Skip to content

Commit 5377127

Browse files
committed
documented hatchcolor parameter for collections in next whats new entry
1 parent f5978ce commit 5377127

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/users/next_whats_new/separated_hatchcolor.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,30 @@ Previously, hatch colors were the same as edge colors, with a fallback to
5757
xy=(.5, 1.03), xycoords=patch4, ha='center', va='bottom')
5858

5959
plt.show()
60+
61+
For collections, a sequence of colors can be passed to the *hatchcolor* parameter
62+
which will be cycled through for each hatch, similar to *facecolor* and *edgecolor*.
63+
64+
.. plot::
65+
:include-source: true
66+
:alt: A scatter plot of a quadratic function with hatches on the markers. The hatches are colored in blue, orange, and green, respectively. After the first three markers, the colors are cycled through again.
67+
68+
import matplotlib.pyplot as plt
69+
import numpy as np
70+
71+
fig, ax = plt.subplots()
72+
73+
x = np.linspace(0, 1, 10)
74+
y = x**2
75+
colors = ["blue", "orange", "green"]
76+
77+
ax.scatter(
78+
x,
79+
y,
80+
s=800,
81+
hatch="xxxx",
82+
hatchcolor=colors,
83+
facecolor="none",
84+
edgecolor="black",
85+
)
86+
plt.show()

0 commit comments

Comments
 (0)