8000 Fix #1973: offset_position == 'data' is not respected by point_in_pat… · matplotlib/matplotlib@c04d6e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c04d6e5

Browse files
committed
Fix #1973: offset_position == 'data' is not respected by point_in_path_collection
1 parent 98e37e8 commit c04d6e5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/matplotlib/collections.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ def contains(self, mouseevent):
302302
ind = mpath.point_in_path_collection(
303303
mouseevent.x, mouseevent.y, pickradius,
304304
transform.frozen(), paths, self.get_transforms(),
305-
offsets, transOffset, pickradius <= 0)
305+
offsets, transOffset, pickradius <= 0,
306+
self.get_offset_position())
306307

307308
return len(ind)>0, dict(ind=ind)
308309

src/_path.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ _path_module::get_path_collection_extents(const Py::Tuple& args)
699699
Py::Object
700700
_path_module::point_in_path_collection(const Py::Tuple& args)
701701
{
702-
args.verify_length(9);
702+
args.verify_length(10);
703703

704704
//segments, trans, clipbox, colors, linewidths, antialiaseds
705705
double x = Py::Float(args[0]);
@@ -711,6 +711,9 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
711711
Py::SeqBase<Py::Object> offsets_obj = args[6];
712712
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7].ptr());
713713
bool filled = Py::Boolean(args[8]);
714+
std::string offset_position = Py::String(args[9]);
715+
716+
bool data_offsets = (offset_position == "data");
714717

715718
PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject(
716719
offsets_obj.ptr(), PyArray_DOUBLE, 0, 2);
@@ -761,7 +764,11 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
761764
double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0);
762765
double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1);
763766
offset_trans.transform(&xo, &yo);
764-
trans *= agg::trans_affine_translation(xo, yo);
767+
if (data_offsets) {
768+
trans = agg::trans_affine_translation(xo, yo) * trans;
769+
} else {
770+
trans *= agg::trans_affine_translation(xo, yo);
771+
}
765772
}
766773

767774
if (filled)

0 commit comments

Comments
 (0)
0