Closed
Description
Bug report
Bug summary
Changing the example radian_ticks.py
to plot a waveform from a negative to positive radians range displays incorrect tick labels.
x = [val*radians for val in np.arange(-7, 8, 0.01)]
The issues:
- "0" is repeated
- "-1pi/2" should just be "-pi/2"
- The negative labels are just wrong
Fix
Change rad_fn()
in basic_units.py
:
# radians formatting
def rad_fn(x, pos=None):
if x >= 0:
n = int((x / np.pi) * 2.0 + 0.25)
else:
n = int((x / np.pi) * 2.0 - 0.25)
if n == 0:
return '0'
elif n == 1:
return r'$\pi/2$'
elif n == 2:
return r'$\pi$'
elif n == -1:
return r'$-\pi/2$'
elif n == -2:
return r'$-\pi$'
elif n % 2 == 0:
return r'$%s\pi$' % (n//2,)
else:
return r'$%s\pi/2$' % (n,)
Metadata
Metadata
Assignees
Labels
No labels