Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:02:41+00:00 2026-06-14T23:02:41+00:00

In some cases matplotlib shows plot with errorbars errorneously when using logarithmic scale. Suppose

  • 0

In some cases matplotlib shows plot with errorbars errorneously when using logarithmic scale.
Suppose these data (within pylab for example):

s=[19.0, 20.0, 21.0, 22.0, 24.0]
v=[36.5, 66.814250000000001, 130.17750000000001, 498.57466666666664, 19.41]
verr=[0.28999999999999998, 80.075044597909169, 71.322124839818571, 650.11015891565125, 0.02]
errorbar(s,v,yerr=verr)

and I get a normal result but when I switch to logarithmic scale:

yscale('log')

I get a plot in which some errorbars are not visible, although you can still see some of the error bar caps. (See below.) Why is this happening, and how can I fix it?

log plot example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:02:43+00:00Added an answer on June 14, 2026 at 11:02 pm

    The problem is that for some points v-verr is becoming negative, values <=0 cannot be shown on a logarithmic axis (log(x), x<=0 is undefined) To get around this you can use asymmetric errors and force the resulting values to be above zero for the offending points.

    At any point for which errors are bigger than value verr>=v we assign verr=.999v in this case the error bar will go close to zero.

    Here is the script

    import matplotlib.pyplot as plt
    import numpy as np
    
    s=[19.0, 20.0, 21.0, 22.0, 24.0]
    v=np.array([36.5, 66.814250000000001, 130.17750000000001, 498.57466666666664, 19.41])
    verr=np.array([0.28999999999999998, 80.075044597909169, 71.322124839818571,     650.11015891565125, 0.02])
    verr2 = np.array(verr)
    verr2[verr>=v] = v[verr>=v]*.999999
    plt.errorbar(s,v,yerr=[verr2,verr])
    plt.ylim(1E1,1E4)
    plt.yscale('log')
    plt.show()
    

    Here is the result

    Logarithmic plot with error bars

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to plot some HDF data in matplotlib. After importing them using
I have a checkbox which in some cases may be disabled and checked using
I am using jquery cluetip and i have noticed taht in some cases the
In my WPF application using MVVM I noticed that in some cases the CanExecute
I'm using the following code in some cases: #define array_key_exists(find_key, arr) (arr.find(find_key) != arr.end())
I find using blocks in some cases more convenient to use than the Delegate
i am using collection object. In some cases no of objects become large. in
From my basic understanding about using matplotlib you store your desired plt in some
I have two figures, one is a data plot resulting from some calculations and
I want to make a contour plot of some data, but it is possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.