How to increase color resolution in python matplotlib colormap

Viewed 8023

I am making a colormap of a 2D numpy meshgrid:

X, Y = np.meshgrid(fields, frequencies)
cs = ax.contourf(X, Y, fields_freqs_abs_grid, cmap="viridis", N=256)

The values in fields_freqs_abs_grid, which are plotted by color, have already been logarithmically scaled.

The colormap produced by python's matplotlib is coarse -- it scales over 8 colors even though I use "N=256" for the number of RGB pixels. Increasing N to 2048 did not change anything. A plot using the MatLab language on the same data produces a colormap with significantly higher color resolution. How do I increase the number of colors mapped in Python?

The result is: enter image description here

But I want the result to be: enter image description here

Thank you!

1 Answers
Related