簡體   English   中英

hPlot R x軸標簽和xy對應關系

[英]hPlot R x-axis label and x-y correspondence

我有以下數據,並嘗試使用hPlot

hPlot(Numbers~Date, data = df, group='Type', type = "line", radius=6)


     Date        Type      Numbers
 2014-01-05     Type-1          16
 2014-01-12     Type-1          82
 2014-01-12     Type-2           2
 2014-01-19     Type-1         177
 2014-01-26     Type-1         270
 2014-01-26     Type-2           3
 2014-02-02     Type-1         381
 2014-02-09     Type-1         461
 2014-02-09     Type-2           4

我將多個日期作為x軸,如下圖所示。 我也嘗試過uniqueas.character但是x-data不對應於y-data。

在此輸入圖像描述

這是您的問題的解決方案。 您可以在此處查看圖表以及代碼。 我也在這里發帖

# don't switch to scientific notation, since we want date to be
# represented in milliseconds
options(scipen = 13)
dat = transform(df, Date2 = as.numeric(as.POSIXct(Date))*1000)

library(rCharts)
h1 <- hPlot(Numbers ~ Date2, data = dat, 
  group = 'Type', 
  type = "line", 
  radius=6
)
h1$xAxis(type = 'datetime', labels = list(
  format = '{value:%Y-%m-%d}'  
))
h1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM