Open
Description
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
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
matplotlib.rcParams['font.size'] = 8
# matplotlib.rcParams['text.hinting'] = 'none' # uncomment to fix problem
plt.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
Expected outcome
Matplotlib version
- Operating system: Ubuntu 16.04.2 LTS
- Matplotlib version: commit 0f05cf4
- 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.ttf
49c0f03ec2fa354df7002bcb6331e106 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.