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

[Bug]: PGF backend uses incorrect xtick.labelsize and ytick.labelsize when they are small #28112

Closed as not planned
@voidstarstar

Description

@voidstarstar

Bug summary

Whenxtick.labelsize orytick.labelsize is small, usingsavefig withbackend='pgf' causes the size to render too big. There seems to be a minimum size that these labels can have, but other types of labels do not have this restriction. This bug also requires settingtext.usetex=True.

Code for reproduction

importmatplotlib.pyplotaspltplt.rcParams.update({'figure.dpi':400,'text.usetex':True,'ytick.labelsize':1,    })# Create the figure and axis objectsfig,ax=plt.subplots(figsize=(2,1.5))# Plot the datax= [1,2,3,4,5]y= [2,4,6,8,10]ax.plot(x,y)# Set the title and axis labelsax.set_title('My Plot')ax.set_xlabel('X-axis')ax.set_ylabel('Y-axis')# Save the plot to a fileplt.savefig('my_plot_good.png')plt.savefig('my_plot_bad.png',backend='pgf')

Actual outcome

Themy_plot_good.png file shows the y-axis labels with the correct 1pt font size while themy_plot_bad.png file shows the same labels with a much bigger font size.

Expected outcome

Both files may look slightly different since two different backends are used, but both files should still show the y-axis label font size as 1pt.

Additional information

There seems to be a discrepancy with how the backend is set. When setting it in rcParam, it produces the incorrect large version, but when setting it as a flag tosavefig, it produces the correct smaller version.

The above example is for easy reproduction, but my actual original use case was to create a small figure for use in LaTeX. When creating amy_plot.pgf file that is embedded in a LaTeX document, this bug seems to cause the position of the label to be determined based on the large size, but it will actually render using the small size. This is because the pgf file still sets\fontsize correctly. When creating a png or pdf file, however, both the position and rendering use the incorrect larger size.

Operating system

Ubuntu

Matplotlib Version

3.7.5

Matplotlib Backend

pgf

Python version

3.8.10

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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