1
- Changes to the default style
2
- ----------------------------
1
+ ==============================
2
+ Changes to the default style
3
+ ==============================
3
4
4
5
The most important changes in matplotlib 2.0 are the changes to the
5
6
default style.
6
7
7
8
While it is impossible to select the best default for all cases, these
8
9
are designed to work well in the most common cases.
9
10
10
- These changes include:
11
11
12
- Colors
13
- ``````
12
+
13
+ colors, color cycles, and color maps
14
+ ====================================
15
+
16
+ Colors in default property cycle
17
+ --------------------------------
18
+
19
+ The colors in the default proprety cycle have been changed from
20
+ ``['b', 'g', 'r', 'c', 'm', 'y', 'k'] `` to the `Vega
21
+ category10 palette
22
+ <https://github.com/vega/vega/wiki/Scales#scale-range-literals> `__
23
+
24
+ .. plot ::
25
+
26
+
27
+ th = np.linspace(0, 2*np.pi, 512)
28
+
29
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
30
+
31
+
32
+ def color_demo(ax, colors, title):
33
+ ax.set_title(title)
34
+ for j, c in enumerate(colors):
35
+ v_offset = -(j / len(colors))
36
+ ax.plot(th, .1*np.sin(th) + v_offset, color=c)
37
+ ax.annotate("'C{}'".format(j), (0, v_offset),
38
+ xytext=(-1.5, 0),
39
+ ha='right',
40
+ va='center',
41
+ color=c,
42
+ textcoords='offset points',
43
+ family='monospace')
44
+
45
+ ax.annotate("{!r}".format(c), (2*np.pi, v_offset),
46
+ xytext=(1.5, 0),
47
+ ha='left',
48
+ va='center',
49
+ color=c,
50
+ textcoords='offset points',
51
+ family='monospace')
52
+ ax.axis('off')
53
+
54
+ old_colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
55
+
56
+ new_colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728',
57
+ '#9467bd', '#8c564b', '#e377c2', '#7f7f7f',
58
+ '#bcbd22', '#17becf']
59
+
60
+ color_demo(ax1, old_colors, 'classic')
61
+ color_demo(ax2, new_colors, 'v2.0')
62
+
63
+ fig.subplots_adjust(**{'bottom': 0.0, 'left': 0.059, 'right': 0.869, 'top': 0.895})
64
+
65
+ In addition to changing the colors, an additional method to specify
66
+ colors was added. Previously, the default colors were the single
67
+ character short-hand notations for red, green, blue, cyan, magenta,
68
+ yellow, and black. This made them easy to type and usable in the
69
+ abbreviated style string in ``plot ``. On the other hand, the new
70
+ colors are only specified via a hex value. To make in easy to access
71
+ these colors the notation for colors ``'CN' `` was added to access
72
+ colors. This allows the first 10 colors in
73
+ ``mpl.rcParms['axes.prop_cycle'] `` to be easily accessed. See
74
+ :ref: `colors ` for more details.
75
+
76
+
77
+ Other
78
+ -----
14
79
15
80
- The default figure background color has changed from grey to white.
16
81
Use the rcParam ``figure.facecolor `` to control this.
17
82
18
83
- 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> `__.
84
+ has been changed.
21
85
22
86
- The default color map used for images and pcolor meshes, etc., has
23
87
changed from ``jet `` to ``viridis ``.
@@ -29,14 +93,14 @@ Colors
29
93
default.
30
94
31
95
Plots
32
- `````
96
+ =====
33
97
34
98
- The default size of the elements in a scatter plot is now based on
35
99
the rcParam ``lines.markersize `` so it is consistent with ``plot(X,
36
100
Y, 'o') ``. The old value was 20, and the new value is 36 (6^2).
37
101
38
102
Hatching
39
- ````````
103
+ ========
40
104
41
105
- The width of the lines in a hatch pattern is now configurable by the
42
106
rcParam `hatch.linewidth `, with a default of 1 point. The old
@@ -48,7 +112,7 @@ Hatching
48
112
- Agg: 1 px
49
113
50
114
Plot layout
51
- ```````````
115
+ ===========
52
116
53
117
- The default dpi used for on-screen is now 100, which is the same as
54
118
the old default for saving files. Due to this, the on-screen
@@ -81,7 +145,7 @@ Plot layout
81
145
rcParam ``errorbar.capsize `` to control this.
82
146
83
147
Images
84
- ``````
148
+ ======
85
149
86
150
- The default mode for image interpolation, in the rcParam
87
151
``image.interpolation ``, is now ``nearest ``.
@@ -95,7 +159,7 @@ Images
95
159
downsampling of an image.
96
160
97
161
Fonts
98
- `````
162
+ =====
99
163
100
164
- The default font has changed from "Bitstream Vera Sans" to "DejaVu
101
165
Sans". "DejaVu Sans" is an improvement on "Bistream Vera Sans" that
@@ -109,7 +173,7 @@ Fonts
109
173
TeX backend is used (i.e. ``text.usetex `` is ``True ``).
110
174
111
175
Dates
112
- `````
176
+ =====
113
177
114
178
- The default date formats are now all based on ISO format, i.e., with
115
179
the slowest-moving value first. The date formatters are still
@@ -118,7 +182,7 @@ Dates
118
182
format dates based on the current locale.
119
183
120
184
Legends
121
- ```````
185
+ =======
122
186
123
187
- By default, the number of points displayed in a legend is now 1.
124
188
@@ -129,7 +193,7 @@ Legends
129
193
- The legend now has rounded corners by default.
130
194
131
195
mplot3d
132
- ```````
196
+ =======
133
197
134
198
- mplot3d now obeys some style-related rcParams, rather than using
135
199
hard-coded defaults. These include:
0 commit comments