FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/color/color_cycle_demo.py at master · feisuo/matplotlib · GitHub
feisuo
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
color
/
color_cycle_demo.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (29 loc) · 1.18 KB
Breadcrumbs
matplotlib
/
examples
/
color
/
color_cycle_demo.py
Copy path
File metadata and controls
35 lines (29 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Demo of custom property-cycle settings to control colors and such
for multi-line plots.
This example demonstrates two different APIs:
1. Setting the default rc-parameter specifying the property cycle.
This affects all subsequent axes (but not axes already created).
2. Setting the property cycle for a specific axes. This only
affects a single axes.
"""
from
cycler
import
cycler
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
x
=
np
.
linspace
(
0
,
2
*
np
.
pi
)
offsets
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
4
,
endpoint
=
False
)
# Create array with shifted-sine curve along each column
yy
=
np
.
transpose
([
np
.
sin
(
x
+
phi
)
for
phi
in
offsets
])
plt
.
rc
(
'lines'
,
linewidth
=
4
)
plt
.
rc
(
'axes'
,
prop_cycle
=
(
cycler
(
'color'
, [
'r'
,
'g'
,
'b'
,
'y'
])
+
cycler
(
'linestyle'
, [
'-'
,
'--'
,
':'
,
'-.'
])))
fig
, (
ax0
,
ax1
)
=
plt
.
subplots
(
nrows
=
2
)
ax0
.
plot
(
yy
)
ax0
.
set_title
(
'Set default color cycle to rgby'
)
ax1
.
set_prop_cycle
(
cycler
(
'color'
, [
'c'
,
'm'
,
'y'
,
'k'
])
+
cycler
(
'lw'
, [
1
,
2
,
3
,
4
]))
ax1
.
plot
(
yy
)
ax1
.
set_title
(
'Set axes color cycle to cmyk'
)
# Tweak spacing between subplots to prevent labels from overlapping
plt
.
subplots_adjust
(
hspace
=
0.3
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL