0

我似乎遇到了与前面描述的相同的问题将 ggtern 附加到 ggplot2 时,我收到此消息:

以下对象被“package:ggplot2”屏蔽:

%+%, aes, annotate, calc_element, ggplot, ggplot_build, ggplot_gtable, ggplotGrob,
ggsave, layer_data, theme, theme_bw, theme_classic, theme_dark, theme_gray,
theme_light, theme_linedraw, theme_minimal, theme_void

2016 年的解决方案是更新到 ggtern 的 2.1.4 版,但是,我现在使用 ggtern 的 3.1.0 版(以及 ggplot2 的 3.3.0 版)。关于我可能做错了什么的任何想法?

4

1 回答 1

1

每当你有一个被屏蔽的对象时,你总是可以用一个合格的调用来指向那个对象(例如,使用ggplot2::theme_bw())。

要亲自查看,请加载library(ggplot2)library(ggtern)(按此顺序)。正如您所指出的,此功能因此被掩盖ggplot2。在我下面使用的情况下,这些变化很小,但它说明了这一点。

仔细比较以下两行代码的输出,您可以看到差异(我认为主要是在轴刻度的默认大小上):

不合格的电话。 此代码使用theme_bw()from ggtern,因为ggplot2::theme_bw()被屏蔽:

ggplot2(iris, aes(x=Sepal.Length, y=Sepal.Width)) + 
    geom_point() + theme_bw()

合格的通话。 此代码从以下位置调用该方法ggplot2

ggplot2(iris, aes(x=Sepal.Length, y=Sepal.Width)) + 
    geom_point() + ggplot2::theme_bw()
于 2020-03-25T17:33:21.517 回答