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

tight_layout and font hinting cuts text near the edge #11551

Open
@prekageo

Description

@prekageo

Bug report

I plot a figure with default configuration. I use 8 point fonts and tight_layout. In the resulting PDF, the x and y labels are cut.

Code for reproduction

importmatplotlibmatplotlib.use('agg')importmatplotlib.pyplotaspltmatplotlib.rcParams['font.size']=8# matplotlib.rcParams['text.hinting'] = 'none' # uncomment to fix problemplt.figure(figsize=(.5,.5))plt.xlabel('qyg')plt.ylabel('ETZ')plt.yticks([])plt.xticks([])plt.gca().spines['right'].set_visible(False)plt.gca().spines['top'].set_visible(False)plt.gca().spines['bottom'].set_visible(False)plt.gca().spines['left'].set_visible(False)plt.tight_layout(pad=0)plt.savefig('output.pdf')

Actual outcome

bad.pdf

Expected outcome

good.pdf

Matplotlib version

  • Operating system: Ubuntu 16.04.2 LTS
  • Matplotlib version: commit0f05cf4
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 3.5.2
  • Jupyter version (if applicable):
  • Other libraries:

The font used is the default matplotlib font:

$ md5sum DejaVuSans.ttf49c0f03ec2fa354df7002bcb6331e106  DejaVuSans.ttf

I believe that the problem is here:
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_agg.py#L232
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_pdf.py#L2144

As you can see the PDF backend always uses LOAD_NO_HINTING while the Agg backend uses whatever the user specifies. The only workaround that I've found is enabling the commented out line in the testcase above.

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