我有一个我用剧情创造的情节。当我将它部署到我的闪亮应用程序时,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"))
)
)
)
)
server.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"))
})
答案 0 :(得分:4)
您可以通过设置情节
的边距来解决此问题plot_ly(
...
) %>%
layout(
margin = list(b = 50, l = 50) # to fully display the x and y axis labels
)