Ich habe mehrere Tortengrafiken von Plotly in meiner Shiny App und ich kann sie nicht so bewegen, dass sie in dieselbe Reihe passen. Ich kann sie verschieben, indem ich entweder die Position in einer .css-Datei ändere oder absolutePanel() benutze, aber jede Option lässt mich mit einem riesigen Klumpen Leerraum am unteren Rand zurück. Ich kann keinen Code von meiner App aus posten, also habe ich ein kleineres Beispiel gemacht, in dem ich versucht habe, mit der column() -Funktion umzusteigen, ohne Erfolg. Jede Hilfe wäre willkommen. In meiner tatsächlichen App habe ich etwa 5 Grafiken, so dass die Menge an Leerraum ist sehr groß und ich möchte es auflösen. Es könnte eine einfache Antwort, aber mit mir tragen Jungs einen newb Im ...Wie werden zwei Plot-Graphen in eine Zeile eingefügt?
library(shiny)
library(plotly)
ui = fluidPage(
plotlyOutput("graph1",width="40%",height="350px"),
column(width=12,offset=4,plotlyOutput("graph2",width="40%",height="350px"))
)
server = function(input, output,session) {
output$graph1<-renderPlotly({
USPersonalExpenditure <- data.frame("Categorie"=rownames(USPersonalExpenditure), USPersonalExpenditure)
data <- USPersonalExpenditure[,c('Categorie', 'X1960')]
p <- plot_ly(data, labels = ~Categorie, values = ~X1960, type = 'pie') %>%
layout(title = 'Graph 1',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
output$graph2<-renderPlotly({
USPersonalExpenditure <- data.frame("Categorie" = rownames(USPersonalExpenditure), USPersonalExpenditure)
data <- USPersonalExpenditure[, c('Categorie', 'X1960')]
colors <- c('rgb(211,94,96)', 'rgb(128,133,133)', 'rgb(144,103,167)', 'rgb(171,104,87)', 'rgb(114,147,203)')
p <- plot_ly(data, labels = ~Categorie, values = ~X1960, type = 'pie',
textposition = 'inside',
textinfo = 'label+percent',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~paste('$', X1960, ' billions'),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1)),
#The 'pull' attribute can also be used to create space between the sectors
showlegend = FALSE) %>%
layout(title = 'Graph 2',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
}
# Run the application
shinyApp(ui = ui, server = server)
Vielen Dank, ich wusste, dass es so einfach sein würde. Viel verpflichtet joelnNc –