Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dc291e0

Browse filesBrowse files
committed
Use style package from pyplot
1 parent a8ef5bf commit dc291e0
Copy full SHA for dc291e0

File tree

Expand file treeCollapse file tree

4 files changed

+11
-16
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+11
-16
lines changed

‎doc/users/style_sheets.rst

Copy file name to clipboardExpand all lines: doc/users/style_sheets.rst
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ example, there's a pre-defined style called "ggplot", which emulates the
1313
aesthetics of ggplot_ (a popular plotting package for R_). To use this style,
1414
just add::
1515

16-
>>> from matplotlib import style
17-
>>> style.use('ggplot')
16+
>>> import matplotlib.pyplot as plt
17+
>>> plt.style.use('ggplot')
1818

1919
To list all available styles, use::
2020

21-
>>> print style.available
21+
>>> print plt.style.available
2222

2323

2424
Defining your own style
@@ -45,8 +45,8 @@ For example, you might want to create
4545
Then, when you want to adapt a plot designed for a paper to one that looks
4646
good in a presentation, you can just add::
4747

48-
>>> from matplotlib import style
49-
>>> style.use('presentation')
48+
>>> import matplotlib.pyplot as plt
49+
>>> plt.style.use('presentation')
5050

5151

5252
Composing styles
@@ -57,8 +57,8 @@ sheet that customizes colors and a separate style sheet that alters element
5757
sizes for presentations. These styles can easily be combined by passing
5858
a list of styles::
5959

60-
>>> from matplotlib import style
61-
>>> style.use(['dark_background', 'presentation'])
60+
>>> import matplotlib.pyplot as plt
61+
>>> plt.style.use(['dark_background', 'presentation'])
6262

6363
Note that styles further to the right will overwrite values that are already
6464
defined by styles on the right.
@@ -75,9 +75,8 @@ changes, you can write something like the following::
7575

7676
>>> import numpy as np
7777
>>> import matplotlib.pyplot as plt
78-
>>> from matplotlib import style
7978
>>>
80-
>>> with style.context(('dark_background')):
79+
>>> with plt.style.context(('dark_background')):
8180
>>> plt.plot(np.sin(np.linspace(0, 2*np.pi)), 'r-o')
8281
>>>
8382
>>> # Some plotting code with the default style

‎examples/style_sheets/plot_dark_background.py

Copy file name to clipboardExpand all lines: examples/style_sheets/plot_dark_background.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import numpy as np
88
import matplotlib.pyplot as plt
99

10-
from matplotlib import style
11-
style.use('dark_background')
1210

11+
plt.style.use('dark_background')
1312

1413
L = 6
1514
x = np.linspace(0, L)

‎examples/style_sheets/plot_ggplot.py

Copy file name to clipboardExpand all lines: examples/style_sheets/plot_ggplot.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
"""
1313
import numpy as np
1414
import matplotlib.pyplot as plt
15-
from matplotlib import style
1615

17-
style.use('ggplot')
16+
plt.style.use('ggplot')
1817

1918
fig, axes = plt.subplots(ncols=2, nrows=2)
2019
ax1, ax2, ax3, ax4 = axes.ravel()

‎examples/style_sheets/plot_grayscale.py

Copy file name to clipboardExpand all lines: examples/style_sheets/plot_grayscale.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import numpy as np
88
import matplotlib.pyplot as plt
99

10-
from matplotlib import style
11-
1210

1311
def color_cycle_example(ax):
1412
L = 6
@@ -24,7 +22,7 @@ def image_and_patch_example(ax):
2422
ax.add_patch(c)
2523

2624

27-
style.use('grayscale')
25+
plt.style.use('grayscale')
2826

2927
fig, (ax1, ax2) = plt.subplots(ncols=2)
3028

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.