使用X轴生成R图仅显示数据值

问题描述 投票:0回答:1

example plot我正在绘制一些数据。目前正试图让图表在x轴上只有自然数。怎么可能?在示例中,我想知道如何删除值1.2 1.4 1.6 1.8

谢谢

r data-science
1个回答
0
投票

我会想象使用scale_x_continuous(breaks = c(1,2))的例子。

x = sample(1:2, 1000, replace = T)
y = sample(1:6, 1000, replace = T)
df = data.frame(x, y)

df %>% 
  ggplot(aes(x = x, y = y)) +
  geom_point() +
  scale_x_continuous(breaks = c(1,2))

这会产生这样的情节。

Plot

© www.soinside.com 2019 - 2024. All rights reserved.