R中密度图上的数字而不是日期

number instead of date on the density plot in R

我有问题。我正在尝试使用 plotly 包在 R 中绘制密度图。但是当我将鼠标悬停在绘图上时,我得到日期 17623 的数字格式而不是 2018-04-02。有解决这个问题的想法吗?

Date <- seq(as.Date(Sys.Date()-30), by=1, len=31)
Value <- runif(31)
dataTable <- data.frame(Date, Value)

density_plot = ggplot(dataTable, aes(x=Date, y = Value)) +
  geom_density(stat="identity", fill = "#4156C5") + 
  labs(fill = "Value", x = "Date", y = "Frequency")
ggplotly(density_plot)

基于此:

你可以试试这个:

density_plot = ggplot(dataTable, aes(x=Date, y = Value, label1= Date, label2 = Value)) +
  geom_density(stat="identity", fill = "#4156C5") + 
  labs(fill = "Value", x = "Date", y = "Frequency")

ggplotly(density_plot, tooltip = c("label1", "label2"))