I have a log-log contour plot for which I needed to display the minor ticks. So I used
ax.xaxis.set_minor_formatter(fmt("%.1f"))
ax.yaxis.set_minor_formatter(fmt("%.1f"))
where fmt
is from matplotlib.ticker import FormatStrFormatter as fmt
This works fine and gives me all the minor ticks. However as you can see from the attached image, the x-axis ticks, especially 7.0,8.0 and 9.0
are the ticks that overlap , and I want to specifically remove only them, but have the other minor ticks as they are.
Is this possible? I am not able to find a code that removes specific minor ticks.
Immediately after posting the question, I found an easy solution.
It is to use ax.xaxis.set_minor_locator(plt.FixedLocator([2,3,4,5]))
The list inside the FixedLocator
does the job.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.