[Matplotlib-users] log xaxis for contourf

dimitrif df388 at cam.ac.uk
Thu Nov 23 21:42:14 EST 2017


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


More information about the Matplotlib-users mailing list