R - 情节隐形线

时间:2017-09-07 17:56:08

标签: r plotly

我有一个数据集,其中包含变量Name(factor),Count(整数)和Time(POSIXct)。

我正在使用以下代码:

    df %>% plot_ly(x=~Time,y = ~Count,group = ~Name,color=~Name,type='scatter',
mode='lines+markers')

发生的事情是线条根本没有出现(标记看起来很完美)。将模式更改为“行”会使数据不可见,但只要我将指针悬停在数据位置上,信息就会出现。

另请注意,在没有组的情况下运行会产生所需的结果(线条可见)

        df %>% plot_ly(x=~Time,y = ~Count,type='scatter',
mode='lines+markers')

有什么问题?如何使线条可见?

1 个答案:

答案 0 :(得分:2)

您是否尝试取消数据集分组?它对我有用。

df %>% 
   ungroup() %>%
   plot_ly(x=~Time,y = ~Count,type='scatter', mode='lines+markers')