path simplification can decrease the smoothness of data plots a

a writes:

Michael Droettboom <mdroe@...552...> writes:
>
> Thanks for the pointers.
>
> The original simplification code was written by John Hunter (I believe),
> and I don't know if it was designed by him also or is a replication of
> something published elsewhere. So I take no credit for and have little
> knowledge of its original goals.

I'm not sure on everything it does, but it seems to do clipping and removes
line segments where the change in slope is less than some limit. There are
probably better algorithms out there, but this one works surprisingly well
and is fast and simple. I think it should be a requirement that it returns
points which are a subset of the original points- with the change you've
made it does this, right?

Oh Hey! I'm the one who originally wrote the path simplification code. I'd
have thought it would be gone by now, but I am very happy it turned out to
be useful. I made it up in order to plot a very large set of noisy data I
had.

The goal was to simplify two types of plots at once: Smooth curves, as
well as very noisy data where many lines are 'on top' of each other. (eg
plot(rand(100000)) ). I noticed both could be taken care of by checking
for changes in slope.

An important goal (for me) was making sure that the min/max span of the
points plotted was preserved. (so that eg plot(rand(1000)) spans from the
lowest to highest point in the data (ie ~ 0 to 1) for any zoom factor).
I'm not sure if this property survived...: If you do plot(rand(1000)) with
the latest matplotlib and gradually zoom out on the x axis, you can see
the top/bottom tips of the plotted line flickering in height, which is
what I was trying to avoid. I forget whether I actually got it as I wanted
it though, maybe I gave up.

Allan

Thanks for the note on this. It's nice to know who wrote the original version. I'll add a note about this in the code comments.

I'm not seeing a noticable change in this regard between 0.98.5 (which uses a pretty direct refactoring of your code) to the SVN trunk. The trunk does two things rather differently 1) it only ever returns points that exist in the original data, and 2) it clips line segments at the boundary of the plot. The latter is to get around a shortcoming of Agg (and Abode Reader, for that matter) when plotting lines to very high-valued coordinates.

But, I'd appreciate you having a comparison look yourself, in case you're seeing some detail that I'm missing.

Cheers,
Mike

Allan Haldane wrote:

···

a writes:
  

Michael Droettboom <mdroe@...552...> writes:
    

Thanks for the pointers.

The original simplification code was written by John Hunter (I believe),
and I don't know if it was designed by him also or is a replication of
something published elsewhere. So I take no credit for and have little
knowledge of its original goals.
      

I'm not sure on everything it does, but it seems to do clipping and removes
line segments where the change in slope is less than some limit. There are
probably better algorithms out there, but this one works surprisingly well
and is fast and simple. I think it should be a requirement that it returns
points which are a subset of the original points- with the change you've
made it does this, right?
    
Oh Hey! I'm the one who originally wrote the path simplification code. I'd
have thought it would be gone by now, but I am very happy it turned out to
be useful. I made it up in order to plot a very large set of noisy data I
had.

The goal was to simplify two types of plots at once: Smooth curves, as
well as very noisy data where many lines are 'on top' of each other. (eg
plot(rand(100000)) ). I noticed both could be taken care of by checking
for changes in slope.

An important goal (for me) was making sure that the min/max span of the
points plotted was preserved. (so that eg plot(rand(1000)) spans from the
lowest to highest point in the data (ie ~ 0 to 1) for any zoom factor).
I'm not sure if this property survived...: If you do plot(rand(1000)) with
the latest matplotlib and gradually zoom out on the x axis, you can see
the top/bottom tips of the plotted line flickering in height, which is
what I was trying to avoid. I forget whether I actually got it as I wanted
it though, maybe I gave up.

Allan

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA