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

PNGs lose axis #47

Open
gangemi opened this issue Oct 19, 2023 · 1 comment
Open

PNGs lose axis #47

gangemi opened this issue Oct 19, 2023 · 1 comment

Comments

@gangemi
Copy link

gangemi commented Oct 19, 2023

chart.save("test1-chart.svg") has axis, some white space outside of chart.
chart.save("test1-chart.png") has no axis, png ends at boundaries of chart.

@azogue
Copy link
Owner

azogue commented Nov 24, 2023

For SVG and PNG exports, different matplotlib FigureCanvas classes are used (FigureCanvasSVG for svgs and FigureCanvasAgg if not), but you can pass whatever you need with the canvas_cls= argument to plot.save(), in addition to extra kwargs for the matplotlib's .print_figure() method.

Maybe the defaults are different... or maybe it's a transparency thing? (the frameon attribute of the Figure is set as False, so in PNGs the outside space is transparent.

If you need to set a colored background for the PNG export, you can do this:

# this ensures a figure is created
ax = chart.plot()
# this enables the frame for the background
ax.get_figure().set_frameon(True)
# save with custom facecolor
chart.save("test1-chart.png", facecolor="#FFFF00")

If that's not the problem, could you provide more detailed info to try to reproduce your issue?

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