Problem with errorbar and log axis

Hi,

I am trying to make an errorbar plot with a logarithmic x-axis. I have symmetric errors in logspace, however if I plot them, the errors are not symmetric anymore, as you can see in the enclosed image. Am I misunderstanding something or is this a bug?

Thanks for your help,
Markus

Here the code I used to produce the plot:

import matplotlib.pyplot as plt

import numpy as np

data_x_log = np.array([13.0,15.0])

data_y = np.array([0.5,1])

error_x_log = np.array([0.5,1.])

error_x_lower = 10**(data_x_log-error_x_log)

error_x_upper = 10**(data_x_log+error_x_log)

fig = plt.figure()

ax = fig.add_subplot(111)

ax.errorbar(10**data_x_log,data_y,xerr=[error_x_lower,error_x_upper],ls='',marker='o')

ax.set_xscale('log')

ax.set_xlim([1E11,1E17])

ax.set_ylim([0,2])

plt.savefig('error.png')

error.png

If you error bars denote standard deviation of standard error of mean,
shouldn't they be non-symmetric in log scale?

Shawn

···

On Tue, Apr 7, 2015 at 10:11 AM, Markus Haider <markus.haider@...1627...> wrote:

Hi,

I am trying to make an errorbar plot with a logarithmic x-axis. I have
symmetric errors in logspace, however if I plot them, the errors are not
symmetric anymore, as you can see in the enclosed image. Am I
misunderstanding something or is this a bug?

Thanks for your help,
Markus

Here the code I used to produce the plot:

import matplotlib.pyplot as plt

import numpy as np

data_x_log = np.array([13.0,15.0])

data_y = np.array([0.5,1])

error_x_log = np.array([0.5,1.])

error_x_lower = 10**(data_x_log-error_x_log)

error_x_upper = 10**(data_x_log+error_x_log)

fig = plt.figure()

ax = fig.add_subplot(111)

ax.errorbar(10**data_x_log,data_y,xerr=[error_x_lower,error_x_upper],ls='',marker='o')

ax.set_xscale('log')

ax.set_xlim([1E11,1E17])

ax.set_ylim([0,2])

plt.savefig('error.png')

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj@...809...
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/

Typo - "standard deviation OR standard error of mean", not "OF".

Sorry.

Shawn

···

On Tue, Apr 7, 2015 at 10:39 AM, Yuxiang Wang <yw5aj@...809...> wrote:

If you error bars denote standard deviation of standard error of mean,
shouldn't they be non-symmetric in log scale?

Shawn

On Tue, Apr 7, 2015 at 10:11 AM, Markus Haider <markus.haider@...1627...> wrote:

Hi,

I am trying to make an errorbar plot with a logarithmic x-axis. I have
symmetric errors in logspace, however if I plot them, the errors are not
symmetric anymore, as you can see in the enclosed image. Am I
misunderstanding something or is this a bug?

Thanks for your help,
Markus

Here the code I used to produce the plot:

import matplotlib.pyplot as plt

import numpy as np

data_x_log = np.array([13.0,15.0])

data_y = np.array([0.5,1])

error_x_log = np.array([0.5,1.])

error_x_lower = 10**(data_x_log-error_x_log)

error_x_upper = 10**(data_x_log+error_x_log)

fig = plt.figure()

ax = fig.add_subplot(111)

ax.errorbar(10**data_x_log,data_y,xerr=[error_x_lower,error_x_upper],ls='',marker='o')

ax.set_xscale('log')

ax.set_xlim([1E11,1E17])

ax.set_ylim([0,2])

plt.savefig('error.png')

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj@...809...
+1 (434) 284-0836
Sign in - Google Accounts

--
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj@...809...
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/

I have the error from a table which is in log units, and the error is given to be symmetric in log space.

Cheers,
Markus

···

On 2015-04-07 16:40, Yuxiang Wang wrote:

Typo - "standard deviation OR standard error of mean", not "OF".

Sorry.

Shawn

On Tue, Apr 7, 2015 at 10:39 AM, Yuxiang Wang <yw5aj@...809...> wrote:

If you error bars denote standard deviation of standard error of mean,
shouldn't they be non-symmetric in log scale?

Shawn

On Tue, Apr 7, 2015 at 10:11 AM, Markus Haider <markus.haider@...1627...> wrote:

Hi,

I am trying to make an errorbar plot with a logarithmic x-axis. I have
symmetric errors in logspace, however if I plot them, the errors are not
symmetric anymore, as you can see in the enclosed image. Am I
misunderstanding something or is this a bug?

Thanks for your help,
Markus

Here the code I used to produce the plot:

import matplotlib.pyplot as plt

import numpy as np

data_x_log = np.array([13.0,15.0])

data_y = np.array([0.5,1])

error_x_log = np.array([0.5,1.])

error_x_lower = 10**(data_x_log-error_x_log)

error_x_upper = 10**(data_x_log+error_x_log)

fig = plt.figure()

ax = fig.add_subplot(111)

ax.errorbar(10**data_x_log,data_y,xerr=[error_x_lower,error_x_upper],ls='',marker='o')

ax.set_xscale('log')

ax.set_xlim([1E11,1E17])

ax.set_ylim([0,2])

plt.savefig('error.png')

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj@...809...
+1 (434) 284-0836
Sign in - Google Accounts

xerr is +/- relative to the data:

*xerr*/*yerr*: [ scalar | N, Nx1, or 2xN array-like ]
    If a scalar number, len(N) array-like object, or an Nx1
    array-like object, errorbars are drawn at +/-value relative
    to the data.

    If a sequence of shape 2xN, errorbars are drawn at -row1
    and +row2 relative to the data.

I think you want:

xdat=10**data_x_log
ax.errorbar(10**data_x_log,data_y,xerr=[xdat-error_x_lower,error_x_upper-xdat],ls='',marker='o')

Cheers, Jody

···

On 7 Apr 2015, at 13:51 PM, Markus Haider <markus.haider@...1627...> wrote:

I have the error from a table which is in log units, and the error is
given to be symmetric in log space.

Cheers,
Markus

On 2015-04-07 16:40, Yuxiang Wang wrote:

Typo - "standard deviation OR standard error of mean", not "OF".

Sorry.

Shawn

On Tue, Apr 7, 2015 at 10:39 AM, Yuxiang Wang <yw5aj@...809...> wrote:

If you error bars denote standard deviation of standard error of mean,
shouldn't they be non-symmetric in log scale?

Shawn

On Tue, Apr 7, 2015 at 10:11 AM, Markus Haider <markus.haider@...4650....> wrote:

Hi,

I am trying to make an errorbar plot with a logarithmic x-axis. I have
symmetric errors in logspace, however if I plot them, the errors are not
symmetric anymore, as you can see in the enclosed image. Am I
misunderstanding something or is this a bug?

Thanks for your help,
Markus

Here the code I used to produce the plot:

import matplotlib.pyplot as plt

import numpy as np

data_x_log = np.array([13.0,15.0])

data_y = np.array([0.5,1])

error_x_log = np.array([0.5,1.])

error_x_lower = 10**(data_x_log-error_x_log)

error_x_upper = 10**(data_x_log+error_x_log)

fig = plt.figure()

ax = fig.add_subplot(111)

ax.errorbar(10**data_x_log,data_y,xerr=[error_x_lower,error_x_upper],ls='',marker='o')

ax.set_xscale('log')

ax.set_xlim([1E11,1E17])

ax.set_ylim([0,2])

plt.savefig('error.png')

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj@...809...
+1 (434) 284-0836
Sign in - Google Accounts

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Jody Klymak

Hi Jody,

Thank you very much for your help. You are right, this is what I wanted :slight_smile:

Cheers,
Markus

···

On 2015-04-07 23:33, Jody Klymak wrote:

xerr is +/- relative to the data:

*xerr*/*yerr*: [ scalar | N, Nx1, or 2xN array-like ]
     If a scalar number, len(N) array-like object, or an Nx1
     array-like object, errorbars are drawn at +/-value relative
     to the data.

     If a sequence of shape 2xN, errorbars are drawn at -row1
     and +row2 relative to the data.

I think you want:

xdat=10**data_x_log
ax.errorbar(10**data_x_log,data_y,xerr=[xdat-error_x_lower,error_x_upper-xdat],ls='',marker='o')

Cheers, Jody

On 7 Apr 2015, at 13:51 PM, Markus Haider <markus.haider@...1627...> wrote:

I have the error from a table which is in log units, and the error is
given to be symmetric in log space.

Cheers,
Markus

On 2015-04-07 16:40, Yuxiang Wang wrote:

Typo - "standard deviation OR standard error of mean", not "OF".

Sorry.

Shawn

On Tue, Apr 7, 2015 at 10:39 AM, Yuxiang Wang <yw5aj@...809...> wrote:

If you error bars denote standard deviation of standard error of mean,
shouldn't they be non-symmetric in log scale?

Shawn

On Tue, Apr 7, 2015 at 10:11 AM, Markus Haider <markus.haider@...1627...> wrote:

Hi,

I am trying to make an errorbar plot with a logarithmic x-axis. I have
symmetric errors in logspace, however if I plot them, the errors are not
symmetric anymore, as you can see in the enclosed image. Am I
misunderstanding something or is this a bug?

Thanks for your help,
Markus

Here the code I used to produce the plot:

import matplotlib.pyplot as plt

import numpy as np

data_x_log = np.array([13.0,15.0])

data_y = np.array([0.5,1])

error_x_log = np.array([0.5,1.])

error_x_lower = 10**(data_x_log-error_x_log)

error_x_upper = 10**(data_x_log+error_x_log)

fig = plt.figure()

ax = fig.add_subplot(111)

ax.errorbar(10**data_x_log,data_y,xerr=[error_x_lower,error_x_upper],ls='',marker='o')

ax.set_xscale('log')

ax.set_xlim([1E11,1E17])

ax.set_ylim([0,2])

plt.savefig('error.png')

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw5aj@...809...
+1 (434) 284-0836
Sign in - Google Accounts

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Jody Klymak
Jody M. Klymak - UVic Ocean Physics

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options