azogue / psychrochart

A Python 3 library to make psychrometric charts and overlay information on them.
MIT License
104 stars 27 forks source link

PNGs lose axis #47

Open gangemi opened 1 year ago

gangemi commented 1 year ago

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 commented 12 months ago

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?