1

I am trying to make a contour plot for a paper and I'd like to make it in black and white but with more contrast in the gray level.

fig = plt.figure()
ny, nx = 200, 200
ax = fig.add_subplot(1,1,1)
# Generate a regular grid to interpolate the data.
xi = np.linspace(min(x_conv), max(x_conv), nx)
yi = np.linspace(min(y_conv), max(y_conv), ny)
xi, yi = np.meshgrid(xi, yi)
x_new, xi_new = normalize_xy(x_conv), normalize_xy(xi)
y_new, yi_new = normalize_xy(y_conv), normalize_xy(yi)
zi = griddata(x_new,y_new,fwhm_conv,xi_new,yi_new)
cax=ax.pcolormesh(xi,yi,zi, cmap=cm.gray,norm=cm.colors.Normalize(vmax=5.2,vmin=3.8), extent=[min(x_conv),max(x_conv) , min(y_conv), max(y_conv)])
fontsize=15
for tick in ax.xaxis.get_major_ticks():
        tick.label1.set_fontsize(fontsize)
for tick in ax.yaxis.get_major_ticks():
        tick.label1.set_fontsize(fontsize)
cbar = fig.colorbar(cax,format='%0.8g')

How could I increase the contrast and illustrate the sensitivity with more different gray levels betweenenter image description here black and white?

Dalek
  • 4,168
  • 11
  • 48
  • 100
  • 1
    If you plotted it with let's say `jet`, can you determine more color variation in the z values for points in `y in [1000-5000]` than you can in this grayscale plot? Just looks like the data is pretty homogeneous in that band and adding more color steps might not help. – wflynny Oct 11 '13 at 16:27
  • 1
    try to change the values of `vmax` and `vmin`. Since the color mapper is normalized, try to use: `vmin=0.2` and `vmax=0.8`. You can narrow this range and see if you get a better resolution in the middle. Keep in mid that this will clip some data by plotting it as white or black... – Saullo G. P. Castro Oct 11 '13 at 16:39
  • 'jet' is considered harmful See links ad discussion at https://github.com/matplotlib/matplotlib/issues/2467 (and a zillion other places around the web) – tacaswell Oct 11 '13 at 17:06
  • @Saullo Castro The `vmin` and `vmax` are the limits of third axis which I am interested to illustrate in my plot. – Dalek Oct 11 '13 at 17:50
  • log scale might be useful here http://stackoverflow.com/questions/17201172/a-logarithmic-colorbar-in-matplotlib-scatter-plot/17202196#17202196 – tacaswell Oct 11 '13 at 18:00
  • 1
    @SaulloCastro `vmin` and `vmax` are passed through to `Normalize` and are already set by manually setting `norm`. I am not convinced you can percive more gray levels than you are currently showing. There is also the limitation that the almost all of the backends use 8bit ints to represent the rendered colors which provides an absolute limit. – tacaswell Oct 11 '13 at 18:03
  • @tcaswell I tried logNorm and I didn't get much amelioration! – Dalek Oct 11 '13 at 18:45

0 Answers0