R-闪亮的第二轴标签与y轴值重叠

时间:2017-02-28 03:27:40

标签: r shiny plotly

我正在使用R,有光泽并且正在尝试构建交互式用户界面。基本上,我有一个数据集dest,它有两列Dateprice。这是一个基本的线图:

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。

我认为应该有一个参数来调整显示区域的默认边距 - 但尝试了谷歌搜索没有找到任何东西。

1 个答案:

答案 0 :(得分:0)

您可以在yaxis2中使用refs/tags/*:refs/tags/*

尝试一下:

automargin = T

这里的输出图: plot