- 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 change the transparency/opaqueness of a Matplotlib Table?
To change the transparency/opaqueness of a matplotlib table, we can atke following steps
Steps
Set the figure size and adjust the padding between and around the subplots.
Create a figure and a set of subplots.
Create a random dataset with 10×3 dimension.
Create a tuple of columns.
Get rid of the axis markers using axis('off').
Create a table with data and columns.
Iterate each cell of the table and change its transparency/opaqueness using set_alpha() method.
To display the figure, use Show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig, axs = plt.subplots(1, 1) data = np.random.random((10, 3)) columns = ("Column I", "Column II", "Column III") axs.axis('off') the_table = axs.table(cellText=data, colLabels=columns, loc='center') for k, cell in the_table._cells.items(): cell.set_edgecolor('black') if k[0] == 0 or k[1] < 0: cell.set_text_props(weight='bold', color='w') cell.set_facecolor('red') cell.set_alpha(0.5) else: cell.set_facecolor(['green', 'yellow'][k[0] % 2]) cell.set_alpha(0.5) plt.show()
Output
It will produce the following output −
- Related Articles
- How to change the scale of an existing table in Matplotlib?
- How to adjust transparency (alpha) in Seaborn pairplot using Matplotlib?
- Adjusting Text background transparency in Matplotlib
- Transparency for Poly3DCollection plot in Matplotlib
- How to change the linewidth of a hatch in Matplotlib?
- How to turn off transparency in Matplotlib's 3D Scatter plot?
- How to change the color of a plot frame in Matplotlib?
- How to change the font properties of a Matplotlib colorbar label?
- How to change the face color of a plot using Matplotlib?
- How to change the attributes of a networkx / matplotlib graph drawing?
- How to change the default charset of a MySQL table?
- How to change the strength of antialiasing in Matplotlib?
- Setting Transparency Based on Pixel Values in Matplotlib
- How to change the color of a line using radiobuttons in Matplotlib?
- How to change the DPI of a Pandas Dataframe Plot in Matplotlib?

Advertisements