|
2 | 2 | # |
3 | 3 | from __future__ import print_function |
4 | 4 |
|
5 | | -import matplotlib.transforms |
6 | 5 | from matplotlib.dates import num2date |
7 | | -import numpy |
8 | 6 | import datetime |
9 | 7 | import six |
10 | 8 |
|
11 | 9 | from . import color as mycol |
12 | 10 | from . import path as mypath |
13 | 11 | from . import files |
14 | 12 |
|
15 | | -from .util import get_legend_text, has_legend |
| 13 | +from .util import get_legend_text, has_legend, transform_to_data_coordinates |
16 | 14 |
|
17 | 15 |
|
18 | 16 | def draw_line2d(data, obj): |
@@ -182,24 +180,6 @@ def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color): |
182 | 180 | return data, None, None |
183 | 181 |
|
184 | 182 |
|
185 | | -def _transform_to_data_coordinates(obj, xdata, ydata): |
186 | | - """The coordinates might not be in data coordinates, but could be sometimes in axes |
187 | | - coordinates. For example, the matplotlib command |
188 | | - axes.axvline(2) |
189 | | - will have the y coordinates set to 0 and 1, not to the limits. Therefore, a |
190 | | - two-stage transform has to be applied: |
191 | | - 1. first transforming to display coordinates, then |
192 | | - 2. from display to data. |
193 | | - """ |
194 | | - if obj.get_transform() != obj.axes.transData: |
195 | | - points = numpy.array([xdata, ydata]).T |
196 | | - transform = matplotlib.transforms.composite_transform_factory( |
197 | | - obj.get_transform(), obj.axes.transData.inverted() |
198 | | - ) |
199 | | - return transform.transform(points).T |
200 | | - return xdata, ydata |
201 | | - |
202 | | - |
203 | 183 | def _marker( |
204 | 184 | obj, |
205 | 185 | data, |
@@ -262,12 +242,9 @@ def _marker( |
262 | 242 |
|
263 | 243 |
|
264 | 244 | def _table(obj, data): |
265 | | - # TODO nschloe, Oct 2, 2015: |
266 | | - # The transform call yields warnings and it is unclear why. Perhaps the input data |
267 | | - # is not suitable? Anyhow, this should not happen. Comment out for now. |
268 | 245 | xdata, ydata = obj.get_data() |
269 | 246 | if not isinstance(xdata[0], datetime.datetime): |
270 | | - xdata, ydata = _transform_to_data_coordinates(obj, xdata, ydata) |
| 247 | + xdata, ydata = transform_to_data_coordinates(obj, xdata, ydata) |
271 | 248 |
|
272 | 249 | # matplotlib allows plotting of data containing `astropy.units`, but they will break |
273 | 250 | # the formatted string here. Try to strip the units from the data. |
|
0 commit comments