我有一个我用 plotly 创建的情节。当我将它部署到我闪亮的应用程序时,X 和 Y 标签被切断,如下所示:
我怎样才能防止这种情况发生?如果我使用普通绘图,标签不会被截断,但我需要绘图是交互式的。
这是我创建情节的代码:
ui.r:
#creating app with shiny
library(shiny)
library(shinydashboard)
shinyUI(
dashboardPage(
dashboardHeader(title = "Dashboard"),
dashboardSidebar(
menuItem("Dashboard")
),
dashboardBody(
fluidPage(
box(plotlyOutput("bakePlot")),
box(plotOutput("bakeMonthly"))
)
)
)
)
服务器.r:
shinyServer(function(input, output){
output$bakePlot <- renderPlotly({
ggplot(sales_bakery, aes(ProductName, ProductSales))+
stat_summary(fun.y=sum,geom="bar",colour="red",fill="red",show.legend = FALSE) +
coord_cartesian(ylim = c(7000, 9500)) + ggtitle("January Sales in Bakery") +
xlab("Category") + ylab("Quantity Sold")+
theme(
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_text(angle = 60, hjust = 1),
axis.text.y = element_text(colour = "black", size = 14),
panel.background = element_rect(fill = "white"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.line = element_line(colour = "black", size = 1),
legend.position = "none",
plot.title = element_text(lineheight = 1.8, face = "bold"))
})