Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

In ipython Notebook, first create a pandas Series object, then by calling the instance method .hist(), the browser displays the figure.

I am wondering how to save this figure to a file (I mean not by right click and save as, but the commands needed in the script).

1 Answer

0 votes
by (41.4k points)

Using the Figure.savefig() method:

ax = s.hist()  # s is an instance of Series

fig = ax.get_figure()

fig.savefig('/path/to/figure.pdf')

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...