我正在使用R、shiny和plotly尝试构建交互式用户界面。基本上,我有一个数据集dest
,它有两列Date
和price
。这是一个基本的折线图:
ay <- list(
showticklabels = TRUE,
overlaying = "y",
side = "right",
title = "Benchmark price")
p<-plot_ly(dset, x = ~Date,y= ~Price,type = 'scatter',mode ='lines',marker=list(size = 10),name=paste0(input$select_bench," as of ",input$benchdate)) %>% layout(xaxis = ax, yaxis2 =ay)
p<-add_trace(p,x=~bDate,y=~bPrice,type = 'scatter',mode = 'lines',marker=list(size = 10),name=paste0(input$select_bench," as of ",input$benchdate),textposition = 'middle right',yaxis="y2")}
layout(p,legend = list(orientation = 'h'),title = 'Commodity Price Trending')
我正在使用
legend = list(orientation = 'h')
我希望把图例放在底部,但是这样做会导致右边的第二个轴数值与标签重叠,只显示数字的一部分,例如它只显示5而不是59。
我认为应该有一个参数来调整显示区域的默认边距 - 但我尝试了很多谷歌搜索都没有找到任何东西。