【问题标题】:Shiny with plotly闪闪发光
【发布时间】:2015-09-03 14:49:00
【问题描述】:

我正在创建一个有光泽的笔记本,我在 plotly 使用插件时发现了以下问题:

Data_xts=Data_xts()  #this return a reactive data.frame. fm_timeseries is already formated as POSIXct and has the following format : YYYY-MM-DD hh:mm:ss
plot_ly(x=Data_xts$fm_timeseries, y = Data_xts$Open,name='Stock Prices',showlegend = FALSE) %>%
add_trace(x=Data_xts$fm_timeseries, y = Data_xts$UKX_open, yaxis='y2') %>%
add_trace(x=Data_xts$fm_timeseries, y = Data_xts$TotalNews, yaxis='y3') %>%
layout(yaxis=list(title='Stock Price'),
yaxis2=list(title='Market Index', overlaying = "y",side='right',position=.97,tickfont = list(size = 8)), 
yaxis3=list(title='Total News', overlaying = "y",side='right',anchor='free', tickfont = list(size = 8),position=1),
xaxis=list(title='Time Series') , showlegend = TRUE)

这是我正在创建的几个问题:

  • 时间戳不显示为时间戳(我什至尝试了 plotly 和 R 中的简单示例,并验证它不适用于 Shiny)。事实上,时间戳被归类为字符串,因此无法看到 xaxis 标题。
  • 挑战使 yaxis2 和 3 在相同的轴上而不与图表本身重叠。

为了解决这个问题,我们是否可以将格式传递给 xaxis(尝试过type='date',但没有成功)以及右侧 y 轴上是否有任何类型的自动排列(2 和 3 )。

【问题讨论】:

标签: r timestamp shiny rstudio plotly


【解决方案1】:

尝试使用“因子”。 所以在你的例子中:

plot_ly(x= ~factor(Data_xts$fm_timeseries), y = ~Data_xts$Open, name='Stock Prices',showlegend = FALSE)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-07
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多