Reputation: 21
That is my code
plot_model(mylogit, type = "pred", terms = c("ScoreEnvAtt [all]", "Guilt")) +
scale_colour_discrete(guide = guide_legend(title = "Guilt"), labels = c("Low", "Medium", "High")) +
scale_fill_discrete(guide = guide_legend(title = "Guilt"), labels = c("Low", "Medium", "High")) +
labs( title = "",
x = "Environmental Attitudes",
y = "Probability of choosing the green investment") + theme_gray(base_size = 14) +
theme(text=element_text(family="Times New Roman", size=12))
How can I remove the two gaps such that the x axis starts at 3 and ends at 7?
Upvotes: 1
Views: 527
Reputation: 46958
sjPlot uses ggplot2 so you can find the options to modifying your plot by looking for ggplot2. In this case, what you need is expand=c(0,0) inside scale_x_continuous, for example:
library(sjPlot)
fit = lm(mpg ~ hp,data=mtcars)
plot_model(fit,typpe="pred") + scale_x_continuous(expand=c(0,0))
Upvotes: 2
Reputation: 1053
Maybe change your scale with the following addition to your ggplot:
plot_model(mylogit, type = "pred", terms = c("ScoreEnvAtt [all]", "Guilt")) +
scale_colour_discrete(guide = guide_legend(title = "Guilt"), labels = c("Low", "Medium", "High")) +
scale_fill_discrete(guide = guide_legend(title = "Guilt"), labels = c("Low", "Medium", "High")) +
labs( title = "",
x = "Environmental Attitudes",
y = "Probability of choosing the green investment") + theme_gray(base_size = 14) +
theme(text=element_text(family="Times New Roman", size=12)) +
scale_x_continuous(limits = c(3, 7), expand = c(0, 0))
Upvotes: 1