带有HH的条图:MM:X轴中的SS
我在python中有以下字符串(有很多):
date = "00:01:43"
代表小时:: minute :: seconds。这来自读取包含许多日期的CSV文件。
现在,我需要构造我正在从CSV到某种数组的内容,然后将其用于bar绘图(matloblib.bar),因为x轴
问题是我如何准备我正在阅读的日期条图:
with open('file.csv','r')
for line in file:
time = line.split(',')[0] ## this is read like "HH:MM:SS"
temp = line.split(',')[1] ## this is read like "Float as a string"
tempArray.append(float(temp))
问题
如何将时间汇总到阵列中以在以下内容中使用: plt.bar(Timearray,temparray)
,X轴仍将显示“ HH:MM:SS”格式。
I have the following string in Python (got many of those):
date = "00:01:43"
which represents the hour::minute::seconds. This comes from reading a csv file which contains many of those date.
Now I need to construct those I am reading from csv to some sort of array and then use it for a bar plot (matloblib.bar) as the x-axis
The question is how do I prepare the dates I am reading to be used in a bar plot:
with open('file.csv','r')
for line in file:
time = line.split(',')[0] ## this is read like "HH:MM:SS"
temp = line.split(',')[1] ## this is read like "Float as a string"
tempArray.append(float(temp))
QUESTION
How do I assembly the time into an array to then be used in the following:
plt.bar(timeArray, tempArray)
where the x-axis would still show "HH:MM:SS" format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于看起来您已经创建了一个临时数据列表,因此您只需为时间数据创建另一个列表即可。
然后,使用ax.set_xticks({temp_data_list},{time_data_list})将它们分组在一起。
Since it looks like you have create a list for temp data, then you can just create another list for time data.
Then use ax.set_xticks({temp_data_list}, {time_data_list}) to group them together.