Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f883f79

Browse files
committed
Can't drag zoom on a polar plot.
Finessing Agg drawing quality a little bit. svn path=/branches/transforms/; revision=4019
1 parent 6c20787 commit f883f79

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,12 @@ def format_coord(self, x, y):
18201820

18211821
#### Interactive manipulation
18221822

1823+
def can_zoom(self):
1824+
"""
1825+
Return True if this axes support the zoom box
1826+
"""
1827+
return True
1828+
18231829
def get_navigate(self):
18241830
"""
18251831
Get whether the axes responds to navigation commands

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,8 @@ def press_zoom(self, event):
13611361

13621362
self._xypress=[]
13631363
for i, a in enumerate(self.canvas.figure.get_axes()):
1364-
if x is not None and y is not None and a.in_axes(event) and a.get_navigate():
1364+
if x is not None and y is not None and a.in_axes(event) \
1365+
and a.get_navigate() and a.can_zoom():
13651366
self._xypress.append(( x, y, a, i, a.viewLim.frozen(), a.transData.frozen()))
13661367

13671368
self.press(event)

lib/matplotlib/projections/polar.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ def transform(self, tr):
5555
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
5656

5757
def transform_path(self, path):
58-
path = path.interpolated(self._resolution)
59-
return Path(self.transform(path.vertices), path.codes)
58+
vertices = path.vertices
59+
if len(vertices) == 2 and vertices[0, 0] == vertices[1, 0]:
60+
return Path(self.transform(vertices), path.codes)
61+
ipath = path.interpolated(self._resolution)
62+
return Path(self.transform(ipath.vertices), ipath.codes)
6063
transform_path.__doc__ = Transform.transform_path.__doc__
6164

6265
transform_path_non_affine = transform_path
@@ -151,7 +154,7 @@ def zoom(self, direction):
151154
def refresh(self):
152155
return self.base.refresh()
153156

154-
RESOLUTION = 50
157+
RESOLUTION = 75
155158

156159
def __init__(self, *args, **kwargs):
157160
"""
@@ -377,6 +380,12 @@ def get_data_ratio(self):
377380
return 1.0
378381

379382
### Interactive panning
383+
384+
def can_zoom(self):
385+
"""
386+
Return True if this axes support the zoom box
387+
"""
388+
return False
380389

381390
def start_pan(self, x, y, button):
382391
angle = self._r_label1_position.to_values()[4] / 180.0 * npy.pi

src/_backend_agg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ template<class VertexSource> class conv_quantize
9595
unsigned vertex(double* x, double* y) {
9696
unsigned cmd = m_source->vertex(x, y);
9797
if (m_quantize && agg::is_vertex(cmd)) {
98-
*x = int(*x) + 0.5;
99-
*y = int(*y) + 0.5;
98+
*x = round(*x) + 0.5;
99+
*y = round(*y) + 0.5;
100100
}
101101
return cmd;
102102
}
@@ -389,7 +389,7 @@ bool should_snap(Path& path, const agg::trans_affine& trans) {
389389
}
390390

391391
trans.transform(&x1, &y1);
392-
if (!(fabs(x0 - x1) < 0.001 || fabs(y0 - y1) < 0.001)) {
392+
if (!(fabs(x0 - x1) < 1e-4 || fabs(y0 - y1) < 1e-4)) {
393393
path.rewind(0);
394394
return false;
395395
}

0 commit comments

Comments
 (0)