python - Matplotlib: Use colormap AND use different markers for different values -


i have bunch of (x,y) points stored in array xy, colouring using third array kmap, using matplotlib's in built cmap option.

plt.scatter(xy[:, 0], xy[:, 1], s=70, c=kmap, cmap='bwr') 

this fine. now, want extra. while continuing use cmap, want use different markers according whether kmap values >0, < 0 or =0. how do this?

note: can imagine breaking points, , scatter-plotting them separately, different markers, using if statement. then, don't know how apply continuous cmap these values.

separate dataset looks option. keep consistency between colors, may use vmin, vmax arguments of scatter method

import matplotlib.pyplot plt import numpy np   #generate random data xy = np.random.randn(50, 2) kmax = np.random.randn(50)  #data range vmin, vmax = min(kmax), max(kmax)  #split dataset ipos = kmax >= 0. #positive data (boolean array) ineg = ~ipos      #negative data (boolean array)   #plot 2 dataset different markers plt.scatter(x = xy[ipos, 0], y = xy[ipos, 1], c = kmax[ipos], vmin = vmin, vmax = vmax, cmap = "bwr", marker = "s") plt.scatter(x = xy[ineg, 0], y = xy[ineg, 1], c = kmax[ineg], vmin = vmin, vmax = vmax, cmap = "bwr", marker = "o")  plt.show() 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -