Let's say we have a transform tr that takes 2-dimensional input and returns 2-dimensional input. If I do:
plt.plot(x, y, transform=tr)
x and y will get passed to tr.transform. Now in some cases the transformation may require 3 coordinates and return 2 'final' coordinates to be plotted (e.g. astrofrog/wcsaxes#148).
For example I might have a transformation that takes longitude, latitude, and altitude and translates these into a 2-d position in a satellite image. In this case if I want to plot points I'd like to be able to do:
However this doesn't work (and I tried a few other ways to). Is there a way to get this to work, and if not, could it be considered as a feature request? Just to be clear, the transform would always return two coordinates, but could take any arbitrary number of inputs.
Doing this on plot will be very hard due to the amount of 'friendly' magic already in it's API.
We already support plt.plot(x1, y1, x2, y2, ..) so I am not sure it is possible to unambiguously sort out what to do in the case where the user passes in 6 arrays.
I would suggest writing a function like
defplot_tran3(ax, a, b, c, tr, **kwargs):
x, y=tr(a, b, c)
returnax.plot(x, y, **kwargs)[0]
Is there a way to get this to work, and if not, could it be considered as a feature request?
No. In fact, I don't believe the transform framework itself is particularly well geared for anything other than 2 dimensions (even 1 dimensions are a special case). There is certainly room for unification and generalisation in that regard from the top of my memory.
FWIW even the 3d axes functionality has to override each of the plotting methods to support 3 dimensional input.
I was tinkering with setting up a "projection" class. It is "technically"
possible to do, but actually getting it integrated into matplotlib may
prove tricky (at least, from the mplot3d side of things). Discussions with
Mike did not bring up any obvious blockers to the core idea, it was just
not easy to use such a projection like you could with other transforms.
I would, at the very least, like to get a simple set of 3d projections into
matplotlib core, even if they aren't immediately used by mplot3d. Perhaps
you would be interested in helping with that? I barely have the cycles to
do simple development work at the moment.
Is there a way to get this to work, and if not, could it be considered as
a feature request?
No. In fact, I don't believe the transform framework itself is
particularly well geared for anything other than 2 dimensions (even 1
dimensions are a special case). There is certainly room for unification and
generalisation in that regard from the top of my memory.
FWIW even the 3d axes functionality has to override each of the plotting
methods to support 3 dimensional input.
Sorry I don't have a better answer [image: 😞]
—
Reply to this email directly or view it on GitHub #3983 (comment)
.
I think that for the foreseeable future the OP is stuck with a two-step process: do the transform from 3 to 2 dimensions outside of mpl, and then use the normal plot function.
Activity
tacaswell commented on Jan 8, 2015
Doing this on plot will be very hard due to the amount of 'friendly' magic already in it's API.
We already support plt.plot(x1, y1, x2, y2, ..) so I am not sure it is possible to unambiguously sort out what to do in the case where the user passes in 6 arrays.
I would suggest writing a function like
One of the things on my to-do list that really needs to get done is to get a decorator in main-line to provide pyplot like convince to user functions (see #3587 / http://thread.gmane.org/gmane.comp.python.matplotlib.devel/12999 and #2736 )
pelson commented on Jan 8, 2015
No. In fact, I don't believe the transform framework itself is particularly well geared for anything other than 2 dimensions (even 1 dimensions are a special case). There is certainly room for unification and generalisation in that regard from the top of my memory.
FWIW even the 3d axes functionality has to override each of the plotting methods to support 3 dimensional input.
Sorry I don't have a better answer 😞
WeatherGod commented on Jan 8, 2015
I was tinkering with setting up a "projection" class. It is "technically"
possible to do, but actually getting it integrated into matplotlib may
prove tricky (at least, from the mplot3d side of things). Discussions with
Mike did not bring up any obvious blockers to the core idea, it was just
not easy to use such a projection like you could with other transforms.
I would, at the very least, like to get a simple set of 3d projections into
matplotlib core, even if they aren't immediately used by mplot3d. Perhaps
you would be interested in helping with that? I barely have the cycles to
do simple development work at the moment.
On Thu, Jan 8, 2015 at 5:19 PM, Phil Elson notifications@github.com wrote:
petehuang commented on Jan 8, 2017
What's the latest of the team's opinion on whether or not this would be a priority for MPL?
efiring commented on Jan 8, 2017
I think that for the foreseeable future the OP is stuck with a two-step process: do the transform from 3 to 2 dimensions outside of mpl, and then use the normal plot function.