Twitter数据 - 如何使用plotly -R修改堆积条形图中的y轴

时间:2020-12-27 15:00:19

With this dataset https://github.com/frm1789/Project_Dante2018/blob/master/cc2.csv It shows for each day, and each hour, the n-tweets made with a particular hashtag.

使用此数据集https://github.com/frm1789/Project_Dante2018/blob/master/cc2.csv它显示每天和每小时使用特定主题标签创建的n-tweets。

  • day: day of the week.

    日:星期几。

  • hour_only: hour of the day.

    hour_only:一天中的小时。

  • n: total of tweets for that hour.

    n:该小时的推文总数。

  • nn: total of tweets for that day.

    nn:当天的推文总数。

  • n_pc: percentage of the tweets for hour/day.

    n_pc:小时/天推文的百分比。

Using this code:

使用此代码:

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")
) 

I would like to obtain all the rows with the same space, because each space in each row represents an hour. And also, I would like to setup up the y-axis from 0 to 24.

我想获得具有相同空间的所有行,因为每行中的每个空格代表一个小时。而且,我想设置从0到24的y轴。

My results by now are: Twitter数据 - 如何使用plotly -R修改堆积条形图中的y轴

我现在的结果是:

I understand that I am very close, but I don't know how to modify my graph. Or even if the entire idea is wrong.

我知道我非常接近,但我不知道如何修改我的图表。或者即使整个想法都是错误的。

1 个解决方案

#1


0  

Are you after something like this?

你喜欢这样的事吗?

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")
  ) 

Twitter数据 - 如何使用plotly -R修改堆积条形图中的y轴


Note: You might want to rethink your y-axis label since y here is the time of the day, and not the quantity of tweets. Your color labelling, I believe, takes care of the percentage of tweets in a specific hour.

注意:您可能需要重新考虑您的y轴标签,因为这里的y是一天中的时间,而不是推文的数量。我相信,您的颜色标签会照顾特定小时内推文的百分比。

#1


0  

Are you after something like this?

你喜欢这样的事吗?

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")
  ) 

Twitter数据 - 如何使用plotly -R修改堆积条形图中的y轴


Note: You might want to rethink your y-axis label since y here is the time of the day, and not the quantity of tweets. Your color labelling, I believe, takes care of the percentage of tweets in a specific hour.

注意:您可能需要重新考虑您的y轴标签,因为这里的y是一天中的时间,而不是推文的数量。我相信,您的颜色标签会照顾特定小时内推文的百分比。