Open astrofrog opened 9 years ago
@astrofrog will that work on rectangle polygons or just things constructed with Polygon
?
Just Polygon
.
@mdboom - ah ok. Is this something that would be worth implementing in e.g. Rectangle too? The use case here is that when plotting a rectangle (e.g. an image footprint) on a projection with distortions, the result should not be a rectangle.
Actually thinking about this, I wonder if the transformation functions themselves can choose to interpolate a path before returning them, or whether the size of the output has to match the size of the input. If the former were possible, then the WCSAxes transforms could take care of interpolating all paths to the required precision.
Actually thinking about this, I wonder if the transformation functions themselves can choose to interpolate a path before returning them, or whether the size of the output has to match the size of the input.
The transformation function is free to return as many vertices as it likes. There are transformations in matplotlib that both remove and add vertices.
In some sense, it is better if the transformation does the interpolation because it can know about the desired precision in the result. Doing it up front, one just has to "guess" at how many interpolation steps will be enough to achieve the desired level of error against the "ideal".
Ok, great! Then in that case, this issue is a feature request to get the transformations to do The Right Thing (tm) :smile:
I'll try and get to it in October unless somebody beats me to it.
So could this be implemented for Rectangle as well? If not I will re-write sunpy/sunpy#1538 to use Polygon
.
@Cadair - yes, possibly, but need to check. This is non-trivial, so not sure if I can get it working on a short timescale.
yeah there is no rush on this, so I can always change sunpy/sunpy#1538 later.
@Cadair - I finally found the following from @mdboom on the astropy mailing list:
Can’t speak specifically for wcsaxes, but for “raw” matplotlib it would do the former. There is, however, a quick-and-dirty way to interpolate your polygon using a private method intended for the built-in geo projections in matplotlib. If poly is your Polygon object and N is the number of line segments to create for each existing line segment:
On-the-fly interpolation for projections has been on the TODO list for matplotlib for many years. It just hasn’t got done (and will probably require a C++ implementation to be performant enough).
So this is how you can make sure your patches have curved edges. Maybe we should have this automatically happen during
add_patch
.