@@ -37,6 +37,8 @@ The colors in the default property cycle have been changed from
37
37
38
38
.. plot ::
39
39
40
+ import numpy as np
41
+ import matplotlib.pyplot as plt
40
42
41
43
th = np.linspace(0, 2*np.pi, 512)
42
44
@@ -113,17 +115,19 @@ The new default color map used by `matplotlib.cm.ScalarMappable` instances is
113
115
.. plot ::
114
116
115
117
import numpy as np
118
+ import matplotlib.pyplot as plt
119
+
116
120
N = M = 200
117
121
X, Y = np.ogrid[0:20:N*1j, 0:20:M*1j]
118
122
data = np.sin(np.pi * X*2 / 20) * np.cos(np.pi * Y*2 / 20)
119
123
120
124
fig, (ax2, ax1) = plt.subplots(1, 2, figsize=(7, 3))
121
125
im = ax1.imshow(data, extent=[0, 200, 0, 200])
122
126
ax1.set_title("v2.0: 'viridis'")
123
- fig.colorbar(im, ax=ax1, shrink=.9 )
127
+ fig.colorbar(im, ax=ax1, shrink=0.8 )
124
128
125
129
im2 = ax2.imshow(data, extent=[0, 200, 0, 200], cmap='jet')
126
- fig.colorbar(im2, ax=ax2, shrink=.9 )
130
+ fig.colorbar(im2, ax=ax2, shrink=0.8 )
127
131
ax2.set_title("classic: 'jet'")
128
132
129
133
fig.tight_layout()
@@ -180,6 +184,9 @@ solid light grey lines.
180
184
181
185
.. plot ::
182
186
187
+ import numpy as np
188
+ import matplotlib.pyplot as plt
189
+
183
190
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
184
191
185
192
ax1.grid(color='k', linewidth=.5, linestyle=':')
@@ -263,6 +270,9 @@ The following changes were made to the default behavior of
263
270
264
271
.. plot ::
265
272
273
+ import numpy as np
274
+ import matplotlib.pyplot as plt
275
+
266
276
np.random.seed(2)
267
277
268
278
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
@@ -408,7 +418,7 @@ in your :file:`matplotlibrc` file.
408
418
``boxplot ``
409
419
-----------
410
420
411
- Previously, boxplots were composed of a mish-mash styles that were, for
421
+ Previously, boxplots were composed of a mish-mash of styles that were, for
412
422
better for worse, inherited from Matlab. Most of the elements were blue,
413
423
but the medians were red. The fliers (outliers) were black plus-symbols
414
424
(`+ `) and the whiskers were dashed lines, which created ambiguity if
@@ -422,6 +432,9 @@ obscuring data too much.
422
432
423
433
.. plot ::
424
434
435
+ import numpy as np
436
+ import matplotlib.pyplot as plt
437
+
425
438
data = np.random.lognormal(size=(37, 4))
426
439
fig, (old, new) = plt.subplots(ncols=2, sharey=True)
427
440
with plt.style.context('default'):
@@ -487,6 +500,7 @@ cycle.
487
500
import numpy as np
488
501
489
502
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
503
+ fig.subplots_adjust(wspace=0.3)
490
504
th = np.linspace(0, 2*np.pi, 128)
491
505
N = 5
492
506
@@ -730,7 +744,7 @@ Legends
730
744
=======
731
745
732
746
- By default, the number of points displayed in a legend is now 1.
733
- - The default legend location is ``best ``, so the legend will be
747
+ - The default legend location is ``' best' ``, so the legend will be
734
748
automatically placed in a location to minimize overlap with data.
735
749
- The legend defaults now include rounded corners, a lighter
736
750
boundary, and partially transparent boundary and background.
@@ -856,7 +870,7 @@ RGB space. This ensures that only colors from the color map appear
856
870
in the final image. (If your viewer subsequently resamples the image,
857
871
the artifact may reappear.)
858
872
859
- The previous behavior can not be restored.
873
+ The previous behavior cannot be restored.
860
874
861
875
862
876
Shading
@@ -870,6 +884,67 @@ Shading
870
884
Plot layout
871
885
===========
872
886
<
67ED
/tr>
887
+ Auto limits
888
+ -----------
889
+
890
+ The previous auto-scaling behavior was to find 'nice' round numbers
891
+ as view limits that enclosed the data limits, but this could produce
892
+ bad plots if the data happened to fall on a vertical or
893
+ horizontal line near the chosen 'round number' limit. The new default
894
+ sets the view limits to 5% wider than the data range.
895
+
896
+ .. plot ::
897
+
898
+ import matplotlib as mpl
899
+ import matplotlib.pyplot as plt
900
+ import numpy
901
+
902
+ data = np.zeros(1000)
903
+ data[0] = 1
904
+
905
+ fig = plt.figure(figsize=(6, 3))
906
+
907
+ def demo(fig, rc, title, j):
908
+ with mpl.rc_context(rc=rc):
909
+ ax = fig.add_subplot(1, 2, j)
910
+ ax.plot(data)
911
+ ax.set_title(title)
912
+
913
+ demo(fig, {'axes.autolimit_mode': 'round_numbers',
914
+ 'axes.xmargin': 0,
915
+ 'axes.ymargin': 0}, 'classic', 1)
916
+ demo(fig, {}, 'v2.0', 2)
917
+
918
+ The size of the padding in the x and y directions is controlled by the
919
+ ``'axes.xmargin' `` and ``'axes.ymargin' `` rcParams respectively. Whether
920
+ the view limits should be 'round numbers' is controlled by the
921
+ ``'axes.autolimit_mode' `` rcParam. In the original ``'round_number' `` mode,
922
+ the view limits coincide with ticks.
923
+
924
+ The previous default can be restored by using::
925
+
926
+ mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
927
+ mpl.rcParams['axes.xmargin'] = 0
928
+ mpl.rcParams['axes.ymargin'] = 0
929
+
930
+ or setting::
931
+
932
+ axes.autolimit_mode: round_numbers
933
+ axes.xmargin: 0
934
+ axes.ymargin: 0
935
+
936
+ in your :file: `matplotlibrc ` file.
937
+
938
+
939
+ Z-order
940
+ -------
941
+
942
+ - Ticks and grids are now plotted above solid elements such as
943
+ filled contours, but below lines. To return to the previous
944
+ behavior of plotting ticks and grids above lines, set
945
+ ``rcParams['axes.axisbelow'] = False ``.
946
+
947
+
873
948
Ticks
874
949
-----
875
950
@@ -986,70 +1061,11 @@ case of the AutoLocator, the heuristic algorithm reduces the
986
1061
incidence of overlapping tick labels but does not prevent it.
987
1062
988
1063
989
- Auto limits
990
- -----------
991
-
992
- The previous auto-scaling behavior was to find 'nice' round numbers
993
- as view limits that enclosed the data limits, but this could produce
994
- bad plots if the data happened to fall on a vertical or
995
- horizontal line near the chosen 'round number' limit. The new default
996
- sets the view limits to 5% wider than the data range.
997
-
998
- .. plot ::
999
-
1000
- import matplotlib as mpl
1001
- import matplotlib.pyplot as plt
1002
- import numpy
1003
-
1004
- data = np.zeros(1000)
1005
- data[0] = 1
1006
-
1007
- fig = plt.figure(figsize=(6, 3))
1008
-
1009
- def demo(fig, rc, title, j):
1010
- with mpl.rc_context(rc=rc):
1011
- ax = fig.add_subplot(1, 2, j)
1012
- ax.plot(data)
1013
- ax.set_title(title)
1014
-
1015
- demo(fig, {'axes.autolimit_mode': 'round_numbers',
1016
- 'axes.xmargin': 0,
1017
- 'axes.ymargin': 0}, 'classic', 1)
1018
- demo(fig, {}, 'v2.0', 2)
1019
-
1020
- The size of the padding in the x and y directions is controlled by the
1021
- ``'axes.xmargin' `` and ``'axes.ymargin' `` rcParams respectively. Whether
1022
- the view limits should be 'round numbers' is controlled by the
1023
- ``'axes.autolimit_mode' `` rcParam. In the original ``'round_number' `` mode,
1024
- the view limits coincide with ticks.
1025
-
1026
- The previous default can be restored by using::
1027
-
1028
- mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
1029
- mpl.rcParams['axes.xmargin'] = 0
1030
- mpl.rcParams['axes.ymargin'] = 0
1031
-
1032
- or setting::
1033
-
1034
- axes.autolimit_mode: round_numbers
1035
- axes.xmargin: 0
1036
- axes.ymargin: 0
1037
-
1038
- in your :file: `matplotlibrc ` file.
1039
-
1040
-
1041
-
1042
- Z-order
1043
- -------
1044
-
1045
- - Ticks and grids are now plotted above solid elements such as
1046
- filled contours, but below lines. To return to the previous
1047
- behavior of plotting ticks and grids above lines, set
1048
- ``rcParams['axes.axisbelow'] = False ``.
1049
-
1064
+ Tick label formatting
1065
+ ---------------------
1050
1066
1051
1067
``LogFormatter `` labeling of minor ticks
1052
- ========================================
1068
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1053
1069
1054
1070
Minor ticks on a log axis are now labeled when the axis view limits
1055
1071
span a range less than or equal to the interval between two major
@@ -1081,18 +1097,39 @@ but cannot be controlled independently via ``rcParams``.
1081
1097
1082
1098
1083
1099
``ScalarFormatter `` tick label formatting with offsets
1084
- ======================================================
1100
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1085
1101
1086
1102
With the default of ``rcParams['axes.formatter.useoffset'] = True ``,
1087
1103
an offset will be used when it will save 4 or more digits. This can
1088
1104
be controlled with the new rcParam, ``axes.formatter.offset_threshold ``.
1089
1105
To restore the previous behavior of using an offset to save 2 or more
1090
1106
digits, use ``rcParams['axes.formatter.offset_threshold'] = 2 ``.
1091
1107
1108
+ .. plot ::
1109
+
1110
+ import numpy as np
1111
+ import matplotlib.pyplot as plt
1112
+
1113
+ np.random.seed(5)
1114
+
1115
+ fig = plt.figure(figsize=(6, 3))
1116
+ fig.subplots_adjust(bottom=0.15, wspace=0.3, left=0.09, right=0.95)
1117
+
1118
+ x = np.linspace(2000, 2008, 9)
1119
+ y = np.random.randn(9) + 50000
1120
+
1121
+ with plt.rc_context(rc={'axes.formatter.offset_threshold' : 2}):
1122
+ ax1 = fig.add_subplot(1, 2, 1)
1123
+ ax1.plot(x, y)
1124
+ ax1.set_title('classic')
1125
+
1126
+ ax2 = fig.add_subplot(1, 2, 2)
1127
+ ax2.plot(x, y)
1128
+ ax2.set_title('v2.0')
1092
1129
1093
1130
1094
1131
``AutoDateFormatter `` format strings
1095
- ====================================
1132
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1096
1133
1097
1134
The default date formats are now all based on ISO format, i.e., with
1098
1135
the slowest-moving value first. The date formatters are
0 commit comments