Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mplot3d - How do I display minor ticks?

How do I display (turn on) minor ticks on a 3D surface plot using mplot3d / axes3d graph?

I can define the major tickmark locations using:

ax.w_zaxis.set_major_locator(MultipleLocator(10))

Similarly, I'm guessing I can define the the minor ticks using:

ax.w_zaxis.set_minor_locator(MultipleLocator(2))

This appears to define the minor tick locators but doesn't actually turn them on in my plot. How do I turn the minorticks on in my axes3D?

like image 996
Mark Avatar asked Oct 11 '10 22:10

Mark


2 Answers

From what I can tell, minor tick marks aren't fully implemented in mplot3d. The place I'm looking at in the matplotlib code is Your_Python_Lib_site-packages\mpl_toolkits\mplot3d\axis3d.py in the draw() function. I see only the code to draw the major tick marks, not the minor ones. It seems like it wouldn't be all that hard to modify the code to make it draw the minor tick marks too. I wonder if the matplotlib people even know that the minor tick marks don't work in mplot3d.

like image 80
Justin Peel Avatar answered Oct 19 '22 10:10

Justin Peel


As of v3.3 this can be done by setting minor=True in:

ax.set_xticks(minor=True)
ax.set_yticks(minor=True)
ax.set_zticks(minor=True)
like image 42
iacob Avatar answered Oct 19 '22 09:10

iacob