Plotly R-无法调整配色栏的方向
我正在尝试在具有水平方向的配色栏的闪亮应用程序中创建一个散点图。基于我阅读
经过多次尝试和调整,我找不到一种使配色栏水平显示的方法。
任何帮助将不胜感激。
使用虹膜数据集的最小示例:
library(shiny)
ui <- fluidPage(
plotlyOutput("Scatter")
)
server <- function(input, output) {
ScatterPlot<-reactive({
plot_ly(
iris,
type='scatter',
mode='lines+markers'
)%>%
add_trace(
x=~Sepal.Length,
y=~Sepal.Width,
mode='markers',
marker=list(
color=~Petal.Length,
coloraxis='coloraxis'
)
)%>%
layout(
showlegend=FALSE,
margin=list(b=50),
coloraxis=list(
colorbar=list(
orientation="h"
)
)
)
}
)
output$Scatter<-renderPlotly({ScatterPlot()})
}
shinyApp(ui = ui, server = server)
I am trying to create a scatterplot within a Shiny App that has a colorbar with a horizontal orientation. Based on my reading of the Plotly reference it appears that the orientation of a colorbar can be adjusted within Layout/Coloraxis/Colorbar by setting orientation="h".
After many attempts and tweaks I can not find a way to get the colorbar to be displayed horizontally.
Any help would be appreciated.
Minimal example using the iris dataset:
library(shiny)
ui <- fluidPage(
plotlyOutput("Scatter")
)
server <- function(input, output) {
ScatterPlot<-reactive({
plot_ly(
iris,
type='scatter',
mode='lines+markers'
)%>%
add_trace(
x=~Sepal.Length,
y=~Sepal.Width,
mode='markers',
marker=list(
color=~Petal.Length,
coloraxis='coloraxis'
)
)%>%
layout(
showlegend=FALSE,
margin=list(b=50),
coloraxis=list(
colorbar=list(
orientation="h"
)
)
)
}
)
output$Scatter<-renderPlotly({ScatterPlot()})
}
shinyApp(ui = ui, server = server)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论