Ich habe einige Schwierigkeiten mit plotly
. Ich möchte plotly
als pdf herunterladen können. Doch während einige x- und y-Achse Parameter zu meinem Code hinzufügen (Ursache, wenn ich übertragen ggplot
-plotly
, Titel von x und y-Achse geschnitten)GGPlotly: downloadHandler geben leeres Grundstück
Dieser Code arbeitet pdf-Datei zum Download:
library(shiny)
library(DT)
library(ggplot2)
library(plotly)
shinyApp(
ui = fluidPage(
fluidRow(downloadButton('downloadplot',label='Download Plot')),
plotlyOutput('plot1')
),
server = function(input, output) {
testplot <- function(){
a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), y = mpg,fill = interaction(cyl, carb, lex.order = T))) +
geom_boxplot()
}
output$plot1 <- renderPlotly({testplot()})
output$downloadplot <- downloadHandler(
filename ="plot.pdf",
content = function(file) {
pdf(file, width=12, height=6.3)
print(testplot())
dev.off()
})})
und Zugabe dieser Code die Titel des ggplotly
zu beheben fehlschlägt:
a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), y = mpg,fill = interaction(cyl, carb, lex.order = T))) +
geom_boxplot()
p <- ggplotly(a + ylab(" ") + xlab(" "))
x <- list(
title = "[x]"
)
y <- list(
title = "[y]"
)
p %>% layout(xaxis = x, yaxis = y)}
ein leeres Grundstück gibt ...
Danke für jede Hilfe!
Aber wo genau sollte ich verwenden 'return (a)' ..Than i für if-Anweisung verwenden müssen 'downloadHandler' –
Wenn Sie plotly haben user_name etc können Sie' plotly_IMAGE' dafür. oder Sie müssen eine andere Funktion für plotly und eine für pdf ggplot verwenden – Batanichek
Ich habe plotly user_name nicht. Das Problem mit "plotly" ist, dass ich den ** plotty download image button ** im Internet Explorer nicht benutzen kann, deshalb ist die einzige Lösung, 'downlaodHandler' hinzuzufügen, die mir pdf-Datei geben wird –