I've come across a problem (possibly a bug in cleanup_path) after
plotting a line containing nan's and then scaling the axes so that the
line is clipped by the axes.

Instead of a gap at the position of the nan value, two extra segments
appear - back to the start and then onto the next-plus-one valid
point.  It's quite dependent on exactly how the line is clipped, and
by interactively zooming the plot the issue can be made to disappear
and reappear.

e.g.

##############################
import matplotlib
matplotlib.use('pdf') #pdf or ps or agg (incl. inside gui) reproduce
the issue, cairo works as expected
import matplotlib.pyplot as plt
import numpy as np

f = plt.figure()
ax = f.add_subplot(111)
ax.plot([30.,50.,900.,449.0,np.nan,50,60,100])
ax.set_ylim([0,400]) #default plot limits work fine
f.savefig('test')
##############################

This is with the Ubuntu 12.04 version of matplotlib (on x86_64);
v1.1.1rc. Version 1.0.1 (also via Ubuntu) was ok.


For the pdf backend, at least, the problem seems to appear in the call to
cleanup_path at line 247 of path.py (in iter_segments):

vertices, codes = cleanup_path(self, transform, remove_nans, clip,
                                       snap, stroke_width, simplify, curves)

Before the call, the path looks ok, but after the call to
cleanup_path, vertices is a bit of a mess (corresponding 'code' in
brackets):
 array([[  72.        ,   69.12      ],  (moveto)
       [ 135.77142857,   86.4       ],  (lineto)
       [ 165.86834734,  433.        ],  (lineto)
       [ 263.00922817,  433.        ],  (moveto)
       [ 263.31428571,  431.136     ],  (lineto)
       [  72.        ,   69.12      ],  (lineto) <--- (should be a gap?)
       [ 454.62857143,   95.04      ],  (lineto)
       [ 518.4       ,  129.6       ],  (lineto)
       [ 518.4       ,  129.6       ]]) (stop)


I can work around the problem by setting the backend to 'cairo' or by adding
    clip = None
near the top of iter_segments (line 235 of path.py)

HTH.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to