I am trying to make a plot of column density, "nh", for a number of sources. Each source is represented by a key value. And I have multiple dictionaries that match that key to some value. For example:
print(nh_noUL_val, '\n')
print(noUL_colors, '\n')
print(asymetric_error,'\n')
This gives my data:
{2: 3.3e+21, 7: 7e+20, 29: 2e+22, 203: 8.5e+21, 226: 2.1e+21, 231: 6e+19, 259: 4.2e+21, 307: 1.8e+20, 320: 2.6e+21, 366: 4.4e+22, 374: 6e+21, 1143: 3e+22}
{2: 'black', 7: 'green', 29: 'red', 203: 'blue', 226: 'blue', 231: 'blue', 259: 'blue', 307: 'green', 320: 'green', 366: 'blue', 374: 'red', 1143: 'red'}
{2: [4e+20, 4e+20], 7: [7e+20, 3.6e+21], 29: [2e+22, 3.3e+22], 203: [8.5e+21, 2.47e+22], 226: [2.1e+21, 2.17e+22], 231: [6e+19, 9.76e+21], 259: [4.2e+21, 1.9899999999999997e+22], 307: [1.8e+20, 4.65e+21], 320: [2.6e+21, 1.2900000000000001e+22], 366: [4.4e+22, 1.4800000000000001e+23], 374: [6e+21, 3.1e+22], 1143: [3e+22, 4e+22]}
With this data, I am trying to plot each source as a colored data point with its respective color, value, and asymmetric errors.
fig, ax = plt.subplots()
for x, y, yerr, color in zip(nh_noUL_val.keys(), nh_noUL_val.values(), asymetric_error.values(),
noUL_colors.values()):
ax.errorbar(x,y , yerr = asymetric_error, color = color, marker = 'o', ms = 5)
plt.show()
However, this gives me:
ValueError: err must be [ scalar | N, Nx1 or 2xN array-like ]
Admittedly, I am somewhat new to python and don't fully understand arrays. But my guess would be that my asymmetric_error.values()
is actually an Nx2 array? If that's the case, how do I get that into 2xN form? If that's not the case, what is wrong with my code?