8000 Rename registered axes projections with 'proplot_' prefix · proplot-dev/proplot@be7ef21 · GitHub
[go: up one dir, main page]

Skip to content

Commit be7ef21

Browse files
committed
Rename registered axes projections with 'proplot_' prefix
1 parent dadafaa commit be7ef21

File tree

6 files changed

+24
-25
lines changed

6 files changed

+24
-25
lines changed

proplot/axes/base.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def colorbar(
12001200

12011201
# Draw colorbar axes
12021202
with self.figure._context_authorize_add_subplot():
1203-
ax = self.figure.add_subplot(subplotspec, projection='cartesian') # noqa: E501
1203+
ax = self.figure.add_subplot(subplotspec, projection='proplot_cartesian') # noqa: E501
12041204
self.add_child_axes(ax)
12051205

12061206
# Location
@@ -1508,31 +1508,30 @@ def inset_axes(
15081508
label = kwargs.pop('label', 'inset_axes')
15091509
proj = _not_none(proj=proj, projection=projection)
15101510
proj_kw = _not_none(proj_kw=proj_kw, projection_kw=projection_kw, default={})
1511+
if basemap is not None:
1512+
proj_kw['basemap'] = basemap
15111513

15121514
# Inherit from current axes
15131515
if proj is None:
1514-
proj = self.name
1515-
if basemap is not None:
1516-
proj_kw['basemap'] = basemap
1516+
proj = self.name # will have 'proplot_' prefix
15171517
if proj_kw:
15181518
warnings._warn_proplot(
15191519
'Inheriting projection from the main axes. '
15201520
f'Ignoring proj_kw keyword args: {proj_kw}'
15211521
)
1522-
if proj in ('cartopy', 'basemap'):
1523-
map_projection = copy.copy(self.projection)
1524-
kwargs.setdefault('map_projection', map_projection)
1522+
if proj in ('proplot_cartopy', 'proplot_basemap'):
1523+
m = copy.copy(self.projection)
1524+
kwargs.setdefault('map_projection', m)
15251525

15261526
# Create new projection
15271527
elif proj == 'cartesian':
1528-
pass
1528+
proj = 'proplot_cartesian'
15291529
elif proj == 'polar':
1530-
proj = 'polar2' # custom proplot name
1530+
proj = 'proplot_polar'
15311531
else:
1532-
proj_kw.setdefault('basemap', basemap)
1533-
map_projection = constructor.Proj(proj, **proj_kw)
1534-
kwargs.setdefault('map_projection', map_projection)
1535-
proj = 'basemap' if proj_kw['basemap'] else 'cartopy'
1532+
m = constructor.Proj(proj, **proj_kw)
1533+
kwargs.setdefault('map_projection', m)
1534+
proj = 'proplot_' + m._proj_package
15361535

15371536
# This puts the rectangle into figure-relative coordinates.
15381537
locator = self._make_inset_locator(bounds, transform)

proplot/axes/cartesian.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class CartesianAxes(base.Axes):
203203
methods.
204204
"""
205205
#: The registered projection name.
206-
name = 'cartesian'
206+
name = 'proplot_cartesian'
207207

208208
def __init__(self, *args, **kwargs):
209209
"""
@@ -1228,7 +1228,7 @@ def altx(self, **kwargs):
12281228
raise RuntimeError('No more than *two* twin axes are allowed.')
12291229
with self.figure._context_authorize_add_subplot():
12301230
ylocator = self.yaxis.get_minor_locator()
1231-
ax = self._make_twin_axes(sharey=self, projection='cartesian')
1231+
ax = self._make_twin_axes(sharey=self, projection='proplot_cartesian')
12321232
ax.yaxis.set_minor_locator(ylocator)
12331233
ax.yaxis.isDefault_minloc = True
12341234
ax.set_autoscaley_on(self.get_autoscaley_on())
@@ -1252,7 +1252,7 @@ def alty(self, **kwargs):
12521252
raise RuntimeError('No more than *two* twin axes are allowed.')
12531253
with self.figure._context_authorize_add_subplot():
12541254
xlocator = self.xaxis.get_minor_locator()
1255-
ax = self._make_twin_axes(sharex=self, projection='cartesian')
1255+
ax = self._make_twin_axes(sharex=self, projection='proplot_cartesian')
12561256
ax.xaxis.set_minor_locator(xlocator)
12571257
ax.xaxis.isDefault_minloc = True
12581258
ax.set_autoscalex_on(self.get_autoscalex_on())

proplot/axes/geo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class CartopyAxes(GeoAxes, GeoAxesBase):
703703
the equator by default.
704704
"""
705705
#: The registered projection name.
706-
name = 'cartopy'
706+
name = 'proplot_cartopy'
707707
_proj_north = (
708708
pcrs.NorthPolarStereo,
709709
pcrs.NorthPolarGnomonic,
@@ -1236,7 +1236,7 @@ class BasemapAxes(GeoAxes):
12361236
to plotting methods by default.
123712 A3E2 37
"""
12381238
#: The registered projection name.
1239-
name = 'basemap'
1239+
name = 'proplot_basemap'
12401240
_proj_north = ('npaeqd', 'nplaea', 'npstere')
12411241
_proj_south = ('spaeqd', 'splaea', 'spstere')
12421242
_proj_polar = _proj_north + _proj_south

proplot/axes/polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PolarAxes(base.Axes, mproj.PolarAxes):
2222
method and overrides several existing methods.
2323
"""
2424
#: The registered projection name.
25-
name = 'polar2'
25+
name = 'proplot_polar'
2626

2727
def __init__(self, *args, **kwargs):
2828
"""

proplot/figure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _add_axes_panel(self, ax, side, filled=False, **kwargs):
340340

341341
# Draw and setup panel
342342
with self._context_authorize_add_subplot():
343-
pax = self.add_subplot(gridspec[idx1, idx2], projection='cartesian') # noqa: E501
343+
pax = self.add_subplot(gridspec[idx1, idx2], projection='proplot_cartesian')
344344
pgrid.append(pax)
345345
pax._panel_side = side
346346
pax._panel_share = share
@@ -450,7 +450,7 @@ def _add_figure_panel(
450450

451451
# Draw and setup panel
452452
with self._context_authorize_add_subplot():
453-
pax = self.add_subplot(gridspec[idx1, idx2], projection='cartesian') # noqa: E501
453+
pax = self.add_subplot(gridspec[idx1, idx2], projection='proplot_cartesian')
454454
pgrid = getattr(self, '_' + side + '_panels')
455455
pgrid.append(pax)
456456
pax._panel_side = side
@@ -1064,7 +1064,7 @@ def add_subplot(self, *args, **kwargs):
10641064
if (
10651065
len(args) == 1
10661066
and isinstance(args[0], mgridspec.SubplotSpec)
1067-
and kwargs.get('projection', None) in ('cartesian', 'polar2', 'basemap', 'cartopy') # noqa: E501
1067+
and kwargs.get('projection', '').startswith('proplot_')
10681068
):
10691069
kwargs['_subplotspec'] = args[0] # mpl>=3.4.0 workaround: see Axes.__init__
10701070
return super().add_subplot(*args, **kwargs)

proplot/ui.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,11 @@ def subplots(
416416
for num, name in proj.items():
417417
# The default is CartesianAxes
418418
if name is None or name == 'cartesian':
419-
axes_kw[num]['projection'] = 'cartesian'
419+
axes_kw[num]['projection'] = 'proplot_cartesian'
420420

421421
# Builtin matplotlib polar axes, just use my overridden version
422422
elif name == 'polar':
423-
axes_kw[num]['projection'] = 'polar2'
423+
axes_kw[num]['projection'] = 'proplot_polar'
424424
if num == ref:
425425
aspect = 1
426426

@@ -433,7 +433,7 @@ def subplots(
433433
aspect = (m.urcrnrx - m.llcrnrx) / (m.urcrnry - m.llcrnry)
434434
else:
435435
aspect = (np.diff(m.x_limits) / np.diff(m.y_limits))[0]
436-
axes_kw[num].update({'projection': package, 'map_projection': m})
436+
axes_kw[num].update({'projection': 'proplot_' + package, 'map_projection': m}) # noqa: E501
437437

438438
# Figure and/or axes dimensions
439439
names, values = (), ()

0 commit comments

Comments
 (0)
0