UserWarning: Attempting to set identical bottom==top

I get this error and would like to know what to do to eliminate it and
also what it means:

C:\Python25\lib\site-packages\matplotlib\axes.py:2571:
UserWarning: Attempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=0, top=0 + 'bottom=%s, top=%s') % (bottom, top))

This is with Matplotlib 1.0.0.

Thank you,
Che

I have seen this happen when the plot is set to use the limits of the data
to guide the axes limits, but the data being displayed is either vertical or
horizontal.

What do you mean by the data being vertical or horizontal? I can get
this error with a single point that is plotted on a time vs. values
plot.

It isn't a huge issue as the code is automatically padding the
axes to make take the plot out of "flat world".

The problem is, when I use a py2exe'd app this error occurs and the
user sees a message to see the log file for the error. I don't want
that at all. It's a bad user experience.

Is there a way I can prevent this error from ever being generated?

Thanks.

···

On Thu, May 5, 2011 at 10:03 PM, C M <cmpython@...287...> wrote:

On Thu, May 5, 2011 at 7:58 PM, Benjamin Root <ben.root@...1304...> wrote:

On Sun, May 1, 2011 at 4:35 PM, C M <cmpython@...287...> wrote:

I get this error and would like to know what to do to eliminate it and

also what it means:

C:\Python25\lib\site-packages\matplotlib\axes.py:2571:

UserWarning: Attempting to set identical bottom==top results

in singular transformations; automatically expanding.

bottom=0, top=0 + ‘bottom=%s, top=%s’) % (bottom, top))

This is with Matplotlib 1.0.0.

Thank you,

Che

I have seen this happen when the plot is set to use the limits of the data

to guide the axes limits, but the data being displayed is either vertical or

horizontal.

What do you mean by the data being vertical or horizontal? I can get

this error with a single point that is plotted on a time vs. values

plot.

Or even a single point. In other words, if the bounding box encompassing the data being plotted can be reduced to a 1 or 0 dimensional representation, then matplotlib will auto-pad this so that the rest of matplotlib won’t crash.

It isn’t a huge issue as the code is automatically padding the

axes to make take the plot out of “flat world”.

The problem is, when I use a py2exe’d app this error occurs and the

user sees a message to see the log file for the error. I don’t want

that at all. It’s a bad user experience.

The warning message is important because it is usually an indication that the program is doing something wrong. If you (and by “you”, I mean the program) might be plotting a single point or something that can be reduced to 1 or 0 dimensions, then you should not have the axes automatically set its limits from the data without pads.

Because you have a py2exe’ed program, I suspect that whoever packaged the program should be the one to modify that program to choose its axes limits more robustly in order to avoid the warning message.

Unless the other developers feel differently, I am against suppressing this warning message.

I hope that makes things clearer.
Ben Root

···

On Thu, May 5, 2011 at 9:04 PM, C M <cmpython@…287…> wrote:

On Thu, May 5, 2011 at 10:03 PM, C M <cmpython@…287…> wrote:

On Thu, May 5, 2011 at 7:58 PM, Benjamin Root <ben.root@…1304…> wrote:

On Sun, May 1, 2011 at 4:35 PM, C M <cmpython@…287…> wrote:

Because you have a py2exe'ed program, I suspect that whoever packaged the
program should be the one to modify that program to choose its axes limits
more robustly in order to avoid the warning message.

Maybe I have been unclear. I am the sole developer of this
application, and I occasionally test it as a py2exe'd app in
anticipation of delivering it in that form at some point. I would be
happy to modify the program to choose its axes limits more
robustly--if I only knew how to do that. That is what I am asking.
How should I do that?

The data to be plotted is a very simple date plot with dates on the x
axis and values (formatted as time) on the y axis.

Che

Is there a list archive I can search to see if a question has been asked before?
Thanks,
Nate

http://old.nabble.com/matplotlib---users-f2906.html

There are others as well. These are good formviewing the archives.
But for searches, I just use google with matplotlib as the first term.
Most results usually point to a thread archived on nabble anyway.

I hope that helps!
Ben Root

···

On Thursday, May 5, 2011, Nate Gallagher <nate.gallagher@...9...> wrote:

Is there a list archive I can search to see if a question has been asked before?
Thanks,
Nate

Most likely, somewhere in your code, you have a call to set_ylim(), and are likely setting it to the minimum and maximum values of the data you are plotting. This is where the problem comes in. There are several options to go about avoiding the problem here. One is to not call set_ylim() at all if you have only one data point, and just let matplotlib figure out the y-limits automatically. Another approach is to call set_ylim() with parameters that have an explicit amount of padding, like the following:

ax.set_ylim(y.min() - 0.5, y.max() + 0.5)

This way, you are guaranteed that the top and bottom limits will never be the same. The best approach is up to you.

I hope that helps!
Ben Root

···

On Thu, May 5, 2011 at 10:01 PM, C M <cmpython@…287…> wrote:

Because you have a py2exe’ed program, I suspect that whoever packaged the

program should be the one to modify that program to choose its axes limits

more robustly in order to avoid the warning message.

Maybe I have been unclear. I am the sole developer of this

application, and I occasionally test it as a py2exe’d app in

anticipation of delivering it in that form at some point. I would be

happy to modify the program to choose its axes limits more

robustly–if I only knew how to do that. That is what I am asking.

How should I do that?

The data to be plotted is a very simple date plot with dates on the x

axis and values (formatted as time) on the y axis.

Che

Thank you, Ben! That helps a lot. Adding some padding myself seems
to fix it. And it's good to understand what was occurring.

-Che

···

On Fri, May 6, 2011 at 10:33 AM, Benjamin Root <ben.root@...1304...> wrote:

On Thu, May 5, 2011 at 10:01 PM, C M <cmpython@...287...> wrote:

> Because you have a py2exe'ed program, I suspect that whoever packaged
> the
> program should be the one to modify that program to choose its axes
> limits
> more robustly in order to avoid the warning message.

Maybe I have been unclear. I am the sole developer of this
application, and I occasionally test it as a py2exe'd app in
anticipation of delivering it in that form at some point. I would be
happy to modify the program to choose its axes limits more
robustly--if I only knew how to do that. That is what I am asking.
How should I do that?

The data to be plotted is a very simple date plot with dates on the x
axis and values (formatted as time) on the y axis.

Che

Most likely, somewhere in your code, you have a call to set_ylim(), and are
likely setting it to the minimum and maximum values of the data you are
plotting. This is where the problem comes in. There are several options to
go about avoiding the problem here. One is to not call set_ylim() at all if
you have only one data point, and just let matplotlib figure out the
y-limits automatically. Another approach is to call set_ylim() with
parameters that have an explicit amount of padding, like the following:

ax.set_ylim(y.min() - 0.5, y.max() + 0.5)

This way, you are guaranteed that the top and bottom limits will never be
the same. The best approach is up to you.

I hope that helps!
Ben Root