Skip to content

Use default colour cycle in more examples #13063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ per-file-ignores =
examples/pyplots/pyplot_simple.py: E231, E402
examples/pyplots/pyplot_text.py: E402
examples/pyplots/pyplot_three.py: E402
examples/pyplots/pyplot_two_subplots.py: E302, E402
examples/pyplots/pyplot_two_subplots.py: E402
examples/pyplots/text_commands.py: E231, E402
examples/pyplots/text_layout.py: E231, E402
examples/pyplots/whats_new_1_subplot3d.py: E402
Expand Down
3 changes: 1 addition & 2 deletions examples/lines_bars_and_markers/barh.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

ax.barh(y_pos, performance, xerr=error, align='center',
color='green', ecolor='black')
ax.barh(y_pos, performance, xerr=error, align='center')
ax.set_yticks(y_pos)
ax.set_yticklabels(people)
ax.invert_yaxis() # labels read top-to-bottom
Expand Down
4 changes: 2 additions & 2 deletions examples/lines_bars_and_markers/broken_barh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='blue')
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='tab:blue')
ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9),
facecolors=('red', 'yellow', 'green'))
facecolors=('tab:orange', 'tab:green', 'tab:red'))
ax.set_ylim(5, 35)
ax.set_xlim(0, 200)
ax.set_xlabel('seconds since start')
Expand Down
11 changes: 6 additions & 5 deletions examples/lines_bars_and_markers/eventcollection_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@
# plot the data
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(xdata1, ydata1, 'r', xdata2, ydata2, 'b')
ax.plot(xdata1, ydata1, color='tab:blue')
ax.plot(xdata2, ydata2, color='tab:orange')

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

# create the events marking the y data points
yevents1 = EventCollection(ydata1, color=[1, 0, 0], linelength=0.05,
yevents1 = EventCollection(ydata1, color='tab:blue', linelength=0.05,
orientation='vertical')
yevents2 = EventCollection(ydata2, color=[0, 0, 1], linelength=0.05,
yevents2 = EventCollection(ydata2, color='tab:orange', linelength=0.05,
orientation='vertical')

# add the events to the axis
Expand Down
9 changes: 2 additions & 7 deletions examples/lines_bars_and_markers/eventplot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
data1 = np.random.random([6, 50])

# set different colors for each set of positions
colors1 = np.array([[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1]])
colors1 = ['C{}'.format(i) for i in range(6)]

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

Expand Down
5 changes: 3 additions & 2 deletions examples/lines_bars_and_markers/joinstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ def plot_angle(ax, x, y, angle, style):
phi = np.radians(angle)
xx = [x + .5, x, x + .5*np.cos(phi)]
yy = [y, y, y + .5*np.sin(phi)]
ax.plot(xx, yy, lw=8, color='blue', solid_joinstyle=style)
ax.plot(xx, yy, lw=8, color='tab:blue', solid_joinstyle=style)
ax.plot(xx[1:], yy[1:], lw=1, color='black')
ax.plot(xx[1::-1], yy[1::-1], lw=1, color='black')
ax.plot(xx[1:2], yy[1:2], 'o', color='red', markersize=3)
ax.plot(xx[1:2], yy[1:2], 'o', color='tab:red', markersize=3)
ax.text(x, y + .2, '%.0f degrees' % angle)


fig, ax = plt.subplots()
ax.set_title('Join style')

Expand Down
6 changes: 3 additions & 3 deletions examples/lines_bars_and_markers/markevery_prop_cycle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
=================================================================
Implemented support for prop_cycle property markevery in rcParams
=================================================================
=========================================
prop_cycle property markevery in rcParams
=========================================

This example demonstrates a working solution to issue #8576, providing full
support of the markevery property for axes.prop_cycle assignments through
Expand Down
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/scatter_with_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


fig, ax = plt.subplots()
for color in ['red', 'green', 'blue']:
for color in ['tab:blue', 'tab:orange', 'tab:green']:
n = 750
x, y = rand(2, n)
scale = 200.0 * rand(n)
Expand Down
4 changes: 2 additions & 2 deletions examples/pyplots/fig_axes_customize_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

for label in ax1.xaxis.get_ticklabels():
# label is a Text instance
label.set_color('red')
label.set_color('tab:red')
label.set_rotation(45)
label.set_fontsize(16)

for line in ax1.yaxis.get_ticklines():
# line is a Line2D instance
line.set_color('green')
line.set_color('tab:green')
line.set_markersize(25)
line.set_markeredgewidth(3)

Expand Down
7 changes: 5 additions & 2 deletions examples/pyplots/pyplot_two_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
import numpy as np
import matplotlib.pyplot as plt


def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)


t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)

plt.figure()
plt.subplot(211)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
plt.plot(t1, f(t1), color='tab:blue', marker='o')
plt.plot(t2, f(t2), color='black')

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

#############################################################################
Expand Down
6 changes: 4 additions & 2 deletions examples/text_labels_and_annotations/figlegend_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
x = np.arange(0.0, 2.0, 0.02)
y1 = np.sin(2 * np.pi * x)
y2 = np.exp(-x)
l1, l2 = axs[0].plot(x, y1, 'rs-', x, y2, 'go')
l1, = axs[0].plot(x, y1)
l2, = axs[0].plot(x, y2, marker='o')

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

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