Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a0647f

Browse files
committed
doc: Use default colours in more examples.
1 parent e27ff2a commit 7a0647f

13 files changed

Lines changed: 17 additions & 17 deletions

examples/api/collections_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
yo = rs.randn(npts)
3939
xyo = list(zip(xo, yo))
4040

41-
# Make a list of colors cycling through the rgbcmyk series.
41+
# Make a list of colors cycling through the default series.
4242
colors = [colorConverter.to_rgba(c)
43-
for c in ('r', 'g', 'b', 'c', 'y', 'm', 'k')]
43+
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
4444

4545
fig, axes = plt.subplots(2, 2)
4646
((ax1, ax2), (ax3, ax4)) = axes # unpack the axes

examples/api/filled_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
172172
hist_func = partial(np.histogram, bins=edges)
173173

174174
# set up style cycles
175-
color_cycle = cycler('facecolor', 'rgbm')
175+
color_cycle = cycler(facecolor=plt.rcParams['axes.prop_cycle'][:4])
176176
label_cycle = cycler('label', ['set {n}'.format(n=n) for n in range(4)])
177177
hatch_cycle = cycler('hatch', ['/', '*', '+', '|'])
178178

examples/pylab_examples/axhspan_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
plt.plot(t, s)
88
# draw a thick red hline at y=0 that spans the xrange
9-
l = plt.axhline(linewidth=4, color='r')
9+
l = plt.axhline(linewidth=4, color='#d62728')
1010

1111
# draw a default hline at y=1 that spans the xrange
1212
l = plt.axhline(y=1)
@@ -16,15 +16,15 @@
1616

1717
# draw a thick blue vline at x=0 that spans the upper quadrant of
1818
# the yrange
19-
l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b')
19+
l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='#1f77b4')
2020

2121
# draw a default hline at y=.5 that spans the middle half of
2222
# the axes
2323
l = plt.axhline(y=.5, xmin=0.25, xmax=0.75)
2424

2525
p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
2626

27-
p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
27+
p = plt.axvspan(1.25, 1.55, facecolor='#2ca02c', alpha=0.5)
2828

2929
plt.axis([-1, 2, -1, 2])
3030

examples/pylab_examples/cohere_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
2323

2424
plt.subplot(211)
25-
plt.plot(t, s1, 'b-', t, s2, 'g-')
25+
plt.plot(t, s1, t, s2)
2626
plt.xlim(0, 5)
2727
plt.xlabel('time')
2828
plt.ylabel('s1 and s2')

examples/pylab_examples/color_by_yvalue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
slower = np.ma.masked_where(s > lower, s)
1414
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
1515

16-
plt.plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')
16+
plt.plot(t, smiddle, t, slower, t, supper)
1717
plt.show()

examples/pylab_examples/csd_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
2323

2424
plt.subplot(211)
25-
plt.plot(t, s1, 'b-', t, s2, 'g-')
25+
plt.plot(t, s1, t, s2)
2626
plt.xlim(0, 5)
2727
plt.xlabel('time')
2828
plt.ylabel('s1 and s2')

examples/pylab_examples/interp_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
yi = stineman_interp(xi, x, y, yp)
1010

1111
fig, ax = plt.subplots()
12-
ax.plot(x, y, 'ro', xi, yi, '-b.')
12+
ax.plot(x, y, 'o', xi, yi, '.')
1313
plt.show()

examples/pylab_examples/legend_demo5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create_artists(self, legend, orig_handle,
5252
x = np.linspace(0, 5, 100)
5353

5454
plt.figure()
55-
colors = ['red', 'orange', 'yellow', 'green', 'blue']
55+
colors = plt.rcParams['axes.prop_cycle'].by_key()['color'][:5]
5656
styles = ['solid', 'dashed', 'dashed', 'dashed', 'solid']
5757
lines = []
5858
for i, color, style in zip(range(5), colors, styles):

examples/pylab_examples/line_collection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# where onoffseq is an even length tuple of on and off ink in points.
3131
# If linestyle is omitted, 'solid' is used
3232
# See matplotlib.collections.LineCollection for more information
33-
colors = [colorConverter.to_rgba(i) for i in 'bgrcmyk']
33+
colors = [colorConverter.to_rgba(c)
34+
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
3435

3536
line_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2),
3637
colors=colors, linestyle='solid')

examples/pylab_examples/masked_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ym1 = np.ma.masked_where(y1 > 0.5, y1)
1616
ym2 = np.ma.masked_where(y2 < -0.5, y2)
1717

18-
lines = plt.plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo')
18+
lines = plt.plot(x, y, x, ym1, x, ym2, 'o')
1919
plt.setp(lines[0], linewidth=4)
2020
plt.setp(lines[1], linewidth=2)
2121
plt.setp(lines[2], markersize=10)

0 commit comments

Comments
 (0)