0

I'm using the data frame plot function to create the following plot: Using the following code:

data.groupby(['age']).agg(np.size)['listener_id'].plot(kind='bar')

enter image description here

How can I save this plot?

HimanAB
  • 2,123
  • 7
  • 25
  • 42

2 Answers2

0

The pandas plotting function wraps matplotlib. You can save these using something like

plt.savefig('<filename>.png')

Demetri Pananos
  • 6,032
  • 6
  • 35
  • 68
0

Try this:

bplot = data.groupby(['age']).agg(np.size)['listener_id'].plot(kind='bar')
fig = bplot.get_figure()
fig.savefig("test.png")
sP_
  • 1,488
  • 2
  • 14
  • 28