- 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 hollow square marks with Matplotlib in Python?
To make hollow square marks with matplotlib, we can use marker 'ks', markerfacecolor='none', markersize=15, and markeredgecolor=red.
Steps
Creat x and y data points using numpy.
Create a figure or activate an existing figure, add an axes to the figure as part of a subplot arrangement.
Plot x and y data points using plot() method. To make hollow square marks, we can use marker "ks" and markerfacecolor="none", markersize="15" and markeredge color="red".
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 x = np.linspace(-2, 2, 10) y = np.sin(x) fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(x, y, 'ks', markerfacecolor='none', ms=15, markeredgecolor='red') plt.show()
Output
Advertisements