- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 do I change matplotlib's subplot projection of an existing axis?
It seems difficult to change the projection of an existing axis, but we can take the following steps to create different type projections −
Using subplot() method, add a subplot to the current figure, with nrows=1, ncols=3 and current index=1.
Add a title to the current axis.
Using subplot() method, add a subplot to the current figure, with nrows=1, ncols=3 and current index=2, projection=hammer.
Add a title to current axis, hammer.
Using subplot() method, add a subplot to the current figure, with nrows=1, ncols=3 and current index=3, projection=polar.
Add a title to current axis, polar.
To display the figure, use the show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.subplot(131) plt.title("1D") plt.subplot(132, projection="hammer") plt.title("hammer") plt.subplot(133, projection="polar") plt.title("polar") plt.show()
Output
- Related Articles
- How do I redraw an image using Python's Matplotlib?
- How do I change a MongoDB user's password?
- How can I modify an existing column's data type?
- How do I change the range of the X-axis with datetimes in Matplotlib?
- Adjust one subplot's height in absolute way (not relative) in Matplotlib
- How to change the scale of an existing table in Matplotlib?
- Rotating axis text for each subplot in Matplotlib
- How do I change the axis tick font in a Matplotlib plot when rendering using LaTeX?
- How do I plot a spectrogram the same way that pylab's specgram() does? (Matplotlib)
- How do I change a tag's inner HTML based on their order in JavaScript?
- Plotting dates on the X-axis with Python's Matplotlib
- How can I programmatically select a specific subplot in Matplotlib?
- How to label and change the scale of a Seaborn kdeplot's axes? (Matplotlib)
- How to change an element's class with JavaScript?
- How do I get time of a Python program's execution?

Advertisements