[Matplotlib-devel] Interpolations in Line2D objects

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Matplotlib-devel] Interpolations in Line2D objects

matplotlib - devel mailing list
Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.

I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.

Ray
_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

Benjamin Root
Matplotlib already has support for bezier curves. Could that work?


On Sat, Mar 9, 2019 at 10:22 AM Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.

I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.

Ray
_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

Jody Klymak
In reply to this post by matplotlib - devel mailing list
Hi Ray,

Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.

As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that.  

Cheers,  Jody


> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>
> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>
> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>
> Ray
> _______________________________________________
> Matplotlib-devel mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

matplotlib - devel mailing list
Matplotlib already has entered this space by providing interpolation options in imshow. There is no difference in the reasons for doing it and the options would be, if anything, less complicated. Personally, I don’t see this as data analysis. It’s more for presentational reasons, which I believe is very much part of Matplotlib and not scipy.

Ray

> On Mar 10, 2019, at 10:14 AM, Jody Klymak <[hidden email]> wrote:
>
> Hi Ray,
>
> Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.
>
> As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that.  
>
> Cheers,  Jody
>
>
>> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>>
>> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>>
>> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>>
>> Ray
>> _______________________________________________
>> Matplotlib-devel mailing list
>> [hidden email]
>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

Jody Klymak
Interpolation in `imshow` is contentious, to say the least, subject to bugs, and disagreements about how out of bounds data should be handled, etc etc.. However, mapping an image of arbitrary resolution to the figure resolution is inherently an interpolation/smoothing operation, so we have to do it to show the image at all.

Conversely, drawing a line between two points is something most renderers do for us.    

Cheers,   Jody

> On Mar 10, 2019, at  8:38 AM, Raymond Osborn <[hidden email]> wrote:
>
> Matplotlib already has entered this space by providing interpolation options in imshow. There is no difference in the reasons for doing it and the options would be, if anything, less complicated. Personally, I don’t see this as data analysis. It’s more for presentational reasons, which I believe is very much part of Matplotlib and not scipy.
>
> Ray
>
>> On Mar 10, 2019, at 10:14 AM, Jody Klymak <[hidden email]> wrote:
>>
>> Hi Ray,
>>
>> Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.
>>
>> As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that.  
>>
>> Cheers,  Jody
>>
>>
>>> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>>>
>>> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>>>
>>> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>>>
>>> Ray
>>> _______________________________________________
>>> Matplotlib-devel mailing list
>>> [hidden email]
>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>
>

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

matplotlib - devel mailing list
Of course, contours involve smooth interpolations as well, so I’m not sure I accept the premise that I am asking Matplotlib to expand its scope unreasonably. I certainly hope that interpolations are not in danger of being removed from imshow.

If this is the consensus of the Matplotlib developers, then I will program it myself in NeXpy (http://nexpy.github.io/nexpy/), where we have added GUI handles to the less common Matplotlib features that we find ourselves using all the time in our research, such as skew axes and symmetric log plots. This is another such feature. It is not hard to implement with scipy.interpolate, but I believe that there are many in your user community who would find this an extremely useful option within Matplotlib, which is why I decided to raise the issue.

With best regards,
Ray

> On Mar 10, 2019, at 11:41 AM, Jody Klymak <[hidden email]> wrote:
>
> Interpolation in `imshow` is contentious, to say the least, subject to bugs, and disagreements about how out of bounds data should be handled, etc etc.. However, mapping an image of arbitrary resolution to the figure resolution is inherently an interpolation/smoothing operation, so we have to do it to show the image at all.
>
> Conversely, drawing a line between two points is something most renderers do for us.    
>
> Cheers,   Jody
>
>> On Mar 10, 2019, at  8:38 AM, Raymond Osborn <[hidden email]> wrote:
>>
>> Matplotlib already has entered this space by providing interpolation options in imshow. There is no difference in the reasons for doing it and the options would be, if anything, less complicated. Personally, I don’t see this as data analysis. It’s more for presentational reasons, which I believe is very much part of Matplotlib and not scipy.
>>
>> Ray
>>
>>> On Mar 10, 2019, at 10:14 AM, Jody Klymak <[hidden email]> wrote:
>>>
>>> Hi Ray,
>>>
>>> Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.
>>>
>>> As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that.  
>>>
>>> Cheers,  Jody
>>>
>>>
>>>> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>>>>
>>>> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>>>>
>>>> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>>>>
>>>> Ray
>>>> _______________________________________________
>>>> Matplotlib-devel mailing list
>>>> [hidden email]
>>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>
>>
>

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

tcaswell
> Interpolation in `imshow` is contentious, 

Interpolation in imshow is _hard_, but I would not say contentious.  There is zero chance of it being removed.  

Further, I think that the Ray is asking about interpolation, not fitting.  I think it is directly analogous in 1D, in both cases we have user input which is not uniform and we implicitly re-sample it to pick what pixels we are going to color.

To that end, we currently do support 'interpolation' in Line2D under the name of 'drawstyle' which switches between linear interpolation and 0-order interpolation.  However there are two problems I see with directly plugging in to that framework for higher-order interpolation 1) the way we call it is not aware of the current view limits and axes size in pixels (which you really want to intelligently pick the number of points to re-sample to)  2) the higher-order interpolators are in scipy (we use the interpolators in Agg for 2D, there may be 1D versions in Agg we can use).  

There is also some concern about how to handle this across all of the backends.  For raster backends it is pretty straight forward (resample to the number of pixels), but for the vector backends it is less so (do we just pick some DPI to resample to?  Does the underlying language natively support it (looks like at least SVG does not)?).

https://github.com/pyviz/datashader/pull/200 is relevant to this discussion for what an intelligently re-sampling artist might look like.

This is a feature that I think we want to get widely available, but I am not sure the best path (new package? optional scipy dependancy?).

For merging the elements in the legend I would look at https://matplotlib.org/tutorials/intermediate/legend_guide.html#legend-handlers .  It means would you have to move away from the auto collection, but it is probably worth it for nexpy.

We support both skew axis and symlog axis in core Matplotlib, what do they not cover than nexpy needs?

Tom

On Sun, Mar 10, 2019 at 2:56 PM Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
Of course, contours involve smooth interpolations as well, so I’m not sure I accept the premise that I am asking Matplotlib to expand its scope unreasonably. I certainly hope that interpolations are not in danger of being removed from imshow.

If this is the consensus of the Matplotlib developers, then I will program it myself in NeXpy (http://nexpy.github.io/nexpy/), where we have added GUI handles to the less common Matplotlib features that we find ourselves using all the time in our research, such as skew axes and symmetric log plots. This is another such feature. It is not hard to implement with scipy.interpolate, but I believe that there are many in your user community who would find this an extremely useful option within Matplotlib, which is why I decided to raise the issue.

With best regards,
Ray

> On Mar 10, 2019, at 11:41 AM, Jody Klymak <[hidden email]> wrote:
>
> Interpolation in `imshow` is contentious, to say the least, subject to bugs, and disagreements about how out of bounds data should be handled, etc etc.. However, mapping an image of arbitrary resolution to the figure resolution is inherently an interpolation/smoothing operation, so we have to do it to show the image at all.
>
> Conversely, drawing a line between two points is something most renderers do for us.   
>
> Cheers,   Jody
>
>> On Mar 10, 2019, at  8:38 AM, Raymond Osborn <[hidden email]> wrote:
>>
>> Matplotlib already has entered this space by providing interpolation options in imshow. There is no difference in the reasons for doing it and the options would be, if anything, less complicated. Personally, I don’t see this as data analysis. It’s more for presentational reasons, which I believe is very much part of Matplotlib and not scipy.
>>
>> Ray
>>
>>> On Mar 10, 2019, at 10:14 AM, Jody Klymak <[hidden email]> wrote:
>>>
>>> Hi Ray,
>>>
>>> Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.
>>>
>>> As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that. 
>>>
>>> Cheers,  Jody
>>>
>>>
>>>> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>>>>
>>>> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>>>>
>>>> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>>>>
>>>> Ray
>>>> _______________________________________________
>>>> Matplotlib-devel mailing list
>>>> [hidden email]
>>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>
>>
>

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

matplotlib - devel mailing list
Tom,
Thanks for your insight. The issue of matching the smoothing to the screen resolution is something that I have little experience of. It was at the back of my mind that Matplotlib developer expertise would probably be needed to do this properly. You have confirmed that it is not a trivial problem.

My comment about skew axes and symbol plots was not very well phrased. They are indeed very well implemented in Matplotlib. What I was trying to say was that one of the goals of NeXpy is to make it easier for our users to access these more advanced features without having to consult the documentation, and that I hope one day to be able to turn on line interpolations just as easily with a checkbox or combo box.

Thanks again,
Ray

On Mar 10, 2019, at 6:29 PM, Thomas Caswell <[hidden email]> wrote:

> Interpolation in `imshow` is contentious, 

Interpolation in imshow is _hard_, but I would not say contentious.  There is zero chance of it being removed.  

Further, I think that the Ray is asking about interpolation, not fitting.  I think it is directly analogous in 1D, in both cases we have user input which is not uniform and we implicitly re-sample it to pick what pixels we are going to color.

To that end, we currently do support 'interpolation' in Line2D under the name of 'drawstyle' which switches between linear interpolation and 0-order interpolation.  However there are two problems I see with directly plugging in to that framework for higher-order interpolation 1) the way we call it is not aware of the current view limits and axes size in pixels (which you really want to intelligently pick the number of points to re-sample to)  2) the higher-order interpolators are in scipy (we use the interpolators in Agg for 2D, there may be 1D versions in Agg we can use).  

There is also some concern about how to handle this across all of the backends.  For raster backends it is pretty straight forward (resample to the number of pixels), but for the vector backends it is less so (do we just pick some DPI to resample to?  Does the underlying language natively support it (looks like at least SVG does not)?).

https://github.com/pyviz/datashader/pull/200 is relevant to this discussion for what an intelligently re-sampling artist might look like.

This is a feature that I think we want to get widely available, but I am not sure the best path (new package? optional scipy dependancy?).

For merging the elements in the legend I would look at https://matplotlib.org/tutorials/intermediate/legend_guide.html#legend-handlers .  It means would you have to move away from the auto collection, but it is probably worth it for nexpy.

We support both skew axis and symlog axis in core Matplotlib, what do they not cover than nexpy needs?

Tom

On Sun, Mar 10, 2019 at 2:56 PM Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
Of course, contours involve smooth interpolations as well, so I’m not sure I accept the premise that I am asking Matplotlib to expand its scope unreasonably. I certainly hope that interpolations are not in danger of being removed from imshow.

If this is the consensus of the Matplotlib developers, then I will program it myself in NeXpy (http://nexpy.github.io/nexpy/), where we have added GUI handles to the less common Matplotlib features that we find ourselves using all the time in our research, such as skew axes and symmetric log plots. This is another such feature. It is not hard to implement with scipy.interpolate, but I believe that there are many in your user community who would find this an extremely useful option within Matplotlib, which is why I decided to raise the issue.

With best regards,
Ray

> On Mar 10, 2019, at 11:41 AM, Jody Klymak <[hidden email]> wrote:
>
> Interpolation in `imshow` is contentious, to say the least, subject to bugs, and disagreements about how out of bounds data should be handled, etc etc.. However, mapping an image of arbitrary resolution to the figure resolution is inherently an interpolation/smoothing operation, so we have to do it to show the image at all.
>
> Conversely, drawing a line between two points is something most renderers do for us.   
>
> Cheers,   Jody
>
>> On Mar 10, 2019, at  8:38 AM, Raymond Osborn <[hidden email]> wrote:
>>
>> Matplotlib already has entered this space by providing interpolation options in imshow. There is no difference in the reasons for doing it and the options would be, if anything, less complicated. Personally, I don’t see this as data analysis. It’s more for presentational reasons, which I believe is very much part of Matplotlib and not scipy.
>>
>> Ray
>>
>>> On Mar 10, 2019, at 10:14 AM, Jody Klymak <[hidden email]> wrote:
>>>
>>> Hi Ray,
>>>
>>> Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.
>>>
>>> As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that. 
>>>
>>> Cheers,  Jody
>>>
>>>
>>>> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>>>>
>>>> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>>>>
>>>> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>>>>
>>>> Ray
>>>> _______________________________________________
>>>> Matplotlib-devel mailing list
>>>> [hidden email]
>>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>
>>
>

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel


--
Thomas Caswell
[hidden email]


_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interpolations in Line2D objects

Antony Lee-3
My position largely echoes Jody's: the complexity of image interpolation (for example regarding the "matching screen resolution" issue raised by Tom) and scope creep both strongly argue against adding this feature to Line2D.
Perhaps more constructively, I believe the desired feature (showing points at data, an interpolant line, and a single unified legend) can also be achieved using the markevery mechanism (https://matplotlib.org/gallery/lines_bars_and_markers/markevery_demo.html) (store the interpolated line in the artist, but set markevery to only display the data points).

Antony

On Mon, Mar 11, 2019 at 1:35 AM Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
Tom,
Thanks for your insight. The issue of matching the smoothing to the screen resolution is something that I have little experience of. It was at the back of my mind that Matplotlib developer expertise would probably be needed to do this properly. You have confirmed that it is not a trivial problem.

My comment about skew axes and symbol plots was not very well phrased. They are indeed very well implemented in Matplotlib. What I was trying to say was that one of the goals of NeXpy is to make it easier for our users to access these more advanced features without having to consult the documentation, and that I hope one day to be able to turn on line interpolations just as easily with a checkbox or combo box.

Thanks again,
Ray

On Mar 10, 2019, at 6:29 PM, Thomas Caswell <[hidden email]> wrote:

> Interpolation in `imshow` is contentious, 

Interpolation in imshow is _hard_, but I would not say contentious.  There is zero chance of it being removed.  

Further, I think that the Ray is asking about interpolation, not fitting.  I think it is directly analogous in 1D, in both cases we have user input which is not uniform and we implicitly re-sample it to pick what pixels we are going to color.

To that end, we currently do support 'interpolation' in Line2D under the name of 'drawstyle' which switches between linear interpolation and 0-order interpolation.  However there are two problems I see with directly plugging in to that framework for higher-order interpolation 1) the way we call it is not aware of the current view limits and axes size in pixels (which you really want to intelligently pick the number of points to re-sample to)  2) the higher-order interpolators are in scipy (we use the interpolators in Agg for 2D, there may be 1D versions in Agg we can use).  

There is also some concern about how to handle this across all of the backends.  For raster backends it is pretty straight forward (resample to the number of pixels), but for the vector backends it is less so (do we just pick some DPI to resample to?  Does the underlying language natively support it (looks like at least SVG does not)?).

https://github.com/pyviz/datashader/pull/200 is relevant to this discussion for what an intelligently re-sampling artist might look like.

This is a feature that I think we want to get widely available, but I am not sure the best path (new package? optional scipy dependancy?).

For merging the elements in the legend I would look at https://matplotlib.org/tutorials/intermediate/legend_guide.html#legend-handlers .  It means would you have to move away from the auto collection, but it is probably worth it for nexpy.

We support both skew axis and symlog axis in core Matplotlib, what do they not cover than nexpy needs?

Tom

On Sun, Mar 10, 2019 at 2:56 PM Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
Of course, contours involve smooth interpolations as well, so I’m not sure I accept the premise that I am asking Matplotlib to expand its scope unreasonably. I certainly hope that interpolations are not in danger of being removed from imshow.

If this is the consensus of the Matplotlib developers, then I will program it myself in NeXpy (http://nexpy.github.io/nexpy/), where we have added GUI handles to the less common Matplotlib features that we find ourselves using all the time in our research, such as skew axes and symmetric log plots. This is another such feature. It is not hard to implement with scipy.interpolate, but I believe that there are many in your user community who would find this an extremely useful option within Matplotlib, which is why I decided to raise the issue.

With best regards,
Ray

> On Mar 10, 2019, at 11:41 AM, Jody Klymak <[hidden email]> wrote:
>
> Interpolation in `imshow` is contentious, to say the least, subject to bugs, and disagreements about how out of bounds data should be handled, etc etc.. However, mapping an image of arbitrary resolution to the figure resolution is inherently an interpolation/smoothing operation, so we have to do it to show the image at all.
>
> Conversely, drawing a line between two points is something most renderers do for us.   
>
> Cheers,   Jody
>
>> On Mar 10, 2019, at  8:38 AM, Raymond Osborn <[hidden email]> wrote:
>>
>> Matplotlib already has entered this space by providing interpolation options in imshow. There is no difference in the reasons for doing it and the options would be, if anything, less complicated. Personally, I don’t see this as data analysis. It’s more for presentational reasons, which I believe is very much part of Matplotlib and not scipy.
>>
>> Ray
>>
>>> On Mar 10, 2019, at 10:14 AM, Jody Klymak <[hidden email]> wrote:
>>>
>>> Hi Ray,
>>>
>>> Thanks a lot for the interest in Matplotlib.  On the other hand, I’d be against this because the API for curve fitting would need to be elaborate, and in my opinion has a better home in scipy or numpy.  We are trying to get away from data processing tasks inside Matplotlib, and leave that to partner libraries, though a few exceptions still exist.
>>>
>>> As for legends, I’d argue pretty strongly that the data and the spline are quite different entities and deserve differentiation in the legend and/or caption of whatever figure you are making.  However if you really want the line and marker in the same legend entry there are numerous hacks to let you do that.  Easiest is probably to draw a marker + line off-canvas somewhere and label that. 
>>>
>>> Cheers,  Jody
>>>
>>>
>>>> On Mar 9, 2019, at  7:22 AM, Raymond Osborn via Matplotlib-devel <[hidden email]> wrote:
>>>>
>>>> Is there any interest in adding an interpolation attribute to axes.Line2D objects similar to those in Axes.imshow? We often use bicubic interpolation using spicy.interpolate to generate smooth lines to connect markers, partly for aesthetic reasons, but partly for (what we maintain are) valid scientific reasons. However, there is no way to display the line along with the associated marker in legends, and it generates additional Line2D objects that are not really separate entities.
>>>>
>>>> I haven’t looked into how this might be done but I thought I would check first to see if this has been considered before and rejected for any reason. It obviously requires storing additional smoothed arrays and smoothing options, and perhaps there are other complications I am not aware of.
>>>>
>>>> Ray
>>>> _______________________________________________
>>>> Matplotlib-devel mailing list
>>>> [hidden email]
>>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>
>>
>

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-devel