python - No exponential form of the z-axis in matplotlib-3D-plots -
i have similar problem described in how prevent numbers being changed exponential form in python matplotlib figure:
i don't want (in special case) weird scientific formatting of axis. problem different have problem @ z
-axis. 2-d plots can use ax.get_yaxis().get_major_formatter().set_useoffset(false)
. , there no function ax.get_zaxis()
what use format z
-axis same way?
edit: example:
from mpl_toolkits.mplot3d import axes3d import numpy np import sys import matplotlib import matplotlib.pyplot pyplot def func(xi, ti): res = 10e3 + np.cos(ti) * np.sin(xi) return res if __name__ == '__main__': timespacing = 20 timestart = 0 timeend = 1 time = np.linspace(timestart, timeend, timespacing) widthspacing = 50 widthstart = 0 widthend = 3 width = np.linspace(widthstart, widthend, widthspacing) reslist = [] matplotlib.rcparams['legend.fontsize'] = 10 fig = pyplot.figure() ax = fig.gca(projection = '3d') i, item in enumerate(time): ti = [item t in width] res = func(width, ti) ax.plot(width, ti, res, 'b') ax.set_xlabel('x') ax.set_ylabel('t') ax.set_zlabel('f(x,t)') pyplot.show()
as say, there no get_zaxis()
method. but, fortunately, there zaxis
field (so don't add ()
). there xaxis
, yaxis
fields, can use of uniformly instead of get_...axis()
if like.
for example:
if __name__ == '__main__': ... ax = fig.gca(projection = '3d') ax.zaxis.get_major_formatter().set_useoffset(false) # here i, item in enumerate(time): ...
and end result should this:
as can see, large numbers might not well...
Comments
Post a Comment