- 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 make axes transparent in Matplotlib?
To make axes transparent in matplotlib, we can take the following steps,
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure using figure() method.
Add an '~.axes.Axes' to the figure as part of a subplot arrangement.
Set face color of the current axes.
Add an axes to the figure.
Create t and s data using numpy.
Plot t and s data points using plot() method on axis 2 (from step 5).
To make the axis transparent, use set_alpha() method and keep alpha value minimum.
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 fig = plt.figure() ax1 = fig.add_subplot(1, 1, 1) ax1.set_facecolor('orange') ax2 = fig.add_axes([0.5, 0.5, 0.3, 0.3]) t = np.arange(0, 1, 0.01) s = np.sin(t) ax2.plot(t, s, linewidth=2) ax2.patch.set_alpha(0.01) plt.show()
Output
- Related Articles
- How to make Matplotlib scatterplots transparent as a group?
- How to make the marker face color transparent without making the line transparent in Matplotlib?
- How to make simple double head arrows on the axes in Matplotlib?
- How to switch axes in Matplotlib?
- 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 make surfaceview transparent in an Android App?
- How to make a Tkinter canvas rectangle transparent?
- How to plot a point on 3D axes in Matplotlib?
- Plotting a transparent histogram with non-transparent edge in Matplotlib
- How to make a background 20% transparent on Android
- How to make a background 25% transparent on Android?
- How to make a background 25% transparent on iOS
- How to get a matplotlib Axes instance to plot to?

Advertisements