You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
annotate places the number 1 off center when saved as a pdf #2519
I am finding that the annotate function places the number 1 off center when the figure is saved as a pdf. All other numbers appear to be fine. For example,
In the pdf, the 1 is not in the center of the rectangle, but the 2 and 3 are in the centers of their respective rectangles. In the jpg, all three numbers are in the center of their respective rectangles. If I was creating rasterized images I would be happy with the jpg, but I really want a pdf output.
Is this a bug?
I am using Matplotlib 1.2.1 on Python 2.7.3 under Mac OS X 10.8.5
I just tried it in v1.3.0, and the issue is not fixed in my setup. In case it matters, I am running Python 2.7.5, via Spyder 2.2.5, under Mac OS X 10.8.5.
Here is the output for the pdf
The 1 is still off center in the pdf.
Here is the output for the jpg
The 1 is horizontally centered in the jpg.
(It probably is not important, but I had to change y_coord in my original post from [0.9, 0.8, .07] to [0.9, 0.7, 0.5]. I think the original [0.9, 0.8, .07] was a typo.)
Also, now that I have switched to Matplotlib 1.3.0, you can see that the jpg and pdf both have the problem I reported in issue 2527. The vertical alignment of the text inside the bounding box is too high.
As for vertical alignment: In 1.3.0, the bounding box now includes the descenders. This is a bugfix for a number of layout problems in the legend and elsewhere, and I consider the new behavior correct.
As for the horizontal alignment, I'm not able to reproduce, but I think that's mainly because I don't have the Helvetica font installed. Where did you get it? (I can't just Google it -- there's so many incompatible versions floating around, I need to ensure I'm using the same one you are in order to reproduce).
I will respond to your comment about the vertical alignment in issue 2527.
The Helvetica font was already installed on my system (Mac OS X 10.8), so I just stuck a copy in the mpl-data/fonts/ttf/ directory. (If you want a free Helvetica clone you could try URW Nimbus Sans, or the TeX Gyre Heros fonts.)
I am not sure the issue is isolated to the Helvetica font, though. Here is the updated version using the default Bitstream Vera Sans.
in matplotlib 2.2.3, here is the pdf: Test.pdf
and here is the png:
They look pretty similar to me. Either something changed over the last 6.5 years or I became less picky. (I tried to load an old version of matplotlib on my hard drive to see if things were different 6.5 years ago, but pyplot failed to import.) My only complaint is the bounding boxes are too low relative to the text in both the pdf and png, but that is different from the original issue, so I am closing.
Activity
pelson commentedon Jan 9, 2014
This looks like it has been fixed in v1.3.0 and above. Are you able to test with a later version of matplotlib?
Thanks,
breedlun commentedon Jan 9, 2014
I just tried it in v1.3.0, and the issue is not fixed in my setup. In case it matters, I am running Python 2.7.5, via Spyder 2.2.5, under Mac OS X 10.8.5.
Here is the output for the pdf
The 1 is still off center in the pdf.
Here is the output for the jpg
The 1 is horizontally centered in the jpg.
(It probably is not important, but I had to change
y_coordin my original post from[0.9, 0.8, .07]to[0.9, 0.7, 0.5]. I think the original[0.9, 0.8, .07]was a typo.)Also, now that I have switched to Matplotlib 1.3.0, you can see that the jpg and pdf both have the problem I reported in issue 2527. The vertical alignment of the text inside the bounding box is too high.
pelson commentedon Jan 10, 2014
Thanks @stretch97 - Sorry about the premature closing. @mdboom has re-opened.
Cheers!
mdboom commentedon Jan 13, 2014
As for vertical alignment: In 1.3.0, the bounding box now includes the descenders. This is a bugfix for a number of layout problems in the legend and elsewhere, and I consider the new behavior correct.
As for the horizontal alignment, I'm not able to reproduce, but I think that's mainly because I don't have the Helvetica font installed. Where did you get it? (I can't just Google it -- there's so many incompatible versions floating around, I need to ensure I'm using the same one you are in order to reproduce).
breedlun commentedon Jan 14, 2014
I will respond to your comment about the vertical alignment in issue 2527.
The Helvetica font was already installed on my system (Mac OS X 10.8), so I just stuck a copy in the mpl-data/fonts/ttf/ directory. (If you want a free Helvetica clone you could try URW Nimbus Sans, or the TeX Gyre Heros fonts.)
I am not sure the issue is isolated to the Helvetica font, though. Here is the updated version using the default Bitstream Vera Sans.
First the pdf,
and then the jpg,
The numbers in the pdf still look like they are too far to the right, while the numbers in the jpg look fine.
breedlun commentedon Jul 24, 2014
I am not sure, but this issue may be related to issue #253.
story645 commentedon Jun 1, 2016
this seems really similar to #2627
QuLogic commentedon Apr 22, 2020
This looks perfectly fine to me, but the original screenshots are gone, so I don't know what the problem was.
breedlun commentedon Apr 24, 2020
When I run
in matplotlib 2.2.3, here is the pdf:

Test.pdf
and here is the png:
They look pretty similar to me. Either something changed over the last 6.5 years or I became less picky. (I tried to load an old version of matplotlib on my hard drive to see if things were different 6.5 years ago, but pyplot failed to import.) My only complaint is the bounding boxes are too low relative to the text in both the pdf and png, but that is different from the original issue, so I am closing.