Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
As in the title. It's not clear what is going wrong with the calculation. It's easy to reproduce.
Code for reproduction
importmatplotlibasmplimportmatplotlib.pyplotaspltdefblank_axes_log_labeled():fig,ax=plt.subplots(figsize=(3,2))ax.set_yscale('log')ax.set_ylim([0.5,2])ax.set_yticks([0.5,0.6,0.7,0.8,0.9,1,2])#, [r"$5\times{}10^{-1}$", "$10^0$"])ax.set_yticklabels([r"$5\times{}10^{-1}$","","","","","$10^0$",""])ax.set_xscale('log')ax.set_xlim([20,1600])returnfigmpl.rcParams['text.usetex']=False# defaultmpl.rcParams['ytick.labelsize']='medium'# defaultfig=blank_axes_log_labeled()fig.savefig('/home/bbeltr1/Downloads/test-no-tex-medium.svg')mpl.rcParams['ytick.labelsize']='x-small'fig=blank_axes_log_labeled()fig.savefig('/home/bbeltr1/Downloads/test-no-tex-x-small.svg')mpl.rcParams['text.usetex']=Truefig=blank_axes_log_labeled()fig.savefig('/home/bbeltr1/Downloads/test-yes-tex-x-small.svg')fig.savefig('/home/bbeltr1/Downloads/test-yes-tex-x-small.pdf')mpl.rcParams['ytick.labelsize']='medium'fig=blank_axes_log_labeled()fig.savefig('/home/bbeltr1/Downloads/test-yes-tex-medium.svg')
Actual outcome
Converted to PNG in Inkscape (guiding lines added manually in Inkscape to clarify the issue):
The SVG Results:
"No Tex, Medium" - Has reasonable spacing
"No Tex, X-small" - Still has reasonable spacing
"Yes Tex, X-small" - Definitely messed up spacing, the two ytick labels don't align at all.
"Yes Tex, Medium" - Default text width withusetex=True
, while it looks correct by eye, if you know what you're looking for it's still a couple of pixels off.
The PDF Results:
"Yes Tex, X-small" - Still works correctly.
Expected outcome
ytick labels should be reasonably right aligned, even if usetex=True. Works in PDF backend but not SVG backend.
Matplotlib version
- Operating system: Debian 9 (Jessie)
- Matplotlib version: master
- Matplotlib backend (
print(matplotlib.get_backend())
): SVG - Python version:
- Jupyter version (if applicable):
- Other libraries: