ggplot2 的 geom_bar() 不显示默认的 x 轴刻度
ggplot2's geom_bar() not showing default x axis ticks
作为一个简单的例子,我将使用钻石数据:
data(diamonds)
ggplot(diamonds, aes(x = clarity, y = carat, fill = cut)) +
geom_bar(stat = "identity")
这将给我以下输出,其中 x 轴未注释:
如何显示 x 轴和 y 轴的值?我一直在广泛搜索,但还没有找到解决方案...
对于我的真实数据集,我的 x 轴值是离散的,使用 scale_x_discrete() 不会改变结果。
提前致谢!
您的代码工作正常,我相信您必须更新 ggplot2
并开始新的 R
会话:
data(diamonds)
ggplot(diamonds, aes(x = clarity, y = carat, fill = cut)) +
geom_bar(stat = "identity")
作为一个简单的例子,我将使用钻石数据:
data(diamonds)
ggplot(diamonds, aes(x = clarity, y = carat, fill = cut)) +
geom_bar(stat = "identity")
这将给我以下输出,其中 x 轴未注释:
如何显示 x 轴和 y 轴的值?我一直在广泛搜索,但还没有找到解决方案...
对于我的真实数据集,我的 x 轴值是离散的,使用 scale_x_discrete() 不会改变结果。
提前致谢!
您的代码工作正常,我相信您必须更新 ggplot2
并开始新的 R
会话:
data(diamonds)
ggplot(diamonds, aes(x = clarity, y = carat, fill = cut)) +
geom_bar(stat = "identity")