- Trending Categories
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 change the linewidth of a hatch in Matplotlib?
To change the linewidth of a hatch in matplotlib, we can set the linewidth of the hatch in the params.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Create x and y=sin(x) data points using numpy.
- Set the linewidth of the hatch in the plot.
- Plot x and y data points using scatter() method with a square marker having "/" hatches with set linewidth.
- To display the figure, use 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 = np.linspace(-5, 5, 25) y = np.sin(x) plt.rcParams['hatch.linewidth'] = 1 plt.scatter(x, y, s=700, marker='s', linewidth=0.05, facecolor='red', hatch='/', alpha=.7) plt.show()
Output
- Related Articles
- How to change the linewidth and markersize separately in a factorplot in Matplotlib?
- How to decrease the hatch density in Matplotlib?
- How to increase colormap/linewidth quality in streamplot Matplotlib?
- How to fill a polygon with a custom hatch in Matplotlib?
- How to decouple hatch and edge color in Matplotlib?
- Plot a circle with an edgecolor and hatch in Matplotlib
- How to change the color of a plot frame in Matplotlib?
- How to change the strength of antialiasing in Matplotlib?
- How to change the transparency/opaqueness of a Matplotlib Table?
- How do I fill a region with only hatch (no background colour) in matplotlib 2.0?
- How to change the color of a line using radiobuttons in Matplotlib?
- How to change the DPI of a Pandas Dataframe Plot in Matplotlib?
- How to change backends in Matplotlib?
- How to change the font properties of a Matplotlib colorbar label?
- How to change the face color of a plot using Matplotlib?

Advertisements