My data is
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
my code is
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))
regression plot
https://i.sstatic.net/XO0nZ.png
I want my diagram to only have 0 and 1 on the x-axis.
By 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),"黑人")