- #41 Change marker color
- #41 Change marker shape
Once you understood how to plot a basic scatterplot with seaborn, you probably want to custom the appearance of your markers. You can custom color, transparency, shape and size. Here is how to do it:
Control shape
# library and dataset import seaborn as sns df = sns.load_dataset('iris') # Change shape of marker sns.regplot(x=df["sepal_length"], y=df["sepal_width"], marker="+", fit_reg=False) #sns.plt.show()
List of available shapes
# You can see all possible shapes: all_shapes=markers.MarkerStyle.markers.keys() all_shapes #[0, 1, 2, 3, 4, u'D', 6, 7, 8, u's', u'|', 11, u'None', u'P', 9, u'x', u'X', 5, u'_', u'^', u' ', None, u'd', u'h', u'+', u'*', u',', u'o', u'.', u'1', u'p', u'3', u'2', u'4', u'H', u'v', u'', u'8', 10, u'<', u'>']
Color, Transparency and size
# More marker customization: sns.regplot(x=df["sepal_length"], y=df["sepal_width"], fit_reg=False, scatter_kws={"color":"darkred","alpha":0.3,"s":200} ) #sns.plt.show()