简体   繁体   English

与 flexdashboard 一起使用后,ggiraph::girafe() output 的大小与 RStudio 查看器上的文档不一致

[英]Sizing of ggiraph::girafe() output is not consistent with documentation on RStudio viewer after use with flexdashboard

I have a number of plots using {ggplot2} and {ggiraph} that I have consolidated into a {flexdashboard}我有许多使用 {ggplot2} 和 {ggiraph} 的图,我已将它们合并到 {flexdashboard}

Before attempting to display them with the dashboard, these plots displayed correctly on RStudio's viewer using the sizing option width = 0.7在尝试使用仪表板显示它们之前,这些图在 RStudio 的查看器上正确显示,使用尺寸选项width = 0.7

However, they do not display on the dashboard (just a blank panel), and now produce a blank panel if run directly in RStudio.但是,它们不会显示在仪表板上(只是一个空白面板),如果直接在 RStudio 中运行,现在会生成一个空白面板。 After some investigation it seems that some setting has changed and that the charts are not output because the size is inconsistent with the window.经过一番调查,似乎某些设置已更改,并且图表不是 output,因为尺寸与 window 不一致。

If I change the width setting to 10 it displays correctly in the RStudio viewer which seems odd.如果我将宽度设置更改为 10,它会在 RStudio 查看器中正确显示,这看起来很奇怪。

I have a small reprex here:我在这里有一个小代表:

library(ggplot2)
library(ggiraph)

#dummy dataframe
df <- data.frame(
  x = seq.Date(Sys.Date() - 30, Sys.Date() - 1, by = "days"),
  y = runif(30, 0, 2) 
)

p <- ggplot2::ggplot(df, (aes(x,y)))+
  geom_point_interactive(aes(tooltip = x, data_id = x))


plot <- girafe(ggobj = p, 
                width =0.7)

print(plot)

This produces the following output:这将产生以下 output:

宽度设置为 0.7

However if I adjust width setting to 10但是,如果我将宽度设置调整为 10

plot <- girafe(ggobj = p, 
                width =10)

print(plot)

I get the following:我得到以下信息:

宽度设置为 10

This seems inconsistent with the documentation for {ggiraph}, is there some graphics setting that has been modified by {flexdashboard}?这似乎与 {ggiraph} 的文档不一致,是否有一些图形设置已被 {flexdashboard} 修改? I've tried interactive (js) charts with {plotly} and {echarts4r} on {flexdashboard} output which don't show the same behaviour.我已经在 {flexdashboard} output 上尝试了带有 {plotly} 和 {echarts4r} 的交互式(js)图表,它们没有显示相同的行为。

I'm using RStudio 1.4.1103 R version 4.0.2 System: x86_64-apple-darwin17.0我正在使用 RStudio 1.4.1103 R 版本 4.0.2 系统:x86_64-apple-darwin17.0

I've been experimenting and it seems that I can control the output by using width_svg consistently.我一直在试验,似乎我可以通过一致地使用width_svg来控制 output。

I still don't know why there is an issue but I suspect some underlying graphics setting.我仍然不知道为什么会出现问题,但我怀疑一些底层图形设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM