3d - Matplotlib mplot3d label and ticks overlapping when using LaTeX labels -
how can overlapping of labels , ticks avoided when using matplotlib 3d plots?
the code below produces matplotlib- figure. figure shows problem labelpadding , 3d plots when using latex in labels. (maybe enough rights can post corresponding figure)
there solution if 1 not uses latex in label: adjust label positioning in axes3d of matplotlib
if use latex rendering label \n @ beginning ignored (or produces errors)! have tried lot \phantom , \vspace*, \mbox minipage, not work! there solution mplot3d + x,y,zlabel + latex
in mplot3d api docu (http://matplotlib.org/mpl_toolkits/mplot3d/api.html) mentioned, parameter labelpad not jet implemented 'currently, labelpad not have effect on labels.'.
example:
import matplotlib.pyplot pyplot import mpl_toolkits.mplot3d matplotlib.pyplot import rc rc('text', usetex = true) rc('font', size=9, family='serif', serif='times') fig = pyplot.figure(figsize=(8/2.5, 5/2.5)) ax = fig.gca(projection='3d') plot = ax.plot([.1,.2,.3],[.1,.2,.3]) xlabel = ax.set_xlabel('xxxxxxx') ylabel = ax.set_ylabel('yyyyyyy') zlabel = ax.set_zlabel('zzzzzzz') # \n in here produces error or ignored see below pyplot.show()
... things have tried:
ax.set_ylabel(r"\phantom{x}" "\n" r'abc', linespacing=-0.5)
i found solution scrolling down there: adjust label positioning in axes3d of matplotlib
just add:
ax.xaxis._axinfo['label']['space_factor'] = 2.0 ax.yaxis._axinfo['label']['space_factor'] = 2.0 ax.zaxis._axinfo['label']['space_factor'] = 2.0
that's solution worked me.
Comments
Post a Comment