I am trying to plot some data but the tick marks show up in the incorrect order on the plot.
Yes, I know that xdata
is just zeros, it just happened that the log I was using had only zeros.
Yes, I know that ydata
appears to repeat itself, that is just how the data is in the log. I need to convince people that we need to add milliseconds to the log times.
fig = plt.figure()
fig.set_size_inches(18.5, 10.5)
fontSize = 9
ax = plt.subplot(1,7,7)
ax.set_title("My Data Plot", y=0, pad=-30)
ax.xaxis.set_ticks_position('top')
ax.yaxis.set_ticks_position('right')
ax.yaxis.set_label_position('right')
timeTicks = ['17:41:39', '17:41:30', '17:41:20', '17:41:10', '17:41:00', '17:40:50', '17:40:40', '17:40:30', '17:40:20']
xdata = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
d = xdata
d.reverse()
ydata = ['17:40:36', '17:40:36', '17:40:36', '17:40:37', '17:40:37', '17:40:37', '17:40:37', '17:40:37', '17:40:38', '17:40:38', '17:40:38', '17:40:38', '17:40:38', '17:40:39', '17:40:39', '17:40:39', '17:40:39', '17:40:39', '17:40:40', '17:40:40', '17:40:40', '17:40:40', '17:40:40', '17:40:41', '17:40:41', '17:40:41', '17:40:41', '17:40:41', '17:40:42', '17:40:42', '17:40:42', '17:40:42', '17:40:42', '17:40:43', '17:40:43', '17:40:43', '17:40:43', '17:40:43', '17:40:44', '17:40:44', '17:40:44', '17:40:44', '17:40:44', '17:40:45', '17:40:45', '17:40:45', '17:40:45', '17:40:45', '17:40:46', '17:40:46', '17:40:46', '17:40:46', '17:40:46', '17:40:47', '17:40:47', '17:40:47', '17:40:47', '17:40:47', '17:40:48', '17:40:48', '17:40:48', '17:40:48', '17:40:48', '17:40:49', '17:40:49', '17:40:56', '17:40:56', '17:40:56', '17:40:57', '17:40:57', '17:40:57', '17:40:57', '17:40:57', '17:40:58', '17:40:58', '17:40:58', '17:40:58', '17:40:58', '17:40:59', '17:40:59', '17:40:59', '17:40:59', '17:40:59', '17:41:00', '17:41:00', '17:41:00', '17:41:00', '17:41:00', '17:41:01', '17:41:01', '17:41:01', '17:41:01', '17:41:01', '17:41:02', '17:41:02', '17:41:02', '17:41:02', '17:41:02', '17:41:03', '17:41:03', '17:41:03', '17:41:03', '17:41:03', '17:41:04', '17:41:04', '17:41:04', '17:41:04', '17:41:04', '17:41:05', '17:41:05', '17:41:05', '17:41:05', '17:41:05', '17:41:06', '17:41:06', '17:41:06', '17:41:06', '17:41:06', '17:41:07', '17:41:07', '17:41:07', '17:41:07', '17:41:07', '17:41:08', '17:41:08', '17:41:08', '17:41:08', '17:41:08', '17:41:09', '17:41:09', '17:41:09', '17:41:09', '17:41:09', '17:41:10', '17:41:10', '17:41:10', '17:41:10', '17:41:10', '17:41:11', '17:41:11', '17:41:11', '17:41:11', '17:41:11', '17:41:12', '17:41:12', '17:41:12', '17:41:12', '17:41:12', '17:41:13', '17:41:13', '17:41:13', '17:41:13', '17:41:13', '17:41:14', '17:41:14', '17:41:14', '17:41:14', '17:41:14', '17:41:15', '17:41:15', '17:41:15', '17:41:15', '17:41:15', '17:41:16', '17:41:16', '17:41:16', '17:41:16', '17:41:16', '17:41:17', '17:41:17', '17:41:17', '17:41:17', '17:41:17', '17:41:18', '17:41:18', '17:41:18', '17:41:18', '17:41:18', '17:41:19', '17:41:19', '17:41:19', '17:41:19', '17:41:19', '17:41:20', '17:41:20', '17:41:20', '17:41:20', '17:41:20', '17:41:21', '17:41:21', '17:41:21', '17:41:21', '17:41:21', '17:41:22', '17:41:22', '17:41:22', '17:41:22', '17:41:22', '17:41:23', '17:41:23', '17:41:23', '17:41:23', '17:41:23', '17:41:24', '17:41:24', '17:41:24', '17:41:24', '17:41:24', '17:41:25', '17:41:25', '17:41:25', '17:41:25', '17:41:25', '17:41:26', '17:41:26', '17:41:26', '17:41:26', '17:41:26', '17:41:27', '17:41:27', '17:41:27', '17:41:27', '17:41:27', '17:41:28', '17:41:28', '17:41:28', '17:41:28', '17:41:28', '17:41:29', '17:41:29', '17:41:29', '17:41:29', '17:41:29', '17:41:30', '17:41:30', '17:41:30', '17:41:30', '17:41:30', '17:41:31', '17:41:31', '17:41:31', '17:41:31', '17:41:31', '17:41:32', '17:41:32', '17:41:32', '17:41:32', '17:41:32', '17:41:33', '17:41:33', '17:41:33', '17:41:33', '17:41:33', '17:41:34', '17:41:34', '17:41:34', '17:41:34', '17:41:34', '17:41:35', '17:41:35', '17:41:35', '17:41:35', '17:41:35', '17:41:36', '17:41:36', '17:41:36', '17:41:36', '17:41:36', '17:41:37', '17:41:37', '17:41:37', '17:41:37', '17:41:37', '17:41:38', '17:41:38', '17:41:38', '17:41:38', '17:41:38', '17:41:39', '17:41:39', '17:41:39', '17:41:39']
t = ydata
t.reverse()
ax.step(d, t, label="0xff1200")
ax.set_yticks(timeTicks, timeTicks)
ax.set_ylabel('Time (hh:mm:ss)')
ax.set_xticks([-100, -50, 0, 50, 100], ['-100', '-50', '0', '50', '100'], fontsize=fontSize)
plt.show()
The tick marks of the plot are not in the correct order, they show up like this:
17:40:20
17:40:30
17:40:50
17:40:40
17:41:00
17:41:10
17:41:20
17:41:30
17:41:39
I have seen this answer here, but this question is really about data that isn't in order.
According to matplotlib documentation that the step
plot of matplotlib plots the data in the order that it was received and doesn't attempt to re-order the data.
So why do the tick marks show up in the wrong order?
Update
If I comment out the d.reverse()
and t.reverse()
lines then the tick labels are really messed up.
17:40:20
17:40:30
17:40:50
17:41:39
17:41:30
17:41:20
17:41:10
17:41:00
17:40:40
Shouldn't tick marks/labels stay in the order that they are set to in set_yticks()
?