带有HH的条图:MM:X轴中的SS

发布于 2025-02-06 04:49:28 字数 580 浏览 0 评论 0原文

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花落人离去 2025-02-13 04:49:30

由于看起来您已经创建了一个临时数据列表,因此您只需为时间数据创建另一个列表即可。
然后,使用ax.set_xticks({temp_data_list},{time_data_list})将它们分组在一起。

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.

ax.set_xticks({temp_data_list}, {time_data_list})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文