R X和Y标签未出现在我的ggplot上

R X和Y标签未出现在我的ggplot上,r,ggplot2,plot,axis-labels,R,Ggplot2,Plot,Axis Labels,我可以将标题添加到图表中,但x和y标签不会显示。相反,我得到了一个底部计数的图例 pl <- ggplot(movies, aes(x = rating)) pl2 <- pl + geom_histogram(binwidth = 0.1, aes(fill = ..count..)) pl2 pl3 <- pl2 + xlab('Movie Rating') + ylab('Count') pl3 pl3 + ggtitl

我可以将标题添加到图表中,但x和y标签不会显示。相反,我得到了一个底部计数的图例

    pl <- ggplot(movies, aes(x = rating))

    pl2 <- pl + geom_histogram(binwidth = 0.1, aes(fill = ..count..))
    pl2
    pl3 <- pl2  + xlab('Movie Rating') + ylab('Count')
    pl3
    pl3 + ggtitle('MY TITLE')
以下是指向该图的imgur链接:


我做错了什么?

看起来您正在使用ggthemes::theme_fivethirtyeight作为ggplot主题。此主题将轴标签设置为默认情况下不显示。您可以使用meaxis.title=element\u text重新启用它们:


使用ggplotmtcars,aesx=disp,我无法重现这个问题。我在R=3.5.3上使用ggplot2-3.2.0,您使用的是什么版本?请在问题中包括您使用的所有库。我能够识别出情节的外观,这样我就可以猜出你使用的是哪一个库ggthemes,因此这个问题,是针对这个主题的。呵呵,很好的发现。。。如果是这样的话,DannyBrown,我可以建议当你提供一个最简单的工作示例时,主要是很好的工作,谢谢,但我们也需要数据,MWE应该在你这一方用于生成你声称来自该代码的图形。非常感谢你的解释和解决方案。下次当我发布问题时,我还会提供更多的数据和信息,谢谢你的反馈!
library(ggplot2)
library(ggthemes)
theme_set(theme_fivethirtyeight())

pl <- ggplot(mtcars, aes(x = disp)) + 
    geom_histogram(binwidth = 0.1, aes(fill = ..count..)) + 
    xlab('Movie Rating') + 
    ylab('Count') + 
    ggtitle('MY TITLE')
# Current plot, no labels
pl

# Turn the labels on
pl +
    theme(axis.title = element_text())