

- #Seaborn scatter plot legend number Patch#
- #Seaborn scatter plot legend number code#
- #Seaborn scatter plot legend number zip#
# you were overlaying a line plot or a second plot that uses # line-width in our case) that we can add to the legend. # generate a 'fake' Line2D plot (with zero elements and no

# us to loop over each group in the second data frame and # since that information is lost when rendered as a # *cannot* retreive the marker style from the scatterplot # the group name, the color, and the marker style.
#Seaborn scatter plot legend number zip#
# Here's the 'magic' - we use zip to link together

# from the data frame and the number of groups in # markers, and palette using the 'name' parameter # first one) and that we're setting the hue, style, # off (otherwise this legend would overwrite the # Generate the scatterplot: notice that Legend is # but this works for demonstration purposes # to ensure consistency for your own application # frame or set the hue and style order in order # You would probably want to sort your data # it closely matches the alpha of the KDE-plot
#Seaborn scatter plot legend number Patch#
# and adjust the patch alpha level so that # axis to turn off the frame, set the title, # Notice that we access this legend via the # The KDE-plot generates a Legend 'as usual' # Crude way to get different distributions # We will need to access some of these matplotlib classes directlyįrom matplotlib.lines import Line2D # For points and linesįrom matplotlib.patches import Patch # For KDE and other plots This goes a bit beyond the original question, but also builds on response to something more general-I do know some of this is easier in Matplotlib directly, but many of the default styling options for Seaborn are quite nice, so I wanted to work out how you could have more than one legend for a point plot (or other Seaborn plot) without dropping into Matplotlib right at the start. Sns.pointplot(ax=ax,x=x_col,y=y_col,data=df3,color='red')Īx.legend(handles=ax.lines, labels=)Īx.set_xticklabels( for t in ax.get_xticklabels()]) Sns.pointplot(ax=ax,x=x_col,y=y_col,data=df2,color='green') In case one is still interested in obtaining the legend for pointplots, here a way to go: sns.pointplot(ax=ax,x=x_col,y=y_col,data=df1,color='blue') This allows to set labels to the plots and have them automatically put into a legend with ax.legend(). This makes things unnecessarily complicated. I would suggest not to use seaborn pointplot for plotting.
#Seaborn scatter plot legend number code#
Sns.pointplot(ax=ax,x=x_col,y=y_col,data=df,hue='region')īut I would like to know if there is a way to create a legend for the code that first adds sequentially point plot to the figure and then add a legend. One workaround that worked was creating a new dataframe and using hue argument. The documentation does not accept label argument. Sns.pointplot(ax=ax,x=x_col,y=y_col,data=df_2,color='green')

Sns.pointplot(ax=ax,x=x_col,y=y_col,data=df_1,color='blue') My code : f, ax = plt.subplots(1, 1, figsize=figsize) My code takes each of the dataframe and plots it one after another on the same figure.Įach dataframe has same columns date count Also I am plotting all the dataframes on the same axis. I am plotting multiple dataframes as point plot using seaborn.
