|
From: Benjamin R. <ben...@ou...> - 2011-02-15 18:20:00
|
On Tue, Feb 15, 2011 at 11:54 AM, Eric Firing <ef...@ha...> wrote: > On 02/15/2011 07:40 AM, Benjamin Root wrote: > > I have come across a little inconsistency that was unexpected in the > > matplotlib API. The following is perfectly valid: > > > > import matplotlib.pyplot as plt > > plt.plot([], []) > > plt.show() > > > > > > However, this is not valid: > > > > import matplotlib.pyplot as plt > > plt.scatter([], []) > > plt.show() > > > > > > The immediate issue that comes up in scatter is that it attempts to find > > min/max of the input data for the purpose of autoscaling (this can > > probably be done better by just using set_xmargin(0.05) and > > set_ymargin(0.05)). This can easily be bypassed with an if statement. > > However, then we discover that polygon collection do not like having > > empty offsets, which leads to a failure in the affine transformation. > > > > So, the question is, is this a bug or a feature? I personally believe > > that empty data is a perfectly valid scenario and given that other > > matplotlib functions handle it gracefully, we should make the > > collections object more friendly to empty data. > > I agree; a call with empty data should simply not plot anything. > > Eric > > Digging further, it appears that the problem is in _path.cpp for _path_module::affine_transform() which explicitly checks for an empty vertices array and throws an exception if it is empty. So, do we want to make _path.cpp empty-friendly or should we just make empty collections objects just avoid doing anything that requires doing an affine transform? Ben Root |