[Matplotlib-users] log xaxis for contourf

Ian Thomas ianthomas23 at gmail.com
Fri Nov 24 15:27:55 EST 2017


Dimitri,

Although there is no explicit 'log axis' argument that contour accepts, you
can use this:

plt.contourf(f_psd_welch, traverseCoord, 10*np.log10(psd_hotwire_FS_welch))
plt.gca().set_xscale('log')
plt.xlim([np.min(f_psd_welch[1:]), np.max(f_psd_welch[1:])])

Ian

On 24 November 2017 at 20:03, dimitrif <df388 at cam.ac.uk> wrote:

> Hi Ian,
>
> Amazing, thank you very much for your help! Now, it works as expected.
>
> I actually got the following warning 'RuntimeWarning: divide by zero
> encountered in log10' when running the script but I couldn't connect it to
> the outcome. Sometimes a new pair of eyes and a fresh mind helps to solve
> the issue in a few seconds.
>
> Sounds logically for me that changing the library would not be necessary. I
> wonder why contourf does not have the option to switch the axes to log
> similar to loglog or semilogx? That would look much nicer and save a lot of
> time adjusting the axes of contourf.
>
> Dimitri
>
>
>
> --
> Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-
> f3.html
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171124/ac33ad34/attachment.html>


More information about the Matplotlib-users mailing list