Issue
I am plotting some time series data with the time being GPS time. I'd like the ticks on my x-axis to be seconds relative to a reference time. So the ticks should be in the range [-100, 100], rather than e.g. [1390585610, 1390585810] (the current GPS time as I write this). I can get this behavior by writing:
axs[1].ticklabel_format(axis = 'x', useOffset = central_time, style = 'plain')
but this produces a small label to the bottom right of the x-axis reading "+1.390585710e9", which I don't want to be displayed. Is there a way to suppress the scientific notation but keep my desired x-axis ticking.
Here's an example of the current behavior and the code used to make it:
import matplotlib.pyplot as plt
xs = [1390585610, 1390585660, 1390585710, 1390585760, 1390585810]
ys = [-1, 0, 1, 0 , -1]
fig, axs = plt.subplots(1)
axs.plot(xs, ys)
axs.ticklabel_format(axis = 'x', useOffset = 1390585710, style = 'plain')
plt.show()
Solution
You could just subtract the offset manually for the plotter and forgo the useOffset
parameter:
import matplotlib.pyplot as plt
xs = np.array([1390585610, 1390585660, 1390585710, 1390585760, 1390585810])
ys = [-1, 0, 1, 0 , -1]
offset = 1390585710
fig, axs = plt.subplots(1)
axs.plot(xs-offset, ys)
axs.ticklabel_format(axis = 'x', style = 'plain')
plt.show()
Answered By - Woodford
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.