|
From: Markus H. <mar...@ui...> - 2015-04-07 14:14:20
|
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')
|