- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to save a figure remotely with pylab in Python?
Using the savefig method of the pyplot package, we can save the figure remotely by specifying the location of the figure.
Steps
To use a different backend, set it using matplotlib.use('Agg') method.
Plot the lines using plot() method.
Using savefig() method, we can save the image remotely, just putting the directory.
To show the figure, use plt.show().
Example
import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt plt.plot([1, 2, 3]) plt.savefig("remotely_fig.png")
Output
Advertisements