Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgf backend producing invisible dot #1339

Closed
aragilar opened this issue Oct 6, 2012 · 6 comments
Closed

pgf backend producing invisible dot #1339

aragilar opened this issue Oct 6, 2012 · 6 comments
Assignees

Comments

@aragilar
Copy link
Contributor

aragilar commented Oct 6, 2012

When a plot is exported to pgf, or a pdf produced via the pgf backend, an invisible dot is produced in the bottom left hand corner. Can it be removed so that the visible elements take up more of the plot? I've created a gist with a example showing the invisible dot at https://gist.github.com/3844330.

@dmcdougall
Copy link
Member

@pwuertz Any ideas?

@ghost ghost assigned pwuertz Oct 6, 2012
@pwuertz
Copy link
Contributor

pwuertz commented Oct 6, 2012

I noticed that invisible dot too. It is not caused by the matplotlib backend and you'll find that it is present in any plain tikz / pgf picture. It may be some kind of implementation detail of the tikz package.

But if I understood the question correctly, the dot is not the issue. The size of the pgfpicture is defined by the bounding box and the dot doesn't change that. What you asked for is a layout of your figure that takes the available space from the defined figsize.

plt.tight_layout(pad=0.0) is your friend, just add that right before calling savefig

EDIT: it is not caused by the matplotlib backend

@dmcdougall
Copy link
Member

@pwuertz Cheers for the clarification.

@aragilar Do you confirm that tight_layout produces the results you desired?

@pwuertz
Copy link
Contributor

pwuertz commented Oct 6, 2012

@aragilar One more thing, when including pgf commands instead of precompiled pdf files, you may want to ensure that the fonts you are using are matching those used to layout the figure. You can inspect the setup the backend used by looking at the header of "test.pgf". In your case, you might want to disable the pgf.rcfonts rc option.

See http://matplotlib.org/1.2.0/users/pgf.html#font-specification for more info.

@aragilar
Copy link
Contributor Author

aragilar commented Oct 7, 2012

Yes, plt.tight_layout(pad=0.0) fixes the problem. One thing that still confuses me is why plt.tight_layout(pad=0.0) worked, whereas passing the tight_layout=True option to figure and calling fig.tight_layout(pad=0.0) based on http://matplotlib.org/1.2.0/api/figure_api.html#matplotlib.figure.Figure.tight_layout didn't work, and if I passed the tight_layout=True option to figure and tried calling plt.tight_layout(pad=0.0), there appeared to be no effect.

@pwuertz
Copy link
Contributor

pwuertz commented Oct 7, 2012

Tight layout allows you to define the desired padding between the figure contents and its bounding box. The default behaviour is to use a padding that scales with the font-size. With plt.tight_layout(pad=0.0) you define that you don't want any spacing at all, which is probably what you want when the figure is embedded somewhere.

The figure tight_layout parameter enables the automatic use of tight_layout but doesn't allow you to specify the amount of padding. So what happened is that you first triggered a manual layout with no spacing and afterwards the automatic layout kicked in rearranging the figure and leaving the default padding.

@pwuertz pwuertz closed this as completed Oct 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants