Incomplete rendering of line plot

I've run into a case where the rendering in a line plot is incomplete
and some lines are not drawn at all. I submitted a question to
matplotlib-users with the same subject. Eric Firing responded that
this is a manifestation of the "infamous path simplification" bug,
which should be fixed in svn. However, the script below shows the
same problem for me using the current svn on CentOS-5 with python 2.6.
For my purposes setting path.simplify to False is fine but Eric
requested that I provide an example, so here it is:

import numpy
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

y = numpy.array([
4., 2., 2., 3., 3., 2., 2., 6., 6., 5., 5., 4., 4.,
7., 7., 2., 2., 4., 4., 2., 2., 2., 2., 4., 4., 4.,
4., 4., 4., 7., 7., 3., 3., 5., 5., 4., 4., 5., 5.,
4., 4., 7., 7., 6., 6., 2., 2., 2., 2., 5., 5., 4.,
4., 4., 4., 6., 6., 3., 3., 4., 4., 3., 3., 2., 2.,
3., 3., 4., 4., 4., 4., 4., 4., 6., 6., 5., 5., 4.,
4., 7., 7., 3., 3., 4., 4., 4., 4., 5., 5., 4., 4.,
7., 7., 3., 3., 4., 4., 4., 4., 6., 6., 4., 4., 4.,
4., 4., 4., 2., 2., 5., 5., 6., 6., 3., 3., 5., 5.,
4., 4., 0., 0., 5., 5., 1., 1., 4., 4., 5., 5., 4.])

plt.figure(figsize=(7,4))
plt.plot(y)
plt.savefig('test.png')

plt.xlim(-12000, 8274)
plt.savefig('test_panned.png')

- Tom

Thanks. I can confirm this with today's SVN. I'm looking into the cause.

Mike

···

On 04/25/2010 07:11 PM, Tom Aldcroft wrote:

import numpy
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

y = numpy.array([
  4., 2., 2., 3., 3., 2., 2., 6., 6., 5., 5., 4., 4.,
  7., 7., 2., 2., 4., 4., 2., 2., 2., 2., 4., 4., 4.,
  4., 4., 4., 7., 7., 3., 3., 5., 5., 4., 4., 5., 5.,
  4., 4., 7., 7., 6., 6., 2., 2., 2., 2., 5., 5., 4.,
  4., 4., 4., 6., 6., 3., 3., 4., 4., 3., 3., 2., 2.,
  3., 3., 4., 4., 4., 4., 4., 4., 6., 6., 5., 5., 4.,
  4., 7., 7., 3., 3., 4., 4., 4., 4., 5., 5., 4., 4.,
  7., 7., 3., 3., 4., 4., 4., 4., 6., 6., 4., 4., 4.,
  4., 4., 4., 2., 2., 5., 5., 6., 6., 3., 3., 5., 5.,
  4., 4., 0., 0., 5., 5., 1., 1., 4., 4., 5., 5., 4.])

plt.figure(figsize=(7,4))
plt.plot(y)
plt.savefig('test.png')

plt.xlim(-12000, 8274)
plt.savefig('test_panned.png')

I think this is due to improper use of the path.simplify_threshold value in the simplification code. It should have been squared since it's used in a 2-dimensional euclidean distance calculation.

I have made the change to SVN r8280 and updated a few of the unit tests that are now more accurate than they used to be. As a workaround (if you're not running from SVN and don't want to rebuild), you can set the rcParam path.simplify_threshold to 0.01, rather than 0.1.

Mike

Michael Droettboom wrote:

···

Thanks. I can confirm this with today's SVN. I'm looking into the cause.

Mike

On 04/25/2010 07:11 PM, Tom Aldcroft wrote:
  

import numpy
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

y = numpy.array([
  4., 2., 2., 3., 3., 2., 2., 6., 6., 5., 5., 4., 4.,
  7., 7., 2., 2., 4., 4., 2., 2., 2., 2., 4., 4., 4.,
  4., 4., 4., 7., 7., 3., 3., 5., 5., 4., 4., 5., 5.,
  4., 4., 7., 7., 6., 6., 2., 2., 2., 2., 5., 5., 4.,
  4., 4., 4., 6., 6., 3., 3., 4., 4., 3., 3., 2., 2.,
  3., 3., 4., 4., 4., 4., 4., 4., 6., 6., 5., 5., 4.,
  4., 7., 7., 3., 3., 4., 4., 4., 4., 5., 5., 4., 4.,
  7., 7., 3., 3., 4., 4., 4., 4., 6., 6., 4., 4., 4.,
  4., 4., 4., 2., 2., 5., 5., 6., 6., 3., 3., 5., 5.,
  4., 4., 0., 0., 5., 5., 1., 1., 4., 4., 5., 5., 4.])

plt.figure(figsize=(7,4))
plt.plot(y)
plt.savefig('test.png')

plt.xlim(-12000, 8274)
plt.savefig('test_panned.png')
   
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA