Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d1e5ccb

Browse filesBrowse files
committed
Allow arc spines to position themselves.
1 parent 00862cb commit d1e5ccb
Copy full SHA for d1e5ccb

File tree

Expand file treeCollapse file tree

2 files changed

+33
-20
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+33
-20
lines changed

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ def _invalidate_internal(self, *args, **kwargs):
495495
rmin, rmax = self.viewLim.intervaly
496496

497497
rorigin = self.get_rorigin()
498-
outer = self.spines.get('polar', None)
499498
inner = self.spines.get('inner', None)
500499

501500
if rorigin < rmin:
@@ -508,10 +507,6 @@ def _invalidate_internal(self, *args, **kwargs):
508507
inner_width = 0.5 - width
509508
if inner:
510509
inner.set_visible(inner_width != 0.0)
511-
inner.set_patch_arc((0.5, 0.5), inner_width,
512-
thetamin, thetamax)
513-
if outer:
514-
outer.set_patch_arc((0.5, 0.5), 0.5, thetamin, thetamax)
515510

516511
self.patch.set_theta1(thetamin)
517512
self.patch.set_theta2(thetamax)
@@ -534,12 +529,12 @@ def _gen_axes_patch(self):
534529
return Wedge((0.5, 0.5), 0.5, 0.0, 360.0)
535530

536531
def _gen_axes_spines(self):
537-
return {'polar': mspines.Spine.arc_spine(self, 'arc',
532+
return {'polar': mspines.Spine.arc_spine(self, 'top',
538533
(0.5, 0.5), 0.5, 0.0, 360.0),
539534
'start': mspines.Spine.linear_spine(self, 'left'),
540535
'end': mspines.Spine.linear_spine(self, 'right'),
541-
'inner': mspines.Spine.arc_spine(self, 'arc',
542-
(0.5, 0.5), 0.5, 0.0, 360.0)}
536+
'inner': mspines.Spine.arc_spine(self, 'bottom',
537+
(0.5, 0.5), 0.0, 0.0, 360.0)}
543538

544539
def set_thetamax(self, thetamax):
545540
self.viewLim.x1 = np.deg2rad(thetamax)

‎lib/matplotlib/spines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/spines.py
+30-12Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def is_frame_like(self):
206206
def _adjust_location(self):
207207
"""automatically set spine bounds to the view interval"""
208208

209-
if self.spine_type in ('arc', 'circle'):
209+
if self.spine_type == 'circle':
210210
return
211211

212212
if self._bounds is None:
@@ -276,17 +276,35 @@ def _adjust_location(self):
276276
else:
277277
low, high = self._bounds
278278

279-
v1 = self._path.vertices
280-
assert v1.shape == (2, 2), 'unexpected vertices shape'
281-
if self.spine_type in ['left', 'right']:
282-
v1[0, 1] = low
283-
v1[1, 1] = high
284-
elif self.spine_type in ['bottom', 'top']:
285-
v1[0, 0] = low
286-
v1[1, 0] = high
279+
if self._patch_type == 'arc':
280+
if self.spine_type in ('bottom', 'top'):
281+
self._path = mpath.Path.arc(np.rad2deg(low), np.rad2deg(high))
282+
283+
if self.spine_type == 'bottom':
284+
rmin, rmax = self.axes.viewLim.intervaly
285+
try:
286+
rorigin = self.axes.get_rorigin()
287+
except AttributeError:
288+
rorigin = rmin
289+
scaled_diameter = (rmin - rorigin) / (rmax - rorigin)
290+
self._height = scaled_diameter
291+
self._width = scaled_diameter
292+
293+
else:
294+
raise ValueError('unable to set bounds for spine "%s"' %
295+
self.spine_type)
287296
else:
288-
raise ValueError('unable to set bounds for spine "%s"' %
289-
self.spine_type)
297+
v1 = self._path.vertices
298+
assert v1.shape == (2, 2), 'unexpected vertices shape'
299+
if self.spine_type in ['left', 'right']:
300+
v1[0, 1] = low
301+
v1[1, 1] = high
302+
elif self.spine_type in ['bottom', 'top']:
303+
v1[0, 0] = low
304+
v1[1, 0] = high
305+
else:
306+
raise ValueError('unable to set bounds for spine "%s"' %
307+
self.spine_type)
290308

291309
@allow_rasterization
292310
def draw(self, renderer):
@@ -453,7 +471,7 @@ def get_spine_transform(self):
453471

454472
def set_bounds(self, low, high):
455473
"""Set the bounds of the spine."""
456-
if self.spine_type in ('arc', 'circle'):
474+
if self.spine_type == 'circle':
457475
raise ValueError(
458476
'set_bounds() method incompatible with circular spines')
459477
self._bounds = (low, high)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.