Skip to content

Commit 6f4eb6d

Browse files
authored
Merge pull request matplotlib#20245 from greglucas/collection-deps
MAINT: Removing deprecated `offset_position` from Collection
2 parents 818133a + 3b6cc7f commit 6f4eb6d

File tree

11 files changed

+20
-120
lines changed

11 files changed

+20
-120
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Collection's offset_position has been removed
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The deprecated keyword argument *offset_position* has been removed from
5+
the Collection class, along with the setter and getter
6+
``Collection.set_offset_position()`` and ``Collection.get_offset_position()``.
7+
The ``offset_position`` of the Collection class is now "screen".

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
228228
*offsets* are first transformed by *offsetTrans* before being
229229
applied.
230230
231-
*offset_position* may be either "screen" or "data" depending on the
232-
space that the offsets are in; "data" is deprecated.
231+
*offset_position* is unused now, but the argument is kept for
232+
backwards compatibility.
233233
234234
This provides a fallback implementation of
235235
:meth:`draw_path_collection` that makes multiple calls to
@@ -401,11 +401,6 @@ def _iter_collection(self, gc, master_transform, all_transforms,
401401
Naa = len(antialiaseds)
402402
Nurls = len(urls)
403403

404-
if offset_position == "data":
405-
_api.warn_deprecated(
406-
"3.3", message="Support for offset_position='data' is "
407-
"deprecated since %(since)s and will be removed %(removal)s.")
408-
409404
if (Nfacecolors == 0 and Nedgecolors == 0) or Npaths == 0:
410405
return
411406
if Noffsets:
@@ -425,17 +420,6 @@ def _iter_collection(self, gc, master_transform, all_transforms,
425420
path_id = path_ids[i % Npaths]
426421
if Noffsets:
427422
xo, yo = toffsets[i % Noffsets]
428-
if offset_position == 'data':
429-
if Ntransforms:
430-
transform = (
431-
Affine2D(all_transforms[i % Ntransforms]) +
432-
master_transform)
433-
else:
434-
transform = master_transform
435-
(xo, yo), (xp, yp) = transform.transform(
436-
[(xo, yo), (0, 0)])
437-
xo = -(xp - xo)
438-
yo = -(yp - yo)
439423
if not (np.isfinite(xo) and np.isfinite(yo)):
440424
continue
441425
if Nfacecolors:

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ def _update_methods(self):
109109
self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles
110110
self.draw_image = self._renderer.draw_image
111111
self.draw_markers = self._renderer.draw_markers
112-
# This is its own method for the duration of the deprecation of
113-
# offset_position = "data".
114-
# self.draw_path_collection = self._renderer.draw_path_collection
112+
self.draw_path_collection = self._renderer.draw_path_collection
115113
self.draw_quad_mesh = self._renderer.draw_quad_mesh
116114
self.copy_from_bbox = self._renderer.copy_from_bbox
117115

@@ -163,19 +161,6 @@ def draw_path(self, gc, path, transform, rgbFace=None):
163161
raise OverflowError("Exceeded cell block limit (set "
164162
"'agg.path.chunksize' rcparam)") from err
165163

166-
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
167-
offsets, offsetTrans, facecolors, edgecolors,
168-
linewidths, linestyles, antialiaseds, urls,
169-
offset_position):
170-
if offset_position == "data":
171-
_api.warn_deprecated(
172-
"3.3", message="Support for offset_position='data' is "
173-
"deprecated since %(since)s and will be removed %(removal)s.")
174-
return self._renderer.draw_path_collection(
175-
gc, master_transform, paths, all_transforms, offsets, offsetTrans,
176-
facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls,
177-
offset_position)
178-
179164
def draw_mathtext(self, gc, x, y, s, prop, angle):
180165
"""Draw mathtext using :mod:`matplotlib.mathtext`."""
181166
ox, oy, width, height, descent, font_image, used_characters = \

lib/matplotlib/collections.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class Collection(artist.Artist, cm.ScalarMappable):
7373
# subclass-by-subclass basis.
7474
_edge_default = False
7575

76-
@_api.delete_parameter("3.3", "offset_position")
7776
@docstring.interpd
7877
def __init__(self,
7978
edgecolors=None,
@@ -90,7 +89,7 @@ def __init__(self,
9089
pickradius=5.0,
9190
hatch=None,
9291
urls=None,
93-
offset_position='screen',
92+
*,
9493
zorder=1,
9594
**kwargs
9695
):
@@ -130,9 +129,6 @@ def __init__(self,
130129
transOffset : `~.transforms.Transform`, default: `.IdentityTransform`
131130
A single transform which will be applied to each *offsets* vector
132131
before it is used.
133-
offset_position : {{'screen' (default), 'data' (deprecated)}}
134-
If set to 'data' (deprecated), *offsets* will be treated as if it
135-
is in data coordinates instead of in screen coordinates.
136132
norm : `~.colors.Normalize`, optional
137133
Forwarded to `.ScalarMappable`. The default of
138134
``None`` means that the first draw call will set ``vmin`` and
@@ -184,8 +180,6 @@ def __init__(self,
184180
self.set_urls(urls)
185181
self.set_hatch(hatch)
186182
self._offset_position = "screen"
187-
if offset_position != "screen":
188-
self.set_offset_position(offset_position) # emit deprecation.
189183
self.set_zorder(zorder)
190184

191185
if capstyle:
@@ -561,35 +555,6 @@ def get_offsets(self):
561555
else:
562556
return self._uniform_offsets
563557

564-
@_api.deprecated("3.3")
565-
def set_offset_position(self, offset_position):
566-
"""
567-
Set how offsets are applied. If *offset_position* is 'screen'
568-
(default) the offset is applied after the master transform has
569-
been applied, that is, the offsets are in screen coordinates.
570-
If offset_position is 'data', the offset is applied before the
571-
master transform, i.e., the offsets are in data coordinates.
572-
573-
Parameters
574-
----------
575-
offset_position : {'screen', 'data'}
576-
"""
577-
_api.check_in_list(['screen', 'data'], offset_position=offset_position)
578-
self._offset_position = offset_position
579-
self.stale = True
580-
581-
@_api.deprecated("3.3")
582-
def get_offset_position(self):
583-
"""
584-
Return how offsets are applied for the collection. If
585-
*offset_position* is 'screen', the offset is applied after the
586-
master transform has been applied, that is, the offsets are in
587-
screen coordinates. If offset_position is 'data', the offset
588-
is applied before the master transform, i.e., the offsets are
589-
in data coordinates.
590-
"""
591-
return self._offset_position
592-
593558
def _get_default_linewidth(self):
594559
# This may be overridden in a subclass.
595560
return mpl.rcParams['patch.linewidth'] # validated as float

src/_backend_agg.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ class RendererAgg
176176
ColorArray &edgecolors,
177177
LineWidthArray &linewidths,
178178
DashesVector &linestyles,
179-
AntialiasedArray &antialiaseds,
180-
e_offset_position offset_position);
179+
AntialiasedArray &antialiaseds);
181180

182181
template <class CoordinateArray, class OffsetArray, class ColorArray>
183182
void draw_quad_mesh(GCAgg &gc,
@@ -277,7 +276,6 @@ class RendererAgg
277276
LineWidthArray &linewidths,
278277
DashesVector &linestyles,
279278
AntialiasedArray &antialiaseds,
280-
e_offset_position offset_position,
281279
bool check_snap,
282280
bool has_curves);
283281

@@ -911,7 +909,6 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
911909
LineWidthArray &linewidths,
912910
DashesVector &linestyles,
913911
AntialiasedArray &antialiaseds,
914-
e_offset_position offset_position,
915912
bool check_snap,
916913
bool has_curves)
917914
{
@@ -969,11 +966,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
969966
double xo = offsets(i % Noffsets, 0);
970967
double yo = offsets(i % Noffsets, 1);
971968
offset_trans.transform(&xo, &yo);
972-
if (offset_position == OFFSET_POSITION_DATA) {
973-
trans = agg::trans_affine_translation(xo, yo) * trans;
974-
} else {
975-
trans *= agg::trans_affine_translation(xo, yo);
976-
}
969+
trans *= agg::trans_affine_translation(xo, yo);
977970
}
978971

979972
// These transformations must be done post-offsets
@@ -1047,8 +1040,7 @@ inline void RendererAgg::draw_path_collection(GCAgg &gc,
10471040
ColorArray &edgecolors,
10481041
LineWidthArray &linewidths,
10491042
DashesVector &linestyles,
1050-
AntialiasedArray &antialiaseds,
1051-
e_offset_position offset_position)
1043+
AntialiasedArray &antialiaseds)
10521044
{
10531045
_draw_path_collection_generic(gc,
10541046
master_transform,
@@ -1064,7 +1056,6 @@ inline void RendererAgg::draw_path_collection(GCAgg &gc,
10641056
linewidths,
10651057
linestyles,
10661058
antialiaseds,
1067-
offset_position,
10681059
true,
10691060
true);
10701061
}
@@ -1175,7 +1166,6 @@ inline void RendererAgg::draw_quad_mesh(GCAgg &gc,
11751166
linewidths,
11761167
linestyles,
11771168
antialiaseds,
1178-
OFFSET_POSITION_FIGURE,
11791169
true, // check_snap
11801170
false);
11811171
}

src/_backend_agg_basic_types.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ class Dashes
6969

7070
typedef std::vector<Dashes> DashesVector;
7171

72-
enum e_offset_position {
73-
OFFSET_POSITION_FIGURE,
74-
OFFSET_POSITION_DATA
75-
};
76-
7772
class GCAgg
7873
{
7974
public:

src/_backend_agg_wrapper.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
330330
DashesVector dashes;
331331
numpy::array_view<const uint8_t, 1> antialiaseds;
332332
PyObject *ignored;
333-
e_offset_position offset_position;
333+
PyObject *offset_position; // offset position is no longer used
334334

335335
if (!PyArg_ParseTuple(args,
336-
"O&O&OO&O&O&O&O&O&O&O&OO&:draw_path_collection",
336+
"O&O&OO&O&O&O&O&O&O&O&OO:draw_path_collection",
337337
&convert_gcagg,
338338
&gc,
339339
&convert_trans_affine,
@@ -356,7 +356,6 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
356356
&antialiaseds.converter,
357357
&antialiaseds,
358358
&ignored,
359-
&convert_offset_position,
360359
&offset_position)) {
361360
return NULL;
362361
}
@@ -376,8 +375,7 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
376375
edgecolors,
377376
linewidths,
378377
dashes,
379-
antialiaseds,
380-
offset_position)));
378+
antialiaseds)));
381379
}
382380
catch (const py::exception &)
383381
{

src/_path.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ void point_in_path_collection(double x,
442442
OffsetArray &offsets,
443443
agg::trans_affine &offset_trans,
444444
bool filled,
445-
e_offset_position offset_position,
446445
std::vector<int> &result)
447446
{
448447
size_t Npaths = paths.size();
@@ -478,11 +477,7 @@ void point_in_path_collection(double x,
478477
double xo = offsets(i % Noffsets, 0);
479478
double yo = offsets(i % Noffsets, 1);
480479
offset_trans.transform(&xo, &yo);
481-
if (offset_position == OFFSET_POSITION_DATA) {
482-
trans = agg::trans_affine_translation(xo, yo) * trans;
483-
} else {
484-
trans *= agg::trans_affine_translation(xo, yo);
485-
}
480+
trans *= agg::trans_affine_translation(xo, yo);
486481
}
487482

488483
if (filled) {

src/_path_wrapper.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
332332
numpy::array_view<const double, 2> offsets;
333333
agg::trans_affine offset_trans;
334334
bool filled;
335-
e_offset_position offset_position;
335+
PyObject *offset_position; // no longer used
336336
std::vector<int> result;
337337

338338
if (!PyArg_ParseTuple(args,
339-
"dddO&OO&O&O&O&O&:point_in_path_collection",
339+
"dddO&OO&O&O&O&O:point_in_path_collection",
340340
&x,
341341
&y,
342342
&radius,
@@ -351,7 +351,6 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
351351
&offset_trans,
352352
&convert_bool,
353353
&filled,
354-
&convert_offset_position,
355354
&offset_position)) {
356355
return NULL;
357356
}
@@ -370,7 +369,6 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
370369
offsets,
371370
offset_trans,
372371
filled,
373-
offset_position,
374372
result)));
375373
}
376374
catch (const py::exception &)

src/py_converters.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,22 +492,6 @@ int convert_gcagg(PyObject *pygc, void *gcp)
492492
return 1;
493493
}
494494

495-
int convert_offset_position(PyObject *obj, void *offsetp)
496-
{
497-
e_offset_position *offset = (e_offset_position *)offsetp;
498-
const char *names[] = {"data", NULL};
499-
int values[] = {OFFSET_POSITION_DATA};
500-
int result = (int)OFFSET_POSITION_FIGURE;
501-
502-
if (!convert_string_enum(obj, "offset_position", names, values, &result)) {
503-
PyErr_Clear();
504-
}
505-
506-
*offset = (e_offset_position)result;
507-
508-
return 1;
509-
}
510-
511495
int convert_face(PyObject *color, GCAgg &gc, agg::rgba *rgba)
512496
{
513497
if (!convert_rgba(color, rgba)) {

0 commit comments

Comments
 (0)