【问题标题】:replicate plot() using ggplot()使用 ggplot() 复制 plot()
【发布时间】:2019-06-20 16:12:35
【问题描述】:

请参阅使用标准plot() 函数与ggplot() 函数的附图。

我目前正在使用theme() 尝试复制plot() 背景/面板和一般外观等,但我无法完全正确。

我试过了:

theme_update(panel.background = element_rect(fill = "white", colour = "grey50"))

但这并不是我想要的,每当我重新启动 RStudio 时,它都会恢复为灰色背景......

任何有用的指针将不胜感激。

谢谢

【问题讨论】:

  • 包 ggthemes 有theme_base,我想你只需要在geom_point() 中为空心点添加 shape = 1。

标签: r ggplot2


【解决方案1】:

根据我的评论,我提供了一个使用钻石数据集的可重现示例:

library(ggplot2)
library(ggthemes)

set.seed(100)
mydata <- diamonds[sample(nrow(diamonds), 100), ]   

ggplot(data = mydata, aes(x = carat, y = price)) +
  geom_point(shape = 1) +
  theme_base()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 2023-01-14
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 2021-11-26
    相关资源
    最近更新 更多