python - Matplotlib change marker border color AND custom marker styles -
i trying plot scatter plot in matplotlib using colors list of colors. code here:
import pandas pd import matplotlib.pyplot plt matplotlib.lines import line2d import numpy np pylab import * random import shuffle rcparams['legend.numpoints'] = 1 df = pd.dataframe(np.random.rand(10,28),columns=list('abcdefghijklmnopqrstuvwxyzab')) markers = [] m in line2d.markers: try: if len(m) == 1 , m != ' ': markers.append(m) except typeerror: pass cust = [r'$\lambda$',r'$\bowtie$',r'$\circlearrowleft$',r'$\clubsuit$',r'$\checkmark$',r'$\spadesuit$'] styles = markers + cust shuffle(styles) color=['magenta','blue','green','none','brown','red'] i,column in enumerate(df.iloc[:,1:7]): plt.plot(df['a'], df.iloc[:,i], linestyle='none', marker=styles[i], markersize=10, label=column, mfc=color[i], markeredgewidth=1.5) plt.legend() plt.show() the output attached here.
the problem order of colors in legend not same order of colors in list.
i expecting following order of colors: - magenta, blue, green, none, brown, red
questions:
- the order of colors in plot not same specified in list. possible fix code colors in same order? (note: if marker has no face, want marker edge have color list)
- from custom marker list
cust = [r'$\lambda$',r'$\bowtie$',r'$\circlearrowleft$',r'$\clubsuit$',r'$\checkmark$',r'$\spadesuit$'], there more options similar this? i.e. how can see list of similar markers?
edit: here resulting plot commenting out list of marker styles [i.e. commented out line: shuffle(styles)]. 
Comments
Post a Comment