6
6
import numpy as np
7
7
import matplotlib .figure as mfigure
8
8
import matplotlib .transforms as mtransforms
9
- from numbers import Integral
10
9
from . import axes as paxes
11
10
from . import gridspec as pgridspec
12
11
from .config import rc
@@ -237,12 +236,28 @@ def __init__(
237
236
warnings ._warn_proplot ('"aligny" has no effect when spany=True.' )
238
237
alignx = _not_none (alignx , align , rc ['subplots.align' ])
239
238
aligny = _not_none (aligny , align , rc ['subplots.align' ])
240
- self .set_alignx (alignx )
241
- self .set_aligny (aligny )
242
- self .set_sharex (sharex )
243
- self .set_sharey (sharey )
244
- self .set_spanx (spanx )
245
- self .set_spany (spany )
239
+ if int (sharex ) not in range (4 ):
240
+ raise ValueError (
241
+ 'Invalid sharing level sharex={value!r}. '
242
+ 'Axis sharing level can be 0 (share nothing), '
243
+ '1 (hide axis labels), '
244
+ '2 (share limits and hide axis labels), or '
245
+ '3 (share limits and hide axis and tick labels).'
246
+ )
247
+ if int (sharey ) not in range (4 ):
248
+ raise ValueError (
249
+ 'Invalid sharing level sharey={sharey!r}. '
250
+ 'Axis sharing level can be 0 (share nothing), '
251
+ '1 (hide axis labels), '
252
+ '2 (share limits and hide axis labels), or '
253
+ '3 (share limits and hide axis and tick labels).'
254
+ )
255
+ self ._alignx = bool (alignx )
256
+ self ._aligny = bool (aligny )
257
+ self ._sharex = int (sharex )
258
+ self ._sharey = int (sharey )
259
+ self ._spanx = bool (spanx )
260
+ self ._spany = bool (spany )
246
261
247
262
# Various other attributes
248
263
gridspec_kw = gridspec_kw or {}
@@ -1293,102 +1308,48 @@ def set_size_inches(self, w, h=None, forward=True, auto=False):
1293
1308
with context ():
1294
1309
super ().set_size_inches (width , height , forward = forward )
1295
1310
1296
- def get_alignx (self ):
1311
+ @property
1312
+ def alignx (self ):
1297
1313
"""
1298
- Return the *x* axis label alignment mode.
1314
+ The *x* axis label alignment mode.
1299
1315
"""
1300
1316
return self ._alignx
1301
1317
1302
- def get_aligny (self ):
1318
+ @property
1319
+ def aligny (self ):
1303
1320
"""
1304
- Return the *y* axis label alignment mode.
1321
+ The *y* axis label alignment mode.
1305
1322
"""
1306
1323
return self ._aligny
1307
1324
1308
- def get_sharex (self ):
1325
+ @property
1326
+ def sharex (self ):
1309
1327
"""
1310
- Return the *x* axis sharing level.
1328
+ The *x* axis sharing level.
1311
1329
"""
1312
1330
return self ._sharex
1313
1331
1314
- def get_sharey (self ):
1332
+ @property
1333
+ def sharey (self ):
1315
1334
"""
1316
- Return the *y* axis sharing level.
1335
+ The *y* axis sharing level.
1317
1336
"""
1318
1337
return self ._sharey
1319
1338
1320
- def get_spanx (self ):
1339
+ @property
1340
+ def spanx (self ):
1321
1341
"""
1322
- Return the *x* axis label spanning mode.
1342
+ The *x* axis label spanning mode.
1323
1343
"""
1324
1344
return self ._spanx
1325
1345
1326
- def get_spany (self ):
1346
+ @property
1347
+ def spany (self ):
1327
1348
"""
1328
- Return the *y* axis label spanning mode.
1349
+ The *y* axis label spanning mode.
1329
1350
"""
1330
1351
return self ._spany
1331
1352
1332
- def set_alignx (self , value ):
1333
- """
1334
- Set the *x* axis label alignment mode.
1335
- """
1336
- self .stale = True
1337
- self ._alignx = bool (value )
1338
-
1339
- def set_aligny (self , value ):
1340
- """
1341
- Set the *y* axis label alignment mode.
1342
- """
1343
- self .stale = True
1344
- self ._aligny = bool (value )
1345
-
1346
- def set_sharex (self , value ):
1347
- """
1348
- Set the *x* axis sharing level.
1349
- """
1350
- value = int (value )
1351
- if value not in range (4 ):
1352
- raise ValueError (
1353
- 'Invalid sharing level sharex={value!r}. '
1354
- 'Axis sharing level can be 0 (share nothing), '
1355
- '1 (hide axis labels), '
1356
- '2 (share limits and hide axis labels), or '
1357
- '3 (share limits and hide axis and tick labels).'
1358
- )
1359
- self .stale = True
1360
- self ._sharex = value
1361
-
1362
- def set_sharey (self , value ):
1363
- """
1364
- Set the *y* axis sharing level.
1365
- """
1366
- value = int (value )
1367
- if value not in range (4 ):
1368
- raise ValueError (
1369
- 'Invalid sharing level sharey={value!r}. '
1370
- 'Axis sharing level can be 0 (share nothing), '
1371
- '1 (hide axis labels), '
1372
- '2 (share limits and hide axis labels), or '
1373
- '3 (share limits and hide axis and tick labels).'
1374
- )
1375
- self .stale = True
1376
- self ._sharey = value
1377
-
1378
- def set_spanx (self , value ):
1379
- """
1380
- Set the *x* axis label spanning mode.
1381
- """
1382
- self .stale = True
1383
- self ._spanx = bool (value )
1384
-
1385
- def set_spany (self , value ):
1386
- """
1387
- Set the *y* axis label spanning mode.
1388
- """
1389
- self .stale = True
1390
- self ._spany = bool (value )
1391
-
1392
1353
@property
1393
1354
def gridspec (self ):
1394
1355
"""
@@ -1405,16 +1366,7 @@ def ref(self):
1405
1366
`~proplot.ui.figure` arguments are applied to this axes, and
1406
1367
aspect ratio is conserved for this axes in tight layout adjustment.
1407
1368
"""
1408
- return self ._ref
1409
-
1410
- @ref .setter
1411
- def ref (self , ref ):
1412
- if not isinstance (ref , Integral ) or ref < 1 :
1413
- raise ValueError (
1414
- f'Invalid axes number { ref !r} . Must be integer >=1.'
1415
- )
1416
- self .stale = True
1417
- self ._ref = ref
1369
+ return self ._ref_num
1418
1370
1419
1371
def _iter_axes (self , hidden = False , children = False ):
1420
1372
"""
@@ -1438,3 +1390,13 @@ def _iter_axes(self, hidden=False, children=False):
1438
1390
if not hidden and ax ._panel_hidden :
1439
1391
continue # ignore hidden panel and its colorbar/legend child
1440
1392
yield from ax ._iter_axes (hidden = hidden , children = children )
1393
+
1394
+ # Deprecations
1395
+ # NOTE: None of these even *worked* after drawing the figure. And not sure
1396
+ # what value (if any) they add even if we do get them to work.
1397
+ get_alignx , set_alignx = warnings ._read_only_property ('0.6' , 'alignx' )
1398
+ get_aligny , set_aligny = warnings ._read_only_property ('0.6' , 'aligny' )
1399
+ get_sharex , set_sharex = warnings ._read_only_property ('0.6' , 'sharex' )
1400
+ get_sharey , set_sharey = warnings ._read_only_property ('0.6' , 'sharey' )
1401
+ get_spanx , set_spanx = warnings ._read_only_property ('0.6' , 'spanx' )
1402
+ get_spany , set_spany = warnings ._read_only_property ('0.6' , 'spany' )
0 commit comments