azogue / psychrochart

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

How to export Psychrochart as png/svg #17

Closed khyati123456 closed 1 year ago

khyati123456 commented 3 years ago

How to export Psychrochart figure as png/svg

7ukunft commented 1 year ago

plt.savefig("Chart_PNG.png", bbox_inches='tight', dpi=300, transparent=True)

azogue commented 1 year ago

Hi @khyati123456 👋,

Sorry for the long delay in replying 🙏, I had totally forgotten about this library, for years (and had GH notifications muted 🙈)

How to export Psychrochart figure as png/svg

chart.save("chart_image.svg") or chart.save("chart_image.png", transparent=True) will do the task you want, and as the Axes object that chart.plot() returns is a normal matplotlib obj, the usage of pyplot methods is also perfectly valid, as @7ukunft points with plt.savefig()

Also, in the latest version there is a method chart.make_svg() to produce the SVG file as text, to include it in HTML or save it to disk 👌

in jupyter, the better way to print the plot would be:

from IPython.core.display import HTML
from psychrochart import PsychroChart

chart = PsychroChart.create()
svg_data = chart.make_svg()
HTML(svg_data)