- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Save figure as file from iPython notebook using Matplotlib
To save a figure as a file from iPython, we can take the following steps−
- Create a new figure or activate an existing figure.
- Add an axes to the figure using add_axes() method.
- Plot the given list.
- Save the plot using savefig() method.
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_axes([1, 1, 1, 1]) plt.plot([1, 2]) plt.savefig('test.png', bbox_inches='tight')
When we execute the code, it will save the following plot as "test.png".
- How to set the matplotlib figure default size in ipython notebook?
- Automatically run %matplotlib inline in IPython Notebook
- Matplotlib animation not working in IPython Notebook?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- Exporting an svg file from a Matplotlib figure
- Plot width settings in ipython notebook
- Best way to display Seaborn/Matplotlib plots with a dark iPython Notebook profile
- How can I dynamically update my Matplotlib figure as the data file changes?
- How to save a matrix as CSV file using R?
- How to hide <matplotlib.lines.Line2D> in IPython notebook?
- Displaying rotatable 3D plots in IPython or Jupyter Notebook
- Matplotlib figure to image as a numpy array
- Programmatically Stop Interaction for specific Figure in Jupyter notebook
- How to extract text from a web page using Selenium and save it as a text file?
- How to dynamically update a plot in a loop in Ipython notebook?