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

Optimize pdf file output #17

Open
jgieseler opened this issue Sep 26, 2022 · 2 comments
Open

Optimize pdf file output #17

jgieseler opened this issue Sep 26, 2022 · 2 comments

Comments

@jgieseler
Copy link
Owner

jgieseler commented Sep 26, 2022

While it is in principle already possible to save the figure as a (vectorized) pdf file, the resulting plot needs more fine-tuning. Especially, the fonts are too small and partly misaligned (in the legend).

from solarmach import SolarMACH

body_list = ['STEREO-A', 'Earth', 'BepiColombo', 'PSP', 'Solar Orbiter', 'Mars']
vsw_list = [400, 400, 400, 400, 400, 400, 400]   # position-sensitive solar wind speed per body in body_list
date = '2021-10-28 15:15:00'
filename = 'Solar-MACH_'+date.replace(' ', '_')+'.pdf'

sm = SolarMACH(date, body_list, vsw_list)
fig, ax = sm.plot(numbered_markers=True, return_plot_object=True, outfile=filename)

PDF file:
Solar-MACH_2021-10-28_15:15:00.pdf

Corresponding PNG file:
solarmach

(In the code plt.savefig is used with bbox_inches="tight" - does that work for pdf files?)

@johan12345
Copy link

johan12345 commented Sep 26, 2022

Yeah, it may well be that tight_layout() or bbox_inches="tight" interfere with that. Or it could also be related to the dpi=200 setting used while creating the figure...

Would be great if we can get the plots to look the same between PDF and PNG. Maybe it is also worth considering not to use tight_layout() and bbox_inches="tight" at all here to achieve reproducible figure size and margins.

@jgieseler
Copy link
Owner Author

Yes, I think the way to go is to set everything manually and forget the automatic things. As I mentioned, I think they don't do anything with pdfs, and then it's hard to have comparable results... At least the DPI settings are completely ignored for the vector graphics.

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

2 participants