【问题标题】:ggplot, scatterplot over an imageggplot,图像上的散点图
【发布时间】:2021-08-21 01:56:24
【问题描述】:

我正在寻找一种方法来绘制具有预定义字段的图像并获得如下结果:

我想从以下位置构建它:

(1): 带有预定义 x 和 y 限制的字段的 PNG 图像,如下所示:

(2):散点图,例如:

mpg %>% 
ggplot() + 
  geom_point(mapping = aes(x = displ, y = hwy, color = class))

问题: 我该怎么做,理想情况下引用/修复字段限制到它们的 x 和 y 值?问候!

【问题讨论】:

    标签: r ggplot2 scatter ggimage


    【解决方案1】:

    我认为您有两个基本选择。

    首先您可以定义一个自定义主题。您也许可以使用其中一个主题包。例如ggthemr.

    第二个可能更好的是,添加自定义曲线,最初可能需要更多的工作,具体取决于弯曲程度。但最终会更加灵活。 https://ggplot2.tidyverse.org/reference/geom_segment.html

    第三个可能更好 geom_path() https://ggplot2.tidyverse.org/reference/geom_path.html

    第四次使用来自ggforce 的多边形。 https://luisdva.github.io/rstats/Grouping-points/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-30
      • 2014-11-20
      • 1970-01-01
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 2015-08-02
      相关资源
      最近更新 更多