- 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
Matplotlib Backend Differences between Agg and Cairo
Renderer | File types | Description |
---|---|---|
AGG | Png | Raster graphics − high-quality images using the Anti-Grain Geometry engine |
Cairo | png, ps, pdf, svg | Raster or vector graphics − using the Cairo library |
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Set the backend name as "Agg".
- Create a 5☓5 matrix array using numpy.
- Use imshow() method to display data as an image, i.e., on a 2D regular raster.
- To save the figure, use savefig() method.
Example
import matplotlib as mpl import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True mpl.use("Agg") data = np.random.rand(5, 5) plt.imshow(data, interpolation='nearest', cmap="copper") plt.savefig('agg.png')
Output
- Related Articles
- Difference between Frontend Testing and Backend Testing
- What are the differences between add_axes and add_subplot in Matplotlib?
- How to check that pylab backend of Matplotlib runs inline?
- How do you determine which backend is being used by matplotlib?
- How do I configure the behavior of the Qt4Agg backend in Matplotlib?
- How can I set the 'backend' in matplotlib in Python?
- Advanced JavaScript Backend Basics
- Differences between String and StringBuffer
- Differences between C++ and C#
- Differences between C and C#
- Differences between POP3 and IMAP
- Differences Between Selenium and Cucumber
- Differences Between Excel and Tableau
- Differences between Consumerism and Environmentalism
- Differences between Permits and Licenses

Advertisements