【问题标题】:Plotting a Time/Value graph in Python using matplotlib使用 matplotlib 在 Python 中绘制时间/值图
【发布时间】:2021-05-28 02:26:49
【问题描述】:

在我的软件中,人们会输入一个时间和一个能耗值。该元组的条目数量将与用户想要的一样多,因此图表需要灵活。例如:

[('12:25', 98.0), ('13:48', 96.3), ('14:47', 85.0), ('16:25', 88.1), ...]

我已经得到了这部分。用户在屏幕上输入数据,我做了一些数据检查,过滤,结果是一个类似上面的列表。现在,我需要将此列表绘制成图表。

谢谢你,祝你有美好的一天。 :)

【问题讨论】:

标签: python list matplotlib plot graph


【解决方案1】:

这对我有用。现在我要看看如何添加标签和东西。 :)

import matplotlib.pyplot as plt

def plot_graph(times, values):
    """ Plots the graph. """
    fig, ax = plt.subplots()
    plt.plot(times, values)
    ax.xaxis.set_tick_params(rotation=30, labelsize=10)

    plt.show()

【讨论】:

    猜你喜欢
    • 2010-12-07
    • 1970-01-01
    • 2015-12-20
    • 2020-03-31
    • 2016-02-14
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    • 1970-01-01
    相关资源
    最近更新 更多