I am trying to make a log-log plot that covers many decades in Matplotlib. However, the default x-axis ticks returned to me are far from ideal as they cover two decades at a time, with only 4 tick marks in between. The code I am using is the following:
rc('text', usetex=True)
f,ax=plt.subplots(figsize=(10,8))
plt.xscale('log')
plt.yscale('log')
plt.ylim([1e26,1e29])
plt.xlim([20,1e10])
plt.xlabel(r'x',fontsize=22)
plt.ylabel(r'y',fontsize=22)
plt.tick_params(axis='both', which='major', labelsize=22,length=9,direction='in')
plt.tick_params(axis='both', which='minor', labelsize=22,length=5,direction='in')
ax.yaxis.set_tick_params(right='on',which='both')
ax.xaxis.set_tick_params(top='on',which='both')
plt.savefig('example.pdf',bbox_inches='tight')
The image returned to me is shown below:
As you can see, the major x-axis labels go from 10^3 to 10^5, etc. On the other hand, there are only 4 minor x-axis labels between major labels. I would like to have major labels every decade, as on the y-axis, with the standard 8 ticks in between each decade. Moreover, I would ideally like for the labelling on the x-axis to stay as is now, in order for the axis to not be too cluttered. That is, I want 10^3, 10^5, 10^7, 10^9 to be labeled as they are now. I just want to extend the major/minor ticks to all decades in between.
Thanks in advance. Also, if it is helpful, I'm using matplotlib version 2.0.0. I need to be using this version (instead of an older version) for additional functionality that is only in 2.0.0.