From: John H. <jdh...@ac...> - 2004-04-20 13:48:21
|
>>>>> "Srinath" == Srinath Avadhanula <sr...@fa...> writes: Srinath> Besides whether or not its a common enough situation is Srinath> very application specific. I was planning to use Srinath> matplotlib to display a complex layout. At the original Srinath> scale, not much can be seen. There necessarily has to be Srinath> a lot of scaling to see the details. Well, it's not complex scaling that causes troubles. The case where you see this failure is when you are drawing a connected line between two points where one or both of the points is far outside the view limits. Srinath> Could you let me know which files in matplotlib have the Srinath> code in question? I'll take a look then. The two relevant methods are matplotlib.transforms.Transform.positions and matplotlib.lines.Line2D._draw. I think the best place to start would be in the latter function. Let the transform do it's thing and then look for negative points. Note there are two kinds of clipping in matplotlib: data clipping and view clipping. data clipping removes data outside the view limits before transpose and plotting. view clipping is a renderer operation that prevents lines from being drawn outside the axes box. data clipping would remove a point from a connected line outside the viewport and prevent any part of that line from being drawn, even the part in the view port. view clipping would only clip the part that extends outside the viewport. The decision to use one or the other is often motivated by performance. Eg, if you want to plot a very large data set with only a small fraction in the viewport (which I often do), you often want to use data clipping to reduce the data set before transform and rendering. If you normally plot data with limits near the viewport limits you probably do not want the extra performance overhead and are happy with just view clipping which gives the "usual" result. That is why it's a configurable parameter. In earlier versions of matplotlib data clipping was on by default so data outside the view ports was removed. That is probably why we didn't see this negative transform error earlier. But experiments revealed that in the most common cases, data clipping did not provide an extra performance benefit, and occasionally surprised users in cases very similar to yours where one point of a connected line was outside the viewport and the entire line was removed. Given that negative display coords are essentially undefined (and backend dependent) at this point, I'm going to re-enable data clipping in the default matplotlibrc file, and I suggest most users do the same. There may be modulo operations on data points very far outside the data set that generate negative display values, or display values far larger than the display limits, each of which could cause artifact points. The ideal solution is yet to be found, but I'm open to suggestions and improvements. JDH |