Opened 10 years ago

Last modified 9 years ago

#24 new defect

Empty/zero results generates matplotlib warning "Attempting to set identical bottom==top results"

Reported by: flip Owned by: bsoher
Priority: minor Milestone:
Component: common Version:
Keywords: Cc:

Description

I've seen this in a number of contexts, usually when some code with which I'm experimenting goes wrong and produces an experiment with no results, or maybe with results that are all zeroes. Here's one reliable way to recreate it:

  1. Copy & save an existing experiment. I used Example One Pulse.
  2. Export it. When exporting, do not export results.
  3. Delete the experiment.
  4. Import it.
  5. Open it. The visualize tab will appear.
  6. Select all metabs. When I do that, I get the following --
    /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py:2571: UserWarning: Attempting to set identical bottom==top results
    in singular transformations; automatically expanding.
    bottom=0.0, top=0.0
      + 'bottom=%s, top=%s') % (bottom, top))
    

Change History (1)

comment:1 Changed 9 years ago by flip

In at least one case (RFPulse), the source of this warning are calls to axes.set_xlim() and axes.set_ylim() where the min/max values passed are equal to one another (usually zero). In this case, a workaround (I hesitate to call it a fix) is to fudge one of the numbers ever so slightly. They'll still be visually equivalent but not mathematically equivalent and so matplotlib won't complain.

Suggested sample code, which increase xmax by the machine epsilon --

if xmin == xmax:
    xmax += np.finfo(type(xmax)).eps
axes.set_xlim([xmin,xmax])

Something similar (although more elegant) is suggested in this conversation:
http://comments.gmane.org/gmane.comp.python.matplotlib.general/27138

Note: See TracTickets for help on using tickets.