errorbar plot requires hold=True

When I use the errorbar() routine to plot data, unless I set hold=True as a kwarg (or set it globally), the data are plotted without the errorbars. I believe it is because the routine first plots the error bars, then overplots the data points and for some reason the routine is clearing the axis in between these steps.

This is rather annoying for interactive use and does not seem to be the expected behavior. For example, if I run the example code from the errorbar page (my copy pasted below), I get a nice plot of the data with no error bars. This seems to be the effect either from within "ipython -pylab" or from standalone scripts.

Any advice would be greatly appreciated, thanks.

joey

import numpy as np
import matplotlib.pyplot as plt

# example data
x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)

# example variable error bar values
yerr = 0.1 + 0.2*np.sqrt(x)
xerr = 0.1 + yerr

# First illustrate basic pyplot interface, using defaults where possible.
plt.figure()
plt.errorbar(x, y, xerr=0.2, yerr=0.4)
plt.title("Simplest errorbars, 0.2 in x, 0.4 in y")

plt.show()

Joey,

The code works as expected for me. Which version of matplotlib are you using (print matplotlib.version)?

Ben Root

···

On Thu, Sep 30, 2010 at 1:28 PM, Joey Richards <joey@…256…> wrote:

When I use the errorbar() routine to plot data, unless I set hold=True as a kwarg (or set it globally), the data are plotted without the errorbars. I believe it is because the routine first plots the error bars, then overplots the data points and for some reason the routine is clearing the axis in between these steps.

This is rather annoying for interactive use and does not seem to be the expected behavior. For example, if I run the example code from the errorbar page (my copy pasted below), I get a nice plot of the data with no error bars. This seems to be the effect either from within “ipython -pylab” or from standalone scripts.

Any advice would be greatly appreciated, thanks.

joey

import numpy as np

import matplotlib.pyplot as plt

example data

x = np.arange(0.1, 4, 0.5)

y = np.exp(-x)

example variable error bar values

yerr = 0.1 + 0.2*np.sqrt(x)

xerr = 0.1 + yerr

First illustrate basic pyplot interface, using defaults where possible.

plt.figure()

plt.errorbar(x, y, xerr=0.2, yerr=0.4)

plt.title(“Simplest errorbars, 0.2 in x, 0.4 in y”)

plt.show()

I just had another thought… have you ever modified your matplotlibrc file? It might be possible that you have turned off holds (which is default). If so, then this would be a bug, because the errorbar function should temporarially turn on the hold in order to complete its task.

Ben Root

···

On Thu, Sep 30, 2010 at 1:44 PM, Benjamin Root <ben.root@…3146…4…> wrote:

On Thu, Sep 30, 2010 at 1:28 PM, Joey Richards <joey@…256…> wrote:

When I use the errorbar() routine to plot data, unless I set hold=True as a kwarg (or set it globally), the data are plotted without the errorbars. I believe it is because the routine first plots the error bars, then overplots the data points and for some reason the routine is clearing the axis in between these steps.

This is rather annoying for interactive use and does not seem to be the expected behavior. For example, if I run the example code from the errorbar page (my copy pasted below), I get a nice plot of the data with no error bars. This seems to be the effect either from within “ipython -pylab” or from standalone scripts.

Any advice would be greatly appreciated, thanks.

joey

import numpy as np

import matplotlib.pyplot as plt

example data

x = np.arange(0.1, 4, 0.5)

y = np.exp(-x)

example variable error bar values

yerr = 0.1 + 0.2*np.sqrt(x)

xerr = 0.1 + yerr

First illustrate basic pyplot interface, using defaults where possible.

plt.figure()

plt.errorbar(x, y, xerr=0.2, yerr=0.4)

plt.title(“Simplest errorbars, 0.2 in x, 0.4 in y”)

plt.show()

Joey,

The code works as expected for me. Which version of matplotlib are you using (print matplotlib.version)?

Ben Root

When I use the errorbar() routine to plot data, unless I set hold=True as a kwarg (or set it globally), the data are plotted without the errorbars. I believe it is because the routine first plots the error bars, then overplots the data points and for some reason the routine is clearing the axis in between these steps.

Joey,

That is a major bug in errorbar. I suspect no one has brought it to our attention before because hold=True is the default. The only workaround is what you have already found: ensure hold is True for the call to errorbar.

If there is no reply within a couple of days to the effect that someone has fixed this bug, then please file a ticket so that we don't forget about it. http://sourceforge.net/tracker/?group_id=80706&atid=560720

Eric

···

On 09/30/2010 08:28 AM, Joey Richards wrote:

This is rather annoying for interactive use and does not seem to be the expected behavior. For example, if I run the example code from the errorbar page (my copy pasted below), I get a nice plot of the data with no error bars. This seems to be the effect either from within "ipython -pylab" or from standalone scripts.

Any advice would be greatly appreciated, thanks.

joey

import numpy as np
import matplotlib.pyplot as plt

# example data
x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)

# example variable error bar values
yerr = 0.1 + 0.2*np.sqrt(x)
xerr = 0.1 + yerr

# First illustrate basic pyplot interface, using defaults where possible.
plt.figure()
plt.errorbar(x, y, xerr=0.2, yerr=0.4)
plt.title("Simplest errorbars, 0.2 in x, 0.4 in y")

plt.show()

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I just had another thought.... have you ever modified your matplotlibrc file? It might be possible that you have turned off holds (which is default). If so, then this would be a bug, because the errorbar function should temporarially turn on the hold in order to complete its task.

You are correct, I have modified axes.hold to be False by default.

For the record, this is with version 0.99.1.1 but has been the case for at least several versions earlier, and I believe is the same on 1.0.

···

On Sep 30, 2010, at 11:46 AM, Benjamin Root wrote:

On Sep 30, 2010, at 11:48 AM, Eric Firing wrote:

That is a major bug in errorbar. I suspect no one has brought it to our
attention before because hold=True is the default. The only workaround
is what you have already found: ensure hold is True for the call to
errorbar.

If there is no reply within a couple of days to the effect that someone
has fixed this bug, then please file a ticket so that we don't forget
about it. http://sourceforge.net/tracker/?group_id=80706&atid=560720

Ok, I'm glad at least for the confirmation that I'm not crazy. I'll add a ticket in a bit if it isn't fixed before then. I guess the fix is simply to enable holds after the first plot command within errorbar(), then restore the hold state at the end.

joey

Fixed in 8724.

Eric

···

On 09/30/2010 08:28 AM, Joey Richards wrote:

When I use the errorbar() routine to plot data, unless I set hold=True as a kwarg (or set it globally), the data are plotted without the errorbars. I believe it is because the routine first plots the error bars, then overplots the data points and for some reason the routine is clearing the axis in between these steps.