- 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 retrieve the list of supported file formats for Matplotlib savefig()function?
To retrieve the list of supported file formats for matplotlib savefig() function, we can use get_supported_filetypes().
Steps
- First get the current figure.
- Set the canvas that contains the figure.
- Use get_supported_filetypes() method.
- Iterate the file type items.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt fs = plt.gcf().canvas.get_supported_filetypes() for key, val in fs.items(): print(key, ":", val)
Output
eps : Encapsulated Postscript jpg : Joint Photographic Experts Group jpeg : Joint Photographic Experts Group pdf : Portable Document Format pgf : PGF code for LaTeX png : Portable Network Graphics ps : Postscript raw : Raw RGBA bitmap rgba : Raw RGBA bitmap svg : Scalable Vector Graphics svgz : Scalable Vector Graphics tif : Tagged Image File Format tiff : Tagged Image File Format
Advertisements