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

Skip to content

Commit 4f44e7d

Browse files
committed
doc: Use axes.prop_cycle in style sheet examples.
1 parent 55043a0 commit 4f44e7d

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

examples/style_sheets/plot_dark_background.py

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

1313
L = 6
1414
x = np.linspace(0, L)
15-
ncolors = len(plt.rcParams['axes.color_cycle'])
15+
ncolors = len(plt.rcParams['axes.prop_cycle'])
1616
shift = np.linspace(0, L, ncolors, endpoint=False)
1717
for s in shift:
1818
plt.plot(x, np.sin(x + s), 'o-')

examples/style_sheets/plot_ggplot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# sinusoidal lines with colors from default color cycle
2626
L = 2*np.pi
2727
x = np.linspace(0, L)
28-
ncolors = len(plt.rcParams['axes.color_cycle'])
28+
ncolors = len(plt.rcParams['axes.prop_cycle'])
2929
shift = np.linspace(0, L, ncolors, endpoint=False)
3030
for s in shift:
3131
ax2.plot(x, np.sin(x + s), '-')
@@ -36,14 +36,15 @@
3636
y1, y2 = np.random.randint(1, 25, size=(2, 5))
3737
width = 0.25
3838
ax3.bar(x, y1, width)
39-
ax3.bar(x + width, y2, width, color=plt.rcParams['axes.color_cycle'][2])
39+
ax3.bar(x + width, y2, width,
40+
color=list(plt.rcParams['axes.prop_cycle'])[2]['color'])
4041
ax3.set_xticks(x + width)
4142
ax3.set_xticklabels(['a', 'b', 'c', 'd', 'e'])
4243

4344
# circles with colors from default color cycle
44-
for i, color in enumerate(plt.rcParams['axes.color_cycle']):
45+
for i, color in enumerate(plt.rcParams['axes.prop_cycle']):
4546
xy = np.random.normal(size=2)
46-
ax4.add_patch(plt.Circle(xy, radius=0.3, color=color))
47+
ax4.add_patch(plt.Circle(xy, radius=0.3, color=color['color']))
4748
ax4.axis('equal')
4849
ax4.margins(0)
4950

examples/style_sheets/plot_grayscale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def color_cycle_example(ax):
1212
L = 6
1313
x = np.linspace(0, L)
14-
ncolors = len(plt.rcParams['axes.color_cycle'])
14+
ncolors = len(plt.rcParams['axes.prop_cycle'])
1515
shift = np.linspace(0, L, ncolors, endpoint=False)
1616
for s in shift:
1717
ax.plot(x, np.sin(x + s), 'o-')

0 commit comments

Comments
 (0)