Skip to content

Commit 673f6c5

Browse files
committed
Merge pull request #5774 from mdboom/style-change2
API: Style changes omnibus PR
2 parents 069785d + b394ae7 commit 673f6c5

File tree

77 files changed

+3313
-3179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3313
-3179
lines changed

doc/users/whats_new/rcparams.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Configuration (rcParams)
2222
``svg.hashsalt``
2323
````````````````
2424

25-
If ``svg.hashsalt`` is ``None`` (which it is by default), the svg backend uses ``uuid4`` to generate the hash salt.
26-
If it is not ``None``, it must be a string that is used as the hash salt instead of ``uuid4``.
27-
This allows for deterministic SVG output.
25+
If ``svg.hashsalt`` is ``None`` (which it is by default), the svg
26+
backend uses ``uuid4`` to generate the hash salt. If it is not
27+
``None``, it must be a string that is used as the hash salt instead of
28+
``uuid4``. This allows for deterministic SVG output.

doc/users/whats_new/style_changes.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Changes to the default style
2+
----------------------------
3+
4+
The most important changes in matplotlib 2.0 are the changes to the
5+
default style.
6+
7+
While it is impossible to select the best default for all cases, these
8+
are designed to work well in the most common cases.
9+
10+
These changes include:
11+
12+
Colors
13+
``````
14+
15+
- The default figure background color has changed from grey to white.
16+
Use the rcParam ``figure.facecolor`` to control this.
17+
18+
- The default cycle of colors to draw lines, markers and other content
19+
has been changed. It is based on the `Vega category10 palette
20+
<https://github.com/vega/vega/wiki/Scales#scale-range-literals>`__.
21+
22+
- The default color map used for images and pcolor meshes, etc., has
23+
changed from ``jet`` to ``viridis``.
24+
25+
- For markers, scatter plots, bar charts and pie charts, there is no
26+
longer a black outline around filled markers by default.
27+
28+
- Grid lines are light grey solid 1pt lines. They are no longer dashed by
29+
default.
30+
31+
Plot layout
32+
```````````
33+
34+
- The default dpi used for on-screen is now 100, which is the same as
35+
the old default for saving files. Due to this, the on-screen
36+
display is now more what-you-see-is-what-you-get.
37+
38+
- The number of ticks on an axis is now automatically determined based
39+
on the length of the axis.
40+
41+
- The limits are scaled to exactly the dimensions of the data, plus 5%
42+
padding. The old behavior was to scale to the nearest "round"
43+
numbers. To use the old behavior, set the ``rcParam``
44+
``axes.autolimit_mode`` to ``round_numbers``. To control the
45+
margins on particular side individually, pass any of the following
46+
to any artist or plotting function:
47+
48+
- ``top_margin=False``
49+
- ``bottom_margin=False``
50+
- ``left_margin=False``
51+
- ``right_margin=False``
52+
53+
- Ticks now point outward by default. To have ticks pointing inward,
54+
use the ``rcParams`` ``xtick.direction`` and ``ytick.direction``.
55+
56+
- By default, caps on the ends of errorbars are not present. Use the
57+
rcParam ``errorbar.capsize`` to control this.
58+
59+
Images
60+
``````
61+
62+
- The default mode for image interpolation, in the rcParam
63+
``image.interpolation``, is now ``nearest``.
64+
65+
- The default shading mode for light source shading, in
66+
``matplotlib.colors.LightSource.shade``, is now ``overlay``.
67+
Formerly, it was ``hsv``.
68+
69+
- The default value for the rcParam ``image.resample`` is now
70+
``True``. This will apply interpolation for both upsampling and
71+
downsampling of an image.
72+
73+
Fonts
74+
`````
75+
76+
- The default font has changed from "Bitstream Vera Sans" to "DejaVu
77+
Sans". "DejaVu Sans" is an improvement on "Bistream Vera Sans" that
78+
adds more international and math characters, but otherwise has the
79+
same appearance.
80+
81+
- The default math font when using the built-in math rendering engine
82+
(mathtext) has changed from "Computer Modern" (i.e. LaTeX-like) to
83+
"DejaVu Sans". To revert to the old behavior, set the ``rcParam``
84+
``mathtext.fontset`` to ``cm``. This change has no effect if the
85+
TeX backend is used (i.e. ``text.usetex`` is ``True``).
86+
87+
Dates
88+
`````
89+
90+
- The default date formats are now all based on ISO format, i.e., with
91+
the slowest-moving value first. The date formatters are still
92+
changeable through the ``date.autoformatter.*`` rcParams. Python's
93+
``%x`` and ``%X`` date formats may be of particular interest to
94+
format dates based on the current locale.
95+
96+
Legends
97+
```````
98+
99+
- By default, the number of points displayed in a legend is now 1.
100+
101+
- The default legend location is ``best``, so the legend will be
102+
automatically placed in a location to obscure the least amount of
103+
data possible.
104+
105+
- The legend now has rounded corners by default.

examples/api/demo_affine_image.py

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def imshow_affine(ax, z, *kl, **kwargs):
3737

3838
fig, (ax1, ax2) = plt.subplots(1, 2)
3939
Z = get_image()
40-
im1 = imshow_affine(ax1, Z, interpolation='none', cmap=cm.jet,
40+
im1 = imshow_affine(ax1, Z, interpolation='none',
4141
origin='lower',
4242
extent=[-2, 4, -3, 2], clip_on=True)
4343

@@ -48,15 +48,15 @@ def imshow_affine(ax, z, *kl, **kwargs):
4848
x1, x2, y1, y2 = im1.get_extent()
4949
x3, y3 = x2, y1
5050

51-
ax1.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "r--", lw=3,
51+
ax1.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "--",
5252
transform=trans_data2)
5353

5454
ax1.set_xlim(-3, 5)
5555
ax1.set_ylim(-4, 4)
5656

5757
# image skew
5858

59-
im2 = ax2.imshow(Z, interpolation='none', cmap=cm.jet,
59+
im2 = ax2.imshow(Z, interpolation='none',
6060
origin='lower',
6161
extent=[-2, 4, -3, 2], clip_on=True)
6262
im2._image_skew_coordinate = (3, -2)

examples/api/filled_step.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ def filled_hist(ax, edges, values, bottoms=None, orientation='v',
6161
values = np.r_[values, values[-1]]
6262
bottoms = np.r_[bottoms, bottoms[-1]]
6363
if orientation == 'h':
64-
return ax.fill_betweenx(edges, values, bottoms, **kwargs)
64+
return ax.fill_betweenx(edges, values, bottoms, left_margin=False,
65+
**kwargs)
6566
elif orientation == 'v':
66-
return ax.fill_between(edges, values, bottoms, **kwargs)
67+
return ax.fill_between(edges, values, bottoms, bottom_margin=False,
68+
**kwargs)
6769
else:
6870
raise AssertionError("you should never be here")
6971

@@ -206,3 +208,5 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
206208
ax1.set_xlabel('counts')
207209
ax1.set_ylabel('x')
208210
ax2.set_ylabel('x')
211+
212+
plt.show()

examples/api/histogram_path_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
barpath = path.Path.make_compound_path_from_polys(XY)
3737

3838
# make a patch out of it
39-
patch = patches.PathPatch(
40-
barpath, facecolor='blue', edgecolor='gray', alpha=0.8)
39+
patch = patches.PathPatch(barpath, facecolor='blue')
4140
ax.add_patch(patch)
4241

4342
# update the view limits

examples/api/image_zcoord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
X = 10*np.random.rand(5, 3)
1010

1111
fig, ax = plt.subplots()
12-
ax.imshow(X, cmap=cm.jet, interpolation='nearest')
12+
ax.imshow(X, interpolation='nearest')
1313

1414
numrows, numcols = X.shape
1515

examples/api/patch_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
patches.append(polygon)
4040

4141
colors = 100*np.random.rand(len(patches))
42-
p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4)
42+
p = PatchCollection(patches, alpha=0.4)
4343
p.set_array(np.array(colors))
4444
ax.add_collection(p)
4545
plt.colorbar(p)

examples/api/power_norm_demo.py

100644100755
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
for i, gamma in enumerate(gammas):
2121
plt.subplot(xgrid, ygrid, i + 2)
22-
plt.title('Power law normalization\n$(\gamma=%1.1f)$' % gamma)
22+
plt.title('Power law\n$(\gamma=%1.1f)$' % gamma)
2323
plt.hist2d(data[:, 0], data[:, 1],
2424
bins=100, norm=mcolors.PowerNorm(gamma))
2525

26-
plt.subplots_adjust(hspace=0.39)
26+
plt.tight_layout()
27+
2728
plt.show()

examples/api/sankey_demo_basics.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@
4242
orientations=[-1, 1, 0, 1, 1, 1, -1, -1, 0],
4343
pathlengths=[0.25, 0.25, 0.25, 0.25, 0.25, 0.6, 0.25, 0.25,
4444
0.25],
45-
patchlabel="Widget\nA",
46-
alpha=0.2, lw=2.0) # Arguments to matplotlib.patches.PathPatch()
45+
patchlabel="Widget\nA") # Arguments to matplotlib.patches.PathPatch()
4746
diagrams = sankey.finish()
48-
diagrams[0].patch.set_facecolor('#37c959')
4947
diagrams[0].texts[-1].set_color('r')
5048
diagrams[0].text.set_fontweight('bold')
5149
# Notice:
@@ -66,7 +64,7 @@
6664
sankey = Sankey(ax=ax, unit=None)
6765
sankey.add(flows=flows, label='one',
6866
orientations=[-1, 1, 0, 1, 1, 1, -1, -1, 0])
69-
sankey.add(flows=[-0.25, 0.15, 0.1], fc='#37c959', label='two',
67+
sankey.add(flows=[-0.25, 0.15, 0.1], label='two',
7068
orientations=[-1, -1, -1], prior=0, connect=(0, 0))
7169
diagrams = sankey.finish()
7270
diagrams[-1].patch.set_hatch('/')

examples/api/sankey_demo_links.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
def side(sankey, n=1):
1313
"""Generate a side chain."""
1414
prior = len(sankey.diagrams)
15-
colors = cycle(['orange', 'b', 'g', 'r', 'c', 'm', 'y'])
1615
for i in range(0, 2*n, 2):
1716
sankey.add(flows=[1, -1], orientations=[-1, -1],
18-
patchlabel=str(prior + i), facecolor=next(colors),
17+
patchlabel=str(prior + i),
1918
prior=prior + i - 1, connect=(1, 0), alpha=0.5)
2019
sankey.add(flows=[1, -1], orientations=[1, 1],
21-
patchlabel=str(prior + i + 1), facecolor=next(colors),
20+
patchlabel=str(prior + i + 1),
2221
prior=prior + i, connect=(1, 0), alpha=0.5)
2322

2423

0 commit comments

Comments
 (0)