I am trying to create a dataframe histogram and save it as a file.
Here is my code:
ax=df.hist('ColumnName')
fig=ax.get_figure()
fig.savefig('pictureName.png', dpi=100,
bbox_inches='tight')
The first line works fine; however, the second line returns an error: AttributeError: the object 'numpy.ndarray' does not have the attribute 'get_figure'.
Because this question shows that get_figure () applies to serial.hist (), I also tried using ax=df['ColumnName'].hist()one that successfully created the histogram, but led to the same error message when I tried to implement get_figure ().
As recommended in this other question , I usually skip get_figure () and fig.savefig (), instead I select plt.savefig, but I'm doing a few numbers. In my experience, plt.savefig () is not reliable in storing multiple shapes, instead storing the same pattern several times, even when I use fig.close () after each shape creation and save.
I really want to solve this problem as carefully as possible so that I can seamlessly transfer the solution to other applications, instead of using a different tape every time I have to make a schedule.
Thank you for your help!
source
share