我正在使用R-Markdown和Tufte模板编写报告。我在报告中嵌入了Shiny应用程序。
到目前为止,我已经尝试在chunck选项中使用“ fig.width =”和“ width =”,但无济于事,然后尝试了“,
options = list(height = 600)“,正如B. Davis change dimensions of shiny app embedded in r markdown HTML建议的那样,在右括号之前,并且再次没有变化。
hist_dist <- read.csv("hist_dist2.csv", check.names = FALSE)
inputPanel(
selectInput("dist", label = "Choose an ecosystem to explore historical disturbance regimes:", choices = hist_dist$`Ecosystem`, selected = "Northern Hardwoods Forest" , width = '70%')
)
renderPlotly({
ggplot(filter(hist_dist, Ecosystem == input$dist), aes(x=Disturbance, y=Acres)) +
geom_bar(stat="identity", fill = "darkslategrey") +
coord_flip() +
theme(legend.position='none') +
expand_limits(y=c(0, 60)) +
theme_bw() +
theme(panel.background = element_rect(colour = "grey", fill=NA, size=1),
text = element_text(family = "serif", size = 14),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black")
)
}
)
'''
I am able to change the width if I use other templates (non-Tufte), and are able to control the size of figures, just not Shiny apps.
答案 0 :(得分:0)
我经历过同样的情况。 Tufte_html在幕后具有覆盖宽度。
这是我的解决方案。不是最好的,但是有效。基本上,您需要为图分配ID,然后从CSS更改样式。
编辑 output $ my_plotly <-renderPlotly(❴❵)
添加 plotlyOutput(“ my_plotly”)在同一块中。
用
编写styles.css #my_plotly ❴ width: 55% !important❵
我相信Tufte风格使用了55%。