8/7/2023 0 Comments Pyplot scatter marker stylesns.lmplot(x='carat', y='price', data=df, hue='color', fit_reg=False) Selecting hue='color' tells seaborn to split and plot the data based on the unique values in the 'color' column. sns.scatterplot(x='carat', y='price', data=df, hue='color', ec=None) also does the same thing.You can use seaborn which is a wrapper around matplotlib that makes it look prettier by default (rather opinion-based, I know :P) but also adds some plotting functions.įor this you could use seaborn.lmplot with fit_reg=False (which prevents it from automatically doing some regression). (Forgive me for not putting another example image up, I think 2 is enough :P) With seaborn Handles =, , marker='o', color='w', markerfacecolor=v, label=k, markersize=8) for k, v in ems()]Īx.legend(title='color', handles=handles, bbox_to_anchor=(1.05, 1), loc='upper left')ĭf.map(colors) effectively maps the colors from "diamond" to "plotting". fig, ax = plt.subplots(figsize=(6, 6))Ĭolors = Īx.scatter(df, df, c=df.map(colors)) The following code defines a colors dictionary to map the diamond colors to the plotting colors. You can pass plt.scatter a c argument, which allows you to select the colors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |