I am trying to plot the following graph with the following code:
from sklearn.datasets import make_blobs
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
X,y = make_blobs(n_samples=21,centers=7,shuffle=False)
palette = sns.color_palette("bright", 7)
fig, ax = plt.subplots(figsize=(4,4))
p1 = sns.scatterplot(X[:,0],X[:,1],palette=palette, hue=y,legend='full')
Now, in addition to different colors for different labels, I also want different shapes. However, even when I add the markers
argument, nothing changes.
marker_list = ['.', ',', 'o', 'v', '^', '<', '>']
fig, ax = plt.subplots(figsize=(4,4))
p1 = sns.scatterplot(X[:,0],X[:,1],palette=palette, hue=y,legend='full',markers=marker_list)
Why does the marker
argument not work?
You should add the style
grouping variable, as described in the scatterplot doc. The following line should work:
p1 = sns.scatterplot(X[:,0],X[:,1],palette=palette, hue=y, style=y, legend='full',markers=marker_list)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With