Skip to content

Commit 12d0199

Browse files
committed
Move axwidth/axheight/aspect-->refwidth/refheight/refaspect, width/height-->figwidth/figheight
1 parent 667bc4d commit 12d0199

17 files changed

Lines changed: 226 additions & 223 deletions

docs/1dplots.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
# %%
132132
import proplot as plot
133-
fig, axs = plot.subplots(ncols=2, axwidth=2.2, share=0)
133+
fig, axs = plot.subplots(ncols=2, refwidth=2.2, share=0)
134134
axs.format(suptitle='Automatic subplot formatting')
135135

136136
# Plot DataArray
@@ -223,7 +223,7 @@
223223

224224
# Generate figure
225225
fig, axs = plot.subplots(
226-
nrows=3, aspect=1.5, axwidth=4,
226+
nrows=3, refaspect=1.5, refwidth=4,
227227
share=0, hratios=(2, 1, 1)
228228
)
229229
axs.format(suptitle='Indicating error bounds with various plotting commands')
@@ -306,7 +306,7 @@
306306

307307
# Generate figure
308308
plot.rc.titleloc = 'uc'
309-
fig, axs = plot.subplots(nrows=2, aspect=2, axwidth=4.8, share=0, hratios=(3, 2))
309+
fig, axs = plot.subplots(nrows=2, refaspect=2, refwidth=4.8, share=0, hratios=(3, 2))
310310

311311
# Side-by-side bars
312312
ax = axs[0]
@@ -337,7 +337,7 @@
337337
cycle = ('gray3', 'gray5', 'gray7')
338338

339339
# Generate figure
340-
fig, axs = plot.subplots(ncols=2, axwidth=2.3, share=0)
340+
fig, axs = plot.subplots(ncols=2, refwidth=2.3, share=0)
341341
axs.format(grid=False, xlabel='xlabel', ylabel='ylabel', suptitle='Area plot demo')
342342

343343
# Overlaid area patches
@@ -363,7 +363,7 @@
363363
data = 4 * (state.rand(50) - 0.5)
364364

365365
# Generate figure
366-
fig, axs = plot.subplots(nrows=2, width=5, aspect=2)
366+
fig, axs = plot.subplots(nrows=2, refaspect=2, figwidth=5)
367367
axs.format(
368368
xmargin=0, xlabel='xlabel', ylabel='ylabel', grid=True,
369369
suptitle='Positive and negative colors demo',
@@ -408,7 +408,7 @@
408408
)
409409

410410
# Generate figure
411-
fig, axs = plot.subplots(ncols=2, axwidth=2.5)
411+
fig, axs = plot.subplots(ncols=2, refwidth=2.5)
412412
axs.format(grid=False, suptitle='Boxes and violins demo')
413413

414414
# Box plots
@@ -449,7 +449,7 @@
449449
import numpy as np
450450
fig, axs = plot.subplots(
451451
share=0, ncols=2, wratios=(2, 1),
452-
width='16cm', aspect=(2, 1)
452+
figwidth='16cm', refaspect=(2, 1)
453453
)
454454
axs.format(suptitle='Parametric plots demo')
455455
cmap = 'IceFire'

docs/2dplots.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133

134134
# %%
135135
import proplot as plot
136-
fig, axs = plot.subplots(nrows=2, axwidth=2.5, share=0)
136+
fig, axs = plot.subplots(nrows=2, refwidth=2.5, share=0)
137137
axs.format(toplabels=('Automatic subplot formatting',))
138138

139139
# Plot DataArray
@@ -220,7 +220,7 @@
220220
import numpy as np
221221

222222
# Pcolor plot with and without distinct levels
223-
fig, axs = plot.subplots(ncols=2, axwidth=2)
223+
fig, axs = plot.subplots(ncols=2, refwidth=2)
224224
state = np.random.RandomState(51423)
225225
data = (state.normal(0, 1, size=(33, 33))).cumsum(axis=0).cumsum(axis=1)
226226
axs.format(suptitle='Pcolor plot with levels')
@@ -233,7 +233,7 @@
233233
import numpy as np
234234
fig, axs = plot.subplots(
235235
[[0, 0, 1, 1, 0, 0], [2, 3, 3, 4, 4, 5]],
236-
wratios=(1.5, 0.5, 1, 1, 0.5, 1.5), axwidth=1.7, ref=1, right='2em'
236+
wratios=(1.5, 0.5, 1, 1, 0.5, 1.5), refwidth=1.7, ref=1, right='2em'
237237
)
238238
axs.format(suptitle='DiscreteNorm color-range standardization')
239239
levels = plot.arange(0, 360, 45)
@@ -292,7 +292,7 @@
292292
# Linear segmented norm
293293
state = np.random.RandomState(51423)
294294
data = 10**(2 * state.rand(20, 20).cumsum(axis=0) / 7)
295-
fig, axs = plot.subplots(ncols=2, axwidth=2.4)
295+
fig, axs = plot.subplots(ncols=2, refwidth=2.4)
296296
ticks = [5, 10, 20, 50, 100, 200, 500, 1000]
297297
for i, (norm, title) in enumerate(zip(
298298
('linear', 'segmented'),
@@ -314,7 +314,7 @@
314314
state = np.random.RandomState(51423)
315315
data1 = (state.rand(20, 20) - 0.43).cumsum(axis=0)
316316
data2 = (state.rand(20, 20) - 0.57).cumsum(axis=0)
317-
fig, axs = plot.subplots(nrows=2, ncols=2, axwidth=2.4, order='F')
317+
fig, axs = plot.subplots(nrows=2, ncols=2, refwidth=2.4, order='F')
318318
cmap = plot.Colormap('DryWet', cut=0.1)
319319
axs.format(suptitle='Diverging normalizer demo')
320320
i = 0
@@ -358,7 +358,7 @@
358358
import numpy as np
359359
fig, axs = plot.subplots(
360360
[[1, 1, 2, 2], [0, 3, 3, 0]],
361-
axwidth=2.2, share=1, span=False, hratios=(1, 0.9)
361+
refwidth=2.2, share=1, span=False, hratios=(1, 0.9)
362362
)
363363
state = np.random.RandomState(51423)
364364
data = state.rand(6, 6)
@@ -416,7 +416,7 @@
416416
data = pd.DataFrame(data, columns=list('abcdefghij'), index=list('abcdefghij'))
417417

418418
# Covariance matrix plot
419-
fig, ax = plot.subplots(axwidth=4.5)
419+
fig, ax = plot.subplots(refwidth=4.5)
420420
m = ax.heatmap(
421421
data, cmap='ColdHot', vmin=-1, vmax=1, N=100,
422422
lw=0.5, edgecolor='k', labels=True, labels_kw={'weight': 'bold'},

docs/axis.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
color='dark blue', suptitlecolor='dark blue',
6565
titleloc='upper center', titlecolor='dark blue', titleborder=False,
6666
)
67-
fig, axs = plot.subplots(nrows=8, axwidth=5, aspect=(8, 1), share=0)
67+
fig, axs = plot.subplots(nrows=8, refwidth=5, refaspect=(8, 1), share=0)
6868
axs.format(suptitle='Tick locators demo')
6969

7070
# Step size for tick locations
@@ -163,7 +163,7 @@
163163
color='gray8', gridcolor='gray8', titlecolor='gray8', suptitlecolor='gray8',
164164
titleloc='upper center', titleborder=False,
165165
)
166-
fig, axs = plot.subplots(nrows=9, axwidth=5, aspect=(8, 1), share=0)
166+
fig, axs = plot.subplots(nrows=9, refwidth=5, refaspect=(8, 1), share=0)
167167

168168
# Scientific notation
169169
axs[0].format(xlim=(0, 1e20), xformatter='sci', title='SciFormatter')
@@ -212,7 +212,7 @@
212212
plot.rc.linewidth = 2
213213
plot.rc.fontsize = 11
214214
locator = [0, 0.25, 0.5, 0.75, 1]
215-
fig, axs = plot.subplots(ncols=2, nrows=2, axwidth=1.5, share=0)
215+
fig, axs = plot.subplots(ncols=2, nrows=2, refwidth=1.5, share=0)
216216

217217
# Formatter comparison
218218
axs[0].format(
@@ -264,7 +264,7 @@
264264
figurefacecolor='w', facecolor='pastel blue',
265265
titleloc='upper center', titleborder=False,
266266
)
267-
fig, axs = plot.subplots(nrows=5, axwidth=6, aspect=(8, 1), share=0)
267+
fig, axs = plot.subplots(nrows=5, refwidth=6, refaspect=(8, 1), share=0)
268268
axs[:4].format(xrotation=0) # no rotation for these examples
269269

270270
# Default date locator
@@ -347,7 +347,7 @@
347347
plot.rc.update({
348348
'linewidth': 1, 'ticklabelweight': 'bold', 'axeslabelweight': 'bold'
349349
})
350-
fig, axs = plot.subplots(ncols=2, nrows=2, axwidth=1.8, share=0)
350+
fig, axs = plot.subplots(ncols=2, nrows=2, refwidth=1.8, share=0)
351351
axs.format(suptitle='Axis scales demo', ytickminor=True)
352352

353353
# Linear and log scales
@@ -387,7 +387,7 @@
387387
# %%
388388
import proplot as plot
389389
import numpy as np
390-
fig, axs = plot.subplots(width=6, nrows=4, aspect=(5, 1), sharex=False)
390+
fig, axs = plot.subplots(nrows=4, refaspect=(5, 1), figwidth=6, sharex=False)
391391
ax = axs[0]
392392

393393
# Sample data
@@ -427,7 +427,7 @@
427427
import proplot as plot
428428
import numpy as np
429429
plot.rc.reset()
430-
fig, axs = plot.subplots(nrows=2, ncols=3, axwidth=1.7, share=0, order='F')
430+
fig, axs = plot.subplots(nrows=2, ncols=3, refwidth=1.7, share=0, order='F')
431431
axs.format(
432432
toplabels=('Power scales', 'Exponential scales', 'Cartographic scales'),
433433
)
@@ -502,7 +502,7 @@
502502
c2 = plot.scale_luminance('red', 0.5)
503503
fig, axs = plot.subplots(
504504
[[1, 1, 2, 2], [0, 3, 3, 0]],
505-
share=0, aspect=2.2, axwidth=3
505+
share=0, refaspect=2.2, refwidth=3
506506
)
507507
axs.format(
508508
suptitle='Duplicate axes with custom transformations',
@@ -540,7 +540,7 @@
540540
plot.rc.update({'grid.alpha': 0.4, 'linewidth': 1, 'grid.linewidth': 1})
541541
c1 = plot.scale_luminance('cerulean', 0.5)
542542
c2 = plot.scale_luminance('red', 0.5)
543-
fig, axs = plot.subplots(ncols=2, share=0, aspect=0.4, axwidth=1.8)
543+
fig, axs = plot.subplots(ncols=2, share=0, refaspect=0.4, refwidth=1.8)
544544
axs.format(suptitle='Duplicate axes with special transformations')
545545

546546
# Pressure as the linear scale, height on opposite axis (scale height 7km)
@@ -570,7 +570,7 @@
570570
plot.rc.margin = 0
571571
c1 = plot.scale_luminance('cerulean', 0.5)
572572
c2 = plot.scale_luminance('red', 0.5)
573-
fig, ax = plot.subplots(aspect=(3, 1), width=6)
573+
fig, ax = plot.subplots(refaspect=(3, 1), figwidth=6)
574574

575575
# Sample data
576576
cutoff = 1 / 5

docs/basics.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
[1, 1, 2, 2],
114114
[0, 3, 3, 0],
115115
]
116-
fig, axs = plot.subplots(array, axwidth=1.8)
116+
fig, axs = plot.subplots(array, refwidth=1.8)
117117
axs.format(
118118
abc=True, abcloc='ul', suptitle='Complex subplot grid',
119119
xlabel='xlabel', ylabel='ylabel'
@@ -130,7 +130,7 @@
130130
[3, 4, 4],
131131
[3, 5, 5],
132132
]
133-
fig, axs = plot.subplots(array, width=5, span=False)
133+
fig, axs = plot.subplots(array, figwidth=5, span=False)
134134
axs.format(
135135
suptitle='Really complex subplot grid',
136136
xlabel='xlabel', ylabel='ylabel', abc=True
@@ -172,7 +172,7 @@
172172

173173
# Example plots
174174
cycle = plot.Cycle('greys', left=0.2, N=5)
175-
fig, axs = plot.subplots(ncols=2, nrows=2, share=0, width=5)
175+
fig, axs = plot.subplots(ncols=2, nrows=2, figwidth=5, share=0)
176176
axs[0].plot(data[:, :5], linewidth=2, linestyle='--', cycle=cycle)
177177
axs[1].scatter(data[:, :5], marker='x', cycle=cycle)
178178
axs[2].pcolormesh(data, cmap='greys')
@@ -230,7 +230,7 @@
230230
# %%
231231
import proplot as plot
232232
import numpy as np
233-
fig, axs = plot.subplots(ncols=2, nrows=2, share=0, tight=True, axwidth=2)
233+
fig, axs = plot.subplots(ncols=2, nrows=2, share=0, tight=True, refwidth=2)
234234
state = np.random.RandomState(51423)
235235
N = 60
236236
x = np.linspace(1, 10, N)
@@ -285,7 +285,7 @@
285285
import proplot as plot
286286
import numpy as np
287287
state = np.random.RandomState(51423)
288-
fig, axs = plot.subplots(ncols=4, nrows=4, axwidth=1.2)
288+
fig, axs = plot.subplots(ncols=4, nrows=4, refwidth=1.2)
289289
axs.format(
290290
xlabel='xlabel', ylabel='ylabel', suptitle='SubplotsContainer demo',
291291
grid=False, xlim=(0, 50), ylim=(-4, 4)
@@ -340,7 +340,7 @@
340340

341341
# Apply settings to figure with context()
342342
with plot.rc.context({'suptitle.size': 13}, toplabelcolor='gray6', linewidth=1.5):
343-
fig, axs = plot.subplots(ncols=2, aspect=1, width=6, span=False, sharey=2)
343+
fig, axs = plot.subplots(ncols=2, figwidth=6, sharey=2, span=False)
344344

345345
# Plot lines
346346
N, M = 100, 6

docs/colorbars_legends.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
# %%
9393
import proplot as plot
9494
import numpy as np
95-
fig, axs = plot.subplots(nrows=2, share=0, axwidth='55mm', panelpad='1em')
95+
fig, axs = plot.subplots(nrows=2, share=0, refwidth='55mm', panelpad='1em')
9696
axs.format(suptitle='Stacked colorbars demo')
9797
state = np.random.RandomState(51423)
9898
N = 10
@@ -139,7 +139,7 @@
139139
# %%
140140
import proplot as plot
141141
import numpy as np
142-
fig, axs = plot.subplots(ncols=3, nrows=3, axwidth=1.4)
142+
fig, axs = plot.subplots(ncols=3, nrows=3, refwidth=1.4)
143143
state = np.random.RandomState(51423)
144144
m = axs.pcolormesh(
145145
state.rand(20, 20), cmap='grays',
@@ -158,7 +158,7 @@
158158
import proplot as plot
159159
import numpy as np
160160
fig, axs = plot.subplots(
161-
ncols=2, nrows=2, axwidth=1.7,
161+
ncols=2, nrows=2, refwidth=1.7,
162162
share=0, wspace=0.3, order='F'
163163
)
164164

@@ -210,7 +210,7 @@
210210
# %%
211211
import proplot as plot
212212
import numpy as np
213-
fig, axs = plot.subplots(share=0, ncols=2, axwidth=2)
213+
fig, axs = plot.subplots(share=0, ncols=2, refwidth=2)
214214

215215
# Colorbars from lines
216216
ax = axs[0]
@@ -268,7 +268,7 @@
268268
import numpy as np
269269
plot.rc.cycle = '538'
270270
labels = ['a', 'bb', 'ccc', 'dddd', 'eeeee']
271-
fig, axs = plot.subplots(ncols=2, span=False, share=1, axwidth=2.3)
271+
fig, axs = plot.subplots(ncols=2, span=False, share=1, refwidth=2.3)
272272
hs1, hs2 = [], []
273273

274274
# On-the-fly legends

0 commit comments

Comments
 (0)