- 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
How to make the marker face color transparent without making the line transparent in Matplotlib?
To make the marker face color transparent without making the line transparent in matplotlib, we can take the following steps −
Create x_data and y_data(sin(x_data)), using numpy.
Plot curve using x_data and y_data, with marker style and marker size. By changing the alpha, we can make it transparent to opaque.
To get the essence of transparency (keeping alhpa value lesser), we can make grid lines, to see through.
To display the figure, use the show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x_data = np.linspace(1, 10, 100) y_data = np.sin(x_data) plt.plot(x_data, y_data, c='green', marker='o', alpha=.3, ms=10, lw=1) plt.grid() plt.show()
Output
Advertisements