here is my problem:
_I have some physical data representing an angle between -90 and 90 degrees. There is a known error associated with this data. I'm working in python3 with numpy and matplotlib.
_I want to plot the data with its error bars for each measurments. The angles range from -90 to 90, and the errors should not go out of these bounds. For example, for an angle of 85+/-10 degrees, I want the upper error bar to cycle back to -85 instead of going to 95.
_Is it possible? How? I'm trying to use $plt.fill_between()$ or $plt.errorbar()$, but it does not work. In the exemple above, even if I try to force the error bar to -85, the error does not cycle through 90...
Here are some examples:
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(10) #time
a = np.linspace(50, 89, 10) #fake angle value
e = np.array([10]*10) #error value
a_up = a + e #Upper error bars
a_low = a - e #Lower error bars
f, ax = plt.subplots(nrows=2, ncols=2)
###Simple error graph, I don't want it because error bars outside of [-90, 90]
ax[0, 0].errorbar(t, a, yerr = e) #Plot the errors as error bars
### Same but with shaded area
ax[0, 1].fill_between(t, a_low, a_up) #Plot the errors as filled region
ax[0, 1].plot(t, a, "*r")
###My best option right now, put an upper limit everywhere
for i, u in enumerate(a_up):
if u > 90:
a_up[i] = 90
ax[1, 0].fill_between(t, a_low, a_up) #Plot the errors
ax[1, 0].plot(t, a, "*r")
###Finally, force all errorbars in [-90, 90] (Just for this exemple, it's generalized in my code)
for i, u in enumerate(a_up):
if u >= 90:
a_up[i] -= 90
ax[1, 1].fill_between(t, a_low, a_up) #Plot the errors
ax[1, 1].plot(t, a, "*r")
plt.show()
I hope I'm clear enough, I can't find a solution on the web... Maybe I don't know how to formulate it.
Thanks in advance for your help, after 10 years of using your answers, I finally got the oppurtunity to ask one! :)
Léo