Saving a Pandas plot to a file with get_figure and savefig

Saving a Pandas plot to a file with get_figure and savefig

After plotting a Python Pandas data frame in Jupyter, how do you save it to a file?

# Grab the axes
ax = df.plot.scatter(x='trip_distance', y='total_amount')
# Get the figure
fig = ax.get_figure()
# Filename extension determines format
fig.savefig('/tmp/myplot.png')