ggplotly:如何使用stat_smooth返回日期?

时间:2018-03-18 23:24:14

标签: r ggplot2 ggplotly r-plotly

我试图绘制组的累积总和,并为每个组添加相应的线性预测线。情节结果很好,但是,我无法读取x轴上预测斜率的日期,因为这些是数字。

如何更改下面的代码,以便<input matInput type="number" min="0" [attr.max]="totalOrders" placeholder="Total Skybridge Orders" formControlName="totalSkybridge" (change)="onTotalSkybridgeOrders($event)" 返回日期而不是数字?

stat_smooth

编辑:这是生成上图的一些代码。

g <- ggplot(aes(x = created_at_day, y = sum, color = groups), data= df) +
  geom_line() +
  stat_smooth(aes(x = as.Date(created_at_day), y = sum, color = groups), method = "lm", fullrange = TRUE, se = FALSE, size = 0.1) + 
  xlab('Date') + 
  ylab('cumulative sum of patients') + 
  expand_limits(x = as.Date(c("2017-11-13", "2018-04-01"))) +
  ggtitle('Number of patients included per practice') +
  theme_bw()
g
ggplotly(g)

0 个答案:

没有答案