【问题标题】:number instead of date on the density plot in RR中密度图上的数字而不是日期
【发布时间】:2018-10-13 00:40:19
【问题描述】:

我有问题。我正在尝试使用 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)

【问题讨论】:

    标签: r plotly density-plot r-plotly ggplotly


    【解决方案1】:

    基于此:how to choose variable to display in tooltip when using ggplotly?

    你可以试试这个:

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

    【讨论】:

    • 太好了,这正是我要找的,谢谢!我还有一个问题,如何去除情节的黑色边框?
    • 你可以使用geom_density(stat="identity", fill = "#4156C5", size = 0)中的颜色(color = "white")或大小。
    猜你喜欢
    • 2014-10-08
    • 1970-01-01
    • 2015-09-27
    • 2020-02-05
    • 2020-03-11
    • 2022-10-24
    • 2012-09-21
    • 1970-01-01
    • 2019-10-02
    相关资源
    最近更新 更多