直方图未显示 R 中的所有 x 轴标签
Histogram not showing all x-axis labels in R
我绘制了直方图,但由于某些原因,x 标签是部分的。
我想把每一年都写在 x 轴上。这是我的代码:
ggplot(video_games, aes(x = Year)) + geom_histogram(stat = 'count') + lims(x = c(1995, 2017))
尝试使用 breaks
参数添加 scale_x_continuous
:
ggplot(...) +
... +
scale_x_continuous(breaks = 1995:2016)
你可以试试:
ggplot(video_games, aes(x = year)) +
geom_bar() +
scale_x_continuous(breaks = unique(video_games$year)) +
coord_flip()
coord_flip
在那里是因为 x 轴上会有很多 'long' 标签。如果你不想翻转你可以旋转:
theme(axis.text.x = element_text(angle = 90, vjust = 0.5))
我绘制了直方图,但由于某些原因,x 标签是部分的。
我想把每一年都写在 x 轴上。这是我的代码:
ggplot(video_games, aes(x = Year)) + geom_histogram(stat = 'count') + lims(x = c(1995, 2017))
尝试使用 breaks
参数添加 scale_x_continuous
:
ggplot(...) +
... +
scale_x_continuous(breaks = 1995:2016)
你可以试试:
ggplot(video_games, aes(x = year)) +
geom_bar() +
scale_x_continuous(breaks = unique(video_games$year)) +
coord_flip()
coord_flip
在那里是因为 x 轴上会有很多 'long' 标签。如果你不想翻转你可以旋转:
theme(axis.text.x = element_text(angle = 90, vjust = 0.5))