简体   繁体   English

R/ggiraph:Plot 被截断

[英]R/ggiraph: Plot truncated

Trying to learn ggiraph, experimenting with basic examples.尝试学习 ggiraph,尝试基本示例。

I'm using R 4.0.2 and RStudio 1.3.1073, both freshly downloaded & updated on my Win10 machine.我正在使用 R 4.0.2 和 RStudio 1.3.1073,它们都是在我的 Win10 机器上新下载和更新的。

library( tidyverse )
library( ggiraph )

somePlot <- 
  mtcars %>% 
  mutate( carname = rownames( . ) ) %>% 
  ggplot( aes( x = wt, y = qsec, color=disp,
               tooltip = cyl, data_id=carname ) ) +
  geom_point_interactive( ) +
  theme_bw()

somePlot                     # Shows ggplot object as expected, no interactivity

girafe( ggobj = somePlot )   # Interactivity, but viewing window shows only about top 2/3 of plot

Links to images because I don't yet have enough reputation on StackOverflow to qualify for posting images:图片链接,因为我在 StackOverflow 上还没有足够的声誉来获得发布图片的资格:

ggplot object in zoomed viewing window ggplot object 放大查看 window

girafe object in zoomed viewing window 长颈鹿 object 放大查看 window

For each image, I clicked "Zoom" in the RStudio plot-viewing window, then captured the image to a PNG file.对于每个图像,我在 RStudio 绘图查看 window 中单击“缩放”,然后将图像捕获为 PNG 文件。 Expanding the zoom window has no effect-- the ggiraph plot is still truncated at the same place.扩大缩放 window 没有效果 - ggiraph plot 仍然在同一个地方被截断。

If images don't appear: the somePlot call produces a graph as I expect... I can see the entire y axis as well as the x-axis and its labels.如果没有出现图像: somePlot调用会按我的预期生成一个图形......我可以看到整个 y 轴以及 x 轴及其标签。

The girafe... call produces the upper 2/3 or so of the graph... I cannot see the x-axis at all, and I cannot see the full extent of the y-axis. girafe...调用生成图形的上 2/3 左右... 我根本看不到 x 轴,也看不到 y 轴的全部范围。 The plotted points have the interactivity I expect when I hover over them.当我对它们进行 hover 时,绘制的点具有我所期望的交互性。

Any ideas about how I might fix this?关于如何解决这个问题的任何想法?

Simple fix as suggested by David Gohel: Resize the viewing window -- either the Viewer panel inside RStudio or the window that's opened with the Zoom button. David Gohel 建议的简单修复:调整查看 window 的大小 - RStudio 内的查看器面板或使用缩放按钮打开的 window。 In particular, change the aspect ratio of the viewing window to reveal more (or less) of the figure.特别是,更改查看 window 的纵横比以显示更多(或更少)的图形。

I guess I was expecting the viewing window to behave similarly to base graphics or ggplot, where the displayed image is sized to fit the viewing window, and resizes when the window is resized.我想我希望查看 window 的行为类似于基本图形或 ggplot,其中显示的图像大小适合查看 window,并在调整 window 大小时调整大小。

Instead, ggiraph appears to create the image at the size it likes, and if your viewing window doesn't match the aspect ratio of the figure, then some of the figure will spill out of the viewing window.相反,ggiraph 似乎以它喜欢的大小创建图像,如果您查看的 window 与该图的纵横比不匹配,则该图的某些部分将溢出查看 window。

Thanks.谢谢。

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

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