matplotlib dropping points in complex plot?

Hello matplotlib users,

I'm using matplotlib to plot some large data sets (1 million x,y
pairs) and I've noticed that, when zoomed out to view the whole plot,
it looks as if only every Nth point is being plotted, maybe in an
attempt to improve plotting performance in complex plots. When I zoom
in I can see points that were clearly missing in the zoomed-out view.
Is there any way to override this so that the plot really does show
all the points, regardless of zoom? I've included my really simple
plotting code below, and I'm using the "scipy superpack" (python 2.5,
matplotlib-0.98.6) on an OS X 10.5.7 Mac.

Many thanks for any help!

   --Will

import pylab
import smr
import sys
for freqs, stats, chronos in smr.loadData(sys.argv[1:]): # loads data
into numpy.arrays
  pylab.plot(chronos, freqs)
  pylab.show()

You can set the rcParam "path.simplify" to False to turn off this behavior.

However, the goal is that the simplification is not noticable -- if it is that may be a bug. Are you able to share your data so I can look into this further?

Cheers,
Mike

Will Grover wrote:

···

Hello matplotlib users,

I'm using matplotlib to plot some large data sets (1 million x,y
pairs) and I've noticed that, when zoomed out to view the whole plot,
it looks as if only every Nth point is being plotted, maybe in an
attempt to improve plotting performance in complex plots. When I zoom
in I can see points that were clearly missing in the zoomed-out view.
Is there any way to override this so that the plot really does show
all the points, regardless of zoom? I've included my really simple
plotting code below, and I'm using the "scipy superpack" (python 2.5,
matplotlib-0.98.6) on an OS X 10.5.7 Mac.

Many thanks for any help!

   --Will

import pylab
import smr
import sys
for freqs, stats, chronos in smr.loadData(sys.argv[1:]): # loads data
into numpy.arrays
  pylab.plot(chronos, freqs)
  pylab.show()

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael Droettboom wrote:

You can set the rcParam "path.simplify" to False to turn off this behavior.

Mike,

The matplotlibrc.template indicates that this is effective only for vector backends; is the template comment incorrect?

Eric

#path.simplify : False # When True, simplify paths in vector backends, such as
                         # PDF, PS and SVG
#path.simplify_threshold : 0.1 # The threshold of similarity below which
                                 # vertices will be removed in the simplification
                                 # process

Good find. The comment is out of date. It is now followed in all backends. I will update the template.

Mike

Eric Firing wrote:

···

Michael Droettboom wrote:

You can set the rcParam "path.simplify" to False to turn off this behavior.

Mike,

The matplotlibrc.template indicates that this is effective only for vector backends; is the template comment incorrect?

Eric

#path.simplify : False # When True, simplify paths in vector backends, such as
                        # PDF, PS and SVG
#path.simplify_threshold : 0.1 # The threshold of similarity below which
                                # vertices will be removed in the simplification
                                # process

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Hello Mike,

Thanks for the quick reply - I'll try "path.simplify" as you suggest.
My actual data is pretty big and unruly, but I wrote a bit of code
that demonstrates the point dropping. This code plots three
single-point-wide peaks on a baseline of noise that is 'length' points
long. For smaller values of 'length' all three points are visible,
but for larger values some or all of the points disappear. Maybe it's
unrealistic to think that all single-point outliers should always be
visible at any scale, but in this case these three points are
significantly different from all the baseline points and dropping them
obviously makes for a much different looking plot. My actual data
doesn't have single-point peaks like this, but it does have
~50-point-wide peaks in a ~1,000,000 point plot, and many of those
peaks are routinely shortened or eliminated in the zoomed-out plot of
my data, only to reappear when adequately zoomed-in.

Tell me if there's any thing else I can provide you with, or if this
is just the way things are when plotting big data sets. Thanks again,

  -- Will

···

###########
import numpy
import pylab
# When length = 2000, this usually plots all 3 peaks
# When length = 5000, this plots 3, 2, 1, or 0 peaks
length = 2000
x = numpy.arange(length)
y = numpy.random.normal(loc=0.0, scale=1.0, size=length)
y[int(length*0.4)] = 100.0
y[int(length*0.5)] = 100.0
y[int(length*0.6)] = 100.0
pylab.plot(x,y)
pylab.show()
###########

On Wed, May 27, 2009 at 6:32 AM, Michael Droettboom <mdroe@...86...> wrote:

You can set the rcParam "path.simplify" to False to turn off this behavior.

However, the goal is that the simplification is not noticable -- if it is
that may be a bug. Are you able to share your data so I can look into this
further?

Cheers,
Mike

Will Grover wrote:

Hello matplotlib users,

I'm using matplotlib to plot some large data sets (1 million x,y
pairs) and I've noticed that, when zoomed out to view the whole plot,
it looks as if only every Nth point is being plotted, maybe in an
attempt to improve plotting performance in complex plots. When I zoom
in I can see points that were clearly missing in the zoomed-out view.
Is there any way to override this so that the plot really does show
all the points, regardless of zoom? I've included my really simple
plotting code below, and I'm using the "scipy superpack" (python 2.5,
matplotlib-0.98.6) on an OS X 10.5.7 Mac.

Many thanks for any help!

--Will

import pylab
import smr
import sys
for freqs, stats, chronos in smr.loadData(sys.argv[1:]): # loads data
into numpy.arrays
pylab.plot(chronos, freqs)
pylab.show()

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a
gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA