How to Save MatplotLib figures to image files

[1293 views]




Matplotlib library is used to present data statistics in the best of manner with python as a base programming language. Data is been skeptically skewed to extract the most important information out of it and then presented using various functions of matplotlibs. These plots can then be used for reporting purpose. Hence, there is a constant requirement to exporting these data out from the python environment.

A very basic solution of the issue in concern, is to save the output of the matplotlib into image files, using a base code as below:

fig = plt.figure() ax = fig.add_axes([0,0,1,1]) ax.axis('equal') data_oneyear_emission = [87.75399456, 28.73753448, 2.500908237, 33.64595918, 24.68887142, 19.91823327] ax.pie(data_oneyear_emission, labels = ["nh3", "nox", "so2", "voc", "pm10", "pm25"],autopct='%1.2f%%') plt.show() fig.savefig("output.png")
                 





Comments





Search
Get Answers to your Programming Questions


Recommended Deals ends in








Quiz For You:

Search Tags