[Matplotlib-devel] Interpolations in Line2D objects

Thomas Caswell tcaswell at gmail.com
Sun Mar 10 19:29:45 EDT 2019

> 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
.  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?


On Sun, Mar 10, 2019 at 2:56 PM Raymond Osborn via Matplotlib-devel <
matplotlib-devel at python.org> 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 <jklymak at uvic.ca> 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 <rayosborn at mac.com> 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 <jklymak at uvic.ca> 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 <
> matplotlib-devel at python.org> 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
> >>>> Matplotlib-devel at python.org
> >>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
> >>>
> >>
> >
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel

Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20190310/efc6e6b3/attachment-0001.html>

More information about the Matplotlib-devel mailing list