-
Notifications
You must be signed in to change notification settings - Fork 208
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
figsize does not work when exporting sagews plots to PDF #114
Comments
I will add you to this project as soon as I get your email (or name): https://cloud.sagemath.com/projects/1e3b2dde-f9eb-4548-9fe6-a9443c655050/ Then I'll show you which Python file to edit, where in that file, and how to test the result. Then you can research solutions (by googling around and so on) until you figure something out. We can add anybody else to the above project who wants to help. |
Roland open the above project. Then look at the file README.md that I'm about to write. |
Thanks Will. Sorry to take so much to get back at you, had some pressing matter at work. I'll start looking at the link! |
Will, thanks for your help! I tinkered with line 305 of sagews2pdf.py as you suggested. I changed it from: s += '\\includegraphics[width=\\textwidth]{%s}\n'%img to: # omitting [width=\\textwidth] allows figsize to set displayed size
s += '{\\centering\n\\includegraphics{%s}\n\\par\n}\n'%img This works and preserves centering, as it is expected, by using: {\centering
contents\par
} The consequences of this are as follows: Before
After
I've still got to play with 3D plots and see if the issue is present there; I doubt it since in line 326 seems to include Edit:
|
(easy since basically done) |
Umh, this was super easy -- should have done this long ago! |
Hi. I've been trying to export to PDF a Sage WorkSheet that has plots.
When exporting a Notebook to PDF, all plots are scaled to the width of the page (even if there is some vertical overflow when a narrow chart is plotted); I had read in the documentation that the default
figsize
is4
, so I figured since the charts all seem to occupy the width of the page, that a more reasonable size like2
would occupy half as much. However, I haven't been able to make it work, and I think that this is a bug.I tried prepending or appending
sage.plot.graphics.Graphics.SHOW_OPTIONS['figsize'] = 2
as was specified in stack overflow about this very same issue, but the results were the same (as was also reported back then). The issue seems to be reported in track ticket #16212, but only as a lack of documentation and not as a problem in the behavior of the PDF export outcome.Different examples, but same results:
I also tried different approaches, such as not using the
show()
method:Or, even omitting the
aspect_ratio
attribute:The issue I encountered was not shown when displaying the equation in the Notebook in SageCloud (those were displayed properly, and scaled accordingly).
Any workarounds would be greatly appreciated, since I haven't been able to find any documentation to help me out, so far.
P.S. This may not be a bug in itself, as William suggested elsewhere... but I have a hypothesis that it may become a bug when plots have a width/height ratio lower than 0.72 or 0.77 (as discussed here); I will do more testing.
P.P.S. As I also discussed with William, I'll try to implement a fix and ask for help/guidance when needed.
The text was updated successfully, but these errors were encountered: