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?

0

2 Answers 2

0

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this actually plt.savefig("~/Documents/folder/age.pdf") but it says file does not exist
Try creating a figure and axis using fig, ax = plt.subplots() and then pass ax = ax into the pandas plotting command.
0

Try this:

bplot = data.groupby(['age']).agg(np.size)['listener_id'].plot(kind='bar')
fig = bplot.get_figure()
fig.savefig("test.png")

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.