图 ggplot 上的 0 和 1
0 and 1 on diagram ggplot
我的数据是
black wage
1 0 769
2 0 808
3 0 825
4 0 650
5 0 562
6 1 1400
7 0 600
8 0 1081
9 0 1154
10 0 1000
我的密码是
b <- lm(wage~black, y)
ggplot(b, aes(black, wage)) +
geom_point() +
stat_smooth(method = "lm", col = "red", se = F) +
theme_minimal() +
labs(x = '黑人', y = '薪水') +
theme_minimal() +
theme(text = element_text(family='黑體-繁 中黑'),
plot.title = element_text(size = rel(2.5), face = 'bold', hjust = 0.5),
axis.title = element_text(size = rel(1.5), face = 'bold'),
axis.text = element_text(size = rel(2), face = 'bold', colour = 'Black'),
panel.grid.minor.y = element_line(colour = NA))
回归图
https://i.stack.imgur.com/XO0nZ.png
我希望我的图表在 x 轴上只有 0 和 1。
来自 scale_x_continuous
、
ggplot(b, aes(black, wage)) +
geom_point() +
stat_smooth(method = "lm", col = "red", se = F) +
theme_minimal() +
labs(x = '黑人', y = '薪水') +
theme_minimal() +
theme(text = element_text(family='黑體-繁 中黑'),
plot.title = element_text(size = rel(2.5), face = 'bold', hjust = 0.5),
axis.title = element_text(size = rel(1.5), face = 'bold'),
axis.text = element_text(size = rel(2), face = 'bold', colour = 'Black'),
panel.grid.minor.y = element_line(colour = NA)) +
scale_x_continuous(breaks = seq(0,1, by = 1),"黑人")
我的数据是
black wage
1 0 769
2 0 808
3 0 825
4 0 650
5 0 562
6 1 1400
7 0 600
8 0 1081
9 0 1154
10 0 1000
我的密码是
b <- lm(wage~black, y)
ggplot(b, aes(black, wage)) +
geom_point() +
stat_smooth(method = "lm", col = "red", se = F) +
theme_minimal() +
labs(x = '黑人', y = '薪水') +
theme_minimal() +
theme(text = element_text(family='黑體-繁 中黑'),
plot.title = element_text(size = rel(2.5), face = 'bold', hjust = 0.5),
axis.title = element_text(size = rel(1.5), face = 'bold'),
axis.text = element_text(size = rel(2), face = 'bold', colour = 'Black'),
panel.grid.minor.y = element_line(colour = NA))
回归图
https://i.stack.imgur.com/XO0nZ.png
我希望我的图表在 x 轴上只有 0 和 1。
来自 scale_x_continuous
、
ggplot(b, aes(black, wage)) +
geom_point() +
stat_smooth(method = "lm", col = "red", se = F) +
theme_minimal() +
labs(x = '黑人', y = '薪水') +
theme_minimal() +
theme(text = element_text(family='黑體-繁 中黑'),
plot.title = element_text(size = rel(2.5), face = 'bold', hjust = 0.5),
axis.title = element_text(size = rel(1.5), face = 'bold'),
axis.text = element_text(size = rel(2), face = 'bold', colour = 'Black'),
panel.grid.minor.y = element_line(colour = NA)) +
scale_x_continuous(breaks = seq(0,1, by = 1),"黑人")