简体   繁体   English

ggplot 箱线图标签不显示

[英]ggplot boxplot labels not showing

I am creating a boxplot and can get the plot to show, but the x and y axis ticks and labels do not show up.我正在创建一个箱线图,可以显示 plot,但 x 轴和 y 轴刻度和标签没有显示。 This occurs with my own data as well as with example data.我自己的数据和示例数据都会出现这种情况。 Here is the example data (from http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/ :这是示例数据(来自http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/

bp <- ggplot(PlantGrowth, aes(x=group, y=weight)) +
  geom_boxplot()
bp

And the resulting figure结果图

来自示例数据的图

Setting the discrete x axis doesn't change anything either设置离散的 x 轴也不会改变任何东西

bp + scale_x_discrete(limits=c("trt1","trt2","ctrl"))

results in changing the order of the boxplots but no labels show.结果改变了箱线图的顺序但没有标签显示。 Why aren't the ticks and labels showing up and how do I get them to show?为什么刻度和标签不显示,我如何让它们显示?

Question was solved in the comments by @chemdork123 but wanted to post the answer here to close the question. @chemdork123 在评论中解决了问题,但想在此处发布答案以关闭问题。 I uninstalled all of the packages but the base and recommended packages, following the instructions found here https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/ .我按照此处https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/中的说明卸载了除基本和推荐包之外的所有包。 After uninstalling all packages, I reinstalled ggplot2 and the captions appeared.卸载所有包后,我重新安装ggplot2 ,出现了字幕。 After reinstalling each previous problem one by one I learned ggtern was the issue here.在一个一个地重新安装之前的每个问题之后,我了解到ggtern是这里的问题。 Removing ggtern and reinstalling ggplot2 again fixed the issue and code runs perfectly.删除ggtern并重新安装ggplot2再次解决了问题,代码运行完美。

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

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