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

Skip to content

Commit a235538

Browse files
dstansbytimhoffm
authored andcommitted
Use default colour cycle in more examples (#13063)
* Use default colour cycle in more examples * Update examples/lines_bars_and_markers/eventplot_demo.py Co-Authored-By: dstansby <[email protected]> * Use tab:color instead of CN notation * Replace multiple plots in one line calls * Fix plot > plt * Fix flake8 error ignoring
1 parent 8fe8a86 commit a235538

11 files changed

+30
-29
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ per-file-ignores =
185185
examples/pyplots/pyplot_simple.py: E231, E402
186186
examples/pyplots/pyplot_text.py: E402
187187
examples/pyplots/pyplot_three.py: E402
188-
examples/pyplots/pyplot_two_subplots.py: E302, E402
188+
examples/pyplots/pyplot_two_subplots.py: E402
189189
examples/pyplots/text_commands.py: E231, E402
190190
examples/pyplots/text_layout.py: E231, E402
191191
examples/pyplots/whats_new_1_subplot3d.py: E402

examples/lines_bars_and_markers/barh.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
performance = 3 + 10 * np.random.rand(len(people))
2222
error = np.random.rand(len(people))
2323

24-
ax.barh(y_pos, performance, xerr=error, align='center',
25-
color='green', ecolor='black')
24+
ax.barh(y_pos, performance, xerr=error, align='center')
2625
ax.set_yticks(y_pos)
2726
ax.set_yticklabels(people)
2827
ax.invert_yaxis() # labels read top-to-bottom

examples/lines_bars_and_markers/broken_barh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import matplotlib.pyplot as plt
99

1010
fig, ax = plt.subplots()
11-
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='blue')
11+
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='tab:blue')
1212
ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9),
13-
facecolors=('red', 'yellow', 'green'))
13+
facecolors=('tab:orange', 'tab:green', 'tab:red'))
1414
ax.set_ylim(5, 35)
1515
ax.set_xlim(0, 200)
1616
ax.set_xlabel('seconds since start')

examples/lines_bars_and_markers/eventcollection_demo.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@
3232
# plot the data
3333
fig = plt.figure()
3434
ax = fig.add_subplot(1, 1, 1)
35-
ax.plot(xdata1, ydata1, 'r', xdata2, ydata2, 'b')
35+
ax.plot(xdata1, ydata1, color='tab:blue')
36+
ax.plot(xdata2, ydata2, color='tab:orange')
3637

3738
# create the events marking the x data points
38-
xevents1 = EventCollection(xdata1, color=[1, 0, 0], linelength=0.05)
39-
xevents2 = EventCollection(xdata2, color=[0, 0, 1], linelength=0.05)
39+
xevents1 = EventCollection(xdata1, color='tab:blue', linelength=0.05)
40+
xevents2 = EventCollection(xdata2, color='tab:orange', linelength=0.05)
4041

4142
# create the events marking the y data points
42-
yevents1 = EventCollection(ydata1, color=[1, 0, 0], linelength=0.05,
43+
yevents1 = EventCollection(ydata1, color='tab:blue', linelength=0.05,
4344
orientation='vertical')
44-
yevents2 = EventCollection(ydata2, color=[0, 0, 1], linelength=0.05,
45+
yevents2 = EventCollection(ydata2, color='tab:orange', linelength=0.05,
4546
orientation='vertical')
4647

4748
# add the events to the axis

examples/lines_bars_and_markers/eventplot_demo.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
data1 = np.random.random([6, 50])
2121

2222
# set different colors for each set of positions
23-
colors1 = np.array([[1, 0, 0],
24-
[0, 1, 0],
25-
[0, 0, 1],
26-
[1, 1, 0],
27-
[1, 0, 1],
28-
[0, 1, 1]])
23+
colors1 = ['C{}'.format(i) for i in range(6)]
2924

3025
# set different line properties for each set of positions
3126
# note that some overlap
@@ -49,7 +44,7 @@
4944
# use individual values for the parameters this time
5045
# these values will be used for all data sets (except lineoffsets2, which
5146
# sets the increment between each data set in this usage)
52-
colors2 = [[0, 0, 0]]
47+
colors2 = 'black'
5348
lineoffsets2 = 1
5449
linelengths2 = 1
5550

examples/lines_bars_and_markers/joinstyle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ def plot_angle(ax, x, y, angle, style):
1414
phi = np.radians(angle)
1515
xx = [x + .5, x, x + .5*np.cos(phi)]
1616
yy = [y, y, y + .5*np.sin(phi)]
17-
ax.plot(xx, yy, lw=8, color='blue', solid_joinstyle=style)
17+
ax.plot(xx, yy, lw=8, color='tab:blue', solid_joinstyle=style)
1818
ax.plot(xx[1:], yy[1:], lw=1, color='black')
1919
ax.plot(xx[1::-1], yy[1::-1], lw=1, color='black')
20-
ax.plot(xx[1:2], yy[1:2], 'o', color='red', markersize=3)
20+
ax.plot(xx[1:2], yy[1:2], 'o', color='tab:red', markersize=3)
2121
ax.text(x, y + .2, '%.0f degrees' % angle)
2222

23+
2324
fig, ax = plt.subplots()
2425
ax.set_title('Join style')
2526

examples/lines_bars_and_markers/markevery_prop_cycle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
=================================================================
3-
Implemented support for prop_cycle property markevery in rcParams
4-
=================================================================
2+
=========================================
3+
prop_cycle property markevery in rcParams
4+
=========================================
55
66
This example demonstrates a working solution to issue #8576, providing full
77
support of the markevery property for axes.prop_cycle assignments through

examples/lines_bars_and_markers/scatter_with_legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
fig, ax = plt.subplots()
16-
for color in ['red', 'green', 'blue']:
16+
for color in ['tab:blue', 'tab:orange', 'tab:green']:
1717
n = 750
1818
x, y = rand(2, n)
1919
scale = 200.0 * rand(n)

examples/pyplots/fig_axes_customize_simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
for label in ax1.xaxis.get_ticklabels():
2424
# label is a Text instance
25-
label.set_color('red')
25+
label.set_color('tab:red')
2626
label.set_rotation(45)
2727
label.set_fontsize(16)
2828

2929
for line in ax1.yaxis.get_ticklines():
3030
# line is a Line2D instance
31-
line.set_color('green')
31+
line.set_color('tab:green')
3232
line.set_markersize(25)
3333
line.set_markeredgewidth(3)
3434

examples/pyplots/pyplot_two_subplots.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
import numpy as np
99
import matplotlib.pyplot as plt
1010

11+
1112
def f(t):
1213
return np.exp(-t) * np.cos(2*np.pi*t)
1314

15+
1416
t1 = np.arange(0.0, 5.0, 0.1)
1517
t2 = np.arange(0.0, 5.0, 0.02)
1618

1719
plt.figure()
1820
plt.subplot(211)
19-
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
21+
plt.plot(t1, f(t1), color='tab:blue', marker='o')
22+
plt.plot(t2, f(t2), color='black')
2023

2124
plt.subplot(212)
22-
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
25+
plt.plot(t2, np.cos(2*np.pi*t2), color='tab:orange', linestyle='--')
2326
plt.show()
2427

2528
#############################################################################

examples/text_labels_and_annotations/figlegend_demo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
x = np.arange(0.0, 2.0, 0.02)
1616
y1 = np.sin(2 * np.pi * x)
1717
y2 = np.exp(-x)
18-
l1, l2 = axs[0].plot(x, y1, 'rs-', x, y2, 'go')
18+
l1, = axs[0].plot(x, y1)
19+
l2, = axs[0].plot(x, y2, marker='o')
1920

2021
y3 = np.sin(4 * np.pi * x)
2122
y4 = np.exp(-2 * x)
22-
l3, l4 = axs[1].plot(x, y3, 'yd-', x, y4, 'k^')
23+
l3, = axs[1].plot(x, y3, color='tab:green')
24+
l4, = axs[1].plot(x, y4, color='tab:red', marker='^')
2325

2426
fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
2527
fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right')

0 commit comments

Comments
 (0)