Reputation: 7913
i am quite new to pandas plot facilities, in the doc, the following command is really handy:
myplot = rts.ret.hist(bins=50, by=rts.primary_mic)
however, the problems comes when i try to get a figure reference from the plot and save it:
myfigure = myplot.get_figure()
AttributeError: 'numpy.ndarray' object has no attribute 'get_figure'
what I understand is, rts.ret.hist(bins=50) returns a plot object, while rts.ret.hist(bins=50 returns an array object.
how should I save my figure in this case?
any clue?
thanks!
Upvotes: 3
Views: 3404
Reputation: 879421
To save the figure, you could use plt.savefig
:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(
[(1, 2), (1, 3), (1, 4), (2, 1), (2, 2)], columns=['col1', 'col2'])
df.hist(bins=4, by=df['col1'])
plt.savefig('/tmp/out.png')
Upvotes: 5