[英]Twitter Data - how to modify y-axis in stacked bar using plotly - R
使用此数据集https://github.com/frm1789/Project_Dante2018/blob/master/cc2.csv它显示了每天和每小时用特定标签生成的n条推文。
day
:星期几。
hour_only
:一天中的小时。
n
:该小时的总推文数。
nn
:当天的总推文。
n_pc
:小时/天的tweet百分比。
使用此代码:
cc2 %>%
plot_ly(x = ~cc2$day, y = ~(n_pc), color = ~n_pc, hoverinfo = 'y'
) %>%
##add_bars(colors = rainbow) %>%
layout(barmode = "stack",
title = 'In what moment of the day, people tweet about #Dante2018',
xaxis = list(title = "Days of the week"),
yaxis = list(title = "Q - Quantity of tweets")
)
我想获得具有相同空间的所有行,因为每行中的每个空间代表一个小时。 另外,我想将y轴设置为0到24。
现在我的结果是:
我了解自己非常亲密,但是我不知道如何修改图形。 甚至整个想法是错误的。
你是在追求这样的东西吗?
library(plotly)
cc2 %>%
plot_ly(x = ~(day), y = ~(hour_only / hour_only), color = ~n_pc, hoverinfo = 'text',
text = ~paste('Hour of the day: ', hour_only)
) %>%
##add_bars(colors = rainbow) %>%
layout(barmode = "stack",
title = 'In what moment of the day, people tweet about #Dante2018',
xaxis = list(title = "Days of the week"),
yaxis = list(title = "Q - Quantity of tweets")
)
注意 :由于y
是一天中的时间,而不是tweet的数量,因此您可能需要重新考虑y轴标签。 我相信,您的颜色标签会处理特定小时内的鸣叫百分比。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.