Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SVG backend misspaces tick labels whentext.usetex=True #17036

Open
@brunobeltran

Description

@brunobeltran

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
test-no-tex-medium

"No Tex, X-small" - Still has reasonable spacing
test-no-tex-x-small

"Yes Tex, X-small" - Definitely messed up spacing, the two ytick labels don't align at all.
test-yes-tex-x-small

"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.
test-yes-tex-medium

The PDF Results:
"Yes Tex, X-small" - Still works correctly.
pdf

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp