- 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 to unset 'sharex' or 'sharey' from two axes in Matplotlib?
To inset sharex and sharey from two axes in matplotlib, we can use 'none', i.e., False or 'none'. Each subplot X- or Y-axis will be independent.
Steps
Set the figure size and adjust the padding between and around the subplots.
Initialize two variables rows and cols.
Create a figure and a set of subplots.
Iterate the axes where rows=2 and cols=4.
Plot the random data on the axis.
To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True rows = 2 cols = 4 fig, axes = plt.subplots(rows, cols, sharex='none', sharey='none', squeeze=False) for row in range(rows): for col in range(cols): axes[row][col].plot(np.random.rand(10), np.random.rand(10)) plt.show()
Output
It will produce the following output −
- Related Articles
- How to plot single data with two Y-axes (two units) in Matplotlib?
- How to switch axes in Matplotlib?
- How to make axes transparent in Matplotlib?
- How do I plot multiple X or Y axes in Matplotlib?
- How to align the bar and line in Matplotlib two Y-axes chart?
- How to change axes background color in Matplotlib?
- How to hide axes and gridlines in Matplotlib?
- How to rotate a simple matplotlib Axes?
- How to share x axes of two subplots after they have been created in Matplotlib?
- How to sharex when using subplot2grid?
- How to plot a point on 3D axes in Matplotlib?
- How to get a matplotlib Axes instance to plot to?
- Change x axes scale in matplotlib
- How can I hide the axes in Matplotlib 3D?
- How to plot sine curve on polar axes using Matplotlib?

Advertisements