77import numpy as np
88import matplotlib as mpl
99import matplotlib .pyplot as plt
10- import matplotlib .ticker as ticker
1110import matplotlib .patheffects as path_effects
1211
1312
13+ mpl .rcParams ['axes.linewidth' ] = 1.5
14+
15+ margin = 0.01
16+ rect = [margin , margin , 1 - 2 * margin , 1 - 2 * margin ]
17+
18+
1419# color range
1520# -----------------------------------------------------------------------------
1621fig = plt .figure (figsize = (2 ,2 ))
17- mpl .rcParams ['axes.linewidth' ] = 1.5
18- d = 0.01
19-
20- ax = fig .add_axes ([d ,d ,1 - 2 * d ,1 - 2 * d ], xticks = [], yticks = [])
22+ ax = fig .add_axes (rect , xticks = [], yticks = [])
2123
2224X = np .random .seed (1 )
2325X = np .random .randn (1000 , 4 )
3133# colorbar
3234# -----------------------------------------------------------------------------
3335fig = plt .figure (figsize = (2.15 ,2 ))
34- mpl .rcParams ['axes.linewidth' ] = 1.5
35- d = 0.01
36- ax = fig .add_axes ([d ,d ,1 - 2 * d ,1 - 2 * d ], xticks = [], yticks = [])
36+ ax = fig .add_axes (rect , xticks = [], yticks = [])
3737
3838np .random .seed (1 )
3939Z = np .random .uniform (0 ,1 ,(8 ,8 ))
6262
6363# dual axis
6464# -----------------------------------------------------------------------------
65- mpl .rcParams ['axes.linewidth' ] = 1.5
66-
67-
6865fig = plt .figure (figsize = (2 ,2 ))
69- d = 0.01
70- ax1 = fig .add_axes ([d ,d ,1 - 2 * d ,1 - 2 * d ], label = "cartesian" )
71- ax2 = fig .add_axes ([d ,d ,1 - 2 * d ,1 - 2 * d ], projection = "polar" , label = "polar" )
66+ ax1 = fig .add_axes (rect , label = "cartesian" )
67+ ax2 = fig .add_axes (rect , projection = "polar" , label = "polar" )
7268
7369ax1 .set_xticks ([]) #np.linspace(0.0, 0.4, 5))
7470ax1 .set_yticks ([]) #np.linspace(0.0, 1.0, 11))
9187def setup (ax ):
9288 ax .spines ['right' ].set_color ('none' )
9389 ax .spines ['left' ].set_color ('none' )
94- ax .yaxis .set_major_locator (ticker .NullLocator ())
90+ ax .yaxis .set_major_locator (mpl . ticker .NullLocator ())
9591 ax .spines ['top' ].set_color ('none' )
9692
93+ ax .spines ['bottom' ].set_linewidth (1 )
9794 ax .spines ['bottom' ].set_position ("center" )
9895
9996 ax .xaxis .set_ticks_position ('bottom' )
@@ -114,10 +111,10 @@ def setup(ax):
114111ax = plt .subplot (n , 1 , 1 )
115112ax .tick_params (axis = 'both' , which = 'minor' , labelsize = 6 )
116113setup (ax )
117- ax .xaxis .set_major_locator (ticker .MultipleLocator (1.0 ))
118- ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.2 ))
119- ax .xaxis .set_major_formatter (ticker .ScalarFormatter ())
120- ax .xaxis .set_minor_formatter (ticker .ScalarFormatter ())
114+ ax .xaxis .set_major_locator (mpl . ticker .MultipleLocator (1.0 ))
115+ ax .xaxis .set_minor_locator (mpl . ticker .MultipleLocator (0.2 ))
116+ ax .xaxis .set_major_formatter (mpl . ticker .ScalarFormatter ())
117+ ax .xaxis .set_minor_formatter (mpl . ticker .ScalarFormatter ())
121118ax .tick_params (axis = 'x' , which = 'minor' , rotation = 0 )
122119
123120for tick in ax .get_xticklabels (which = 'both' ):
@@ -169,8 +166,6 @@ def setup(ax):
169166
170167# multiline
171168# -----------------------------------------------------------------------------
172- mpl .rcParams ['axes.linewidth' ] = 1.5
173-
174169fig = plt .figure (figsize = (8 ,1.5 ))
175170dx ,dy = 0.0025 , 0.01
176171ax = fig .add_axes ([dx , dy , 1 - 2 * dx , 1 - 2 * dy ], frameon = False )
@@ -190,10 +185,8 @@ def setup(ax):
190185# outline
191186# -----------------------------------------------------------------------------
192187fig = plt .figure (figsize = (2 ,2 ))
193- mpl .rcParams ['axes.linewidth' ] = 1.5
194- d = 0.01
195188
196- ax = fig .add_axes ([ d , d , 1 - 2 * d , 1 - 2 * d ] , xticks = [], yticks = [])
189+ ax = fig .add_axes (rect , xticks = [], yticks = [])
197190
198191np .random .seed (1 )
199192Z = np .random .uniform (0 ,1 ,(8 ,8 ))
@@ -209,12 +202,10 @@ def setup(ax):
209202
210203# transparency
211204# -----------------------------------------------------------------------------
212- mpl .rc ('axes' , linewidth = 1.5 )
213-
214205fig = plt .figure (figsize = (2 , 2 ), dpi = 100 )
215- margin = 0.01
216- ax = fig .add_axes ([margin , margin , 1 - 2 * margin , 1 - 2 * margin ])
206+ ax = fig .add_axes (rect )
217207n = 500
208+ np .random .seed (5 )
218209X = np .random .normal (0 , 0.25 , n )
219210Y = np .random .normal (0 , 0.25 , n )
220211ax .scatter (X , Y , s = 50 , c = "k" , lw = 2 )
0 commit comments