【发布时间】:2022-01-05 11:51:57
【问题描述】:
我需要展示几个月和几年的数据。 我的数据是:
我的代码是
import plotly.offline as pyo
import plotly.graph_objs as go
pyo.init_notebook_mode()
#tweets['Time'] = pd.to_datetime(tweets['timestamp'])
tweets['Time'] = pd.to_datetime(tweets['timestamp']).dt.normalize()
tweetsT = tweets['Time']
trace = go.Histogram(
x=tweetsT,
marker=dict(
color='blue'
),
opacity=0.75
)
layout = go.Layout(
title='Tweet Activity Over Years',
height=450,
width=1200,
xaxis=dict(
title='Month and year'
),
yaxis=dict(
title='Tweet Quantity'
),
bargap=0.2,
)
data = [trace]
fig = go.Figure(data=data, layout=layout)
fig.show(renderer="colab")
我的图表如下所示:
但我需要这个:
我不明白,有什么问题。谢谢
【问题讨论】:
-
你能不能也把数据加到列表里去?
-
@OrangoMorango,第一张图片是我的数据样本。