0

I am tuning color settings of matplotlib images, but I am not sure which parameters should I toggle.

Currently, my image looks like this:

enter image description here

But I would like it to be like this:

enter image description here

As shown, the whole color settings look darker and blur.

I've tried many cmap settings but seems didn't work out.

Can anyone give me some advice? Or can someone suggest better combinations for spectrogram plotting?


About interpolation parameters. I've compared different outcomes but couldn't see the difference.

plt.imshow(im, interpolation = 'bilinear', vmin = 50, vmax = 250)

enter image description here

plt.imshow(im, interpolation = 'none', vmin = 50, vmax = 250)

enter image description here

Seems to me the change of the parameters didn't show differences. Something wrong about the setting?

sealpuppy
  • 615
  • 4
  • 12
  • 27
  • 1
    In principle the image you have is much better than the one you desire because you have a higher resolution. If instead you want to artificially blur your image, you can use other [interpolation settings](https://matplotlib.org/gallery/images_contours_and_fields/interpolation_methods.html). Or you smoothen the image prior to plotting. You can alternatively plot a `contourf` plot, and select the desired number of color levels yourself. – ImportanceOfBeingErnest Feb 09 '19 at 19:03
  • You may also decrease dynamic range via the `vmin` and `vmax` parameters. Finally note, that [there are reasons](https://matplotlib.org/users/dflt_style_changes.html#colormap) to use a different colormap. – ImportanceOfBeingErnest Feb 09 '19 at 19:11
  • @ImportanceOfBeingErnest Thank you for your great advice. I've found that simply toggling `vmin` and `vmax` can achieve my desired outcome. However, I still don't understand the use of `interpolation`. Please see my edited post. – sealpuppy Feb 10 '19 at 06:22
  • You can of course smooth in x and y. How you decide to do that depends a good bit on your data – Jody Klymak Feb 10 '19 at 06:38
  • @JodyKlymak Thanks. By "smoothing" do you have any recommended practices? – sealpuppy Feb 10 '19 at 07:02
  • 1
    For simple plot smoothing, a 1-d of 2-d convolve works good. You can convolve with a top hat or a triangle, or whatever you want. I use numpy.convolve usually https://stackoverflow.com/questions/17595912/gaussian-smoothing-an-image-in-python – Jody Klymak Feb 10 '19 at 16:15

0 Answers0