[Matplotlib-users] log xaxis for contourf
Jody Klymak
jklymak at uvic.ca
Thu Nov 23 21:54:53 EST 2017
You are giving contour very irregularly spaced data in x. Its trying to come up w/ those last few contours with very little data and I guess its misbehaving.
If it were me, I’d interpolate onto a regular log10 grid first and then send to contour. Then you have control over how the interpolation takes place...
You may also want to consider just using pcolormesh.
Cheers, Jody
> On Nov 23, 2017, at 18:42 PM, dimitrif <df388 at cam.ac.uk> wrote:
>
> Hi to all,
>
> I spent about 3 hours trying to fix a plotting problem I have with
> matplotlib.pyplot...unfortunately without any sucess.
>
> I want to have a logarithmic xaxis in my contourf plot. Since this is not
> directly possible, I took the log10 of the axis and simply used them. Doing
> so, I get some white space inside the plot for some reason. Can someone give
> me a hint why this is happening? I use the following fraction of code:
>
> #without log scale
> plt.figure(11), plt.cla()
> cf1 = plt.contourf(f_psd_welch, traverseCoord,
> 10*np.log10(psd_hotwire_FS_welch),cmap='viridis')
> cbar1 = plt.colorbar(cf1)
> plt.xlim([min(f_psd_welch), max(f_psd_welch)]), plt.ylim([-50, 50])
>
> <http://matplotlib.1069221.n5.nabble.com/file/t5112/normalX.png>
>
> #with logscale
> plt.figure(11), plt.cla()
> cf1 = plt.contourf(np.log10(f_psd_welch), traverseCoord,
> 10*np.log10(psd_hotwire_FS_welch),cmap='viridis')
> cbar1 = plt.colorbar(cf1)
> plt.xlim([min(np.log10(f_psd_welch[1:])), max(np.log10(f_psd_welch[1:]))]),
> plt.ylim([-50, 50])
>
> <http://matplotlib.1069221.n5.nabble.com/file/t5112/logX.png>
>
> The output is attached.
> I would be happy about any help!
>
> Thanks,
> 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
More information about the Matplotlib-users
mailing list