Closed badgerinden closed 2 years ago
So I'll use the example code here...
library(ggplot2)
library(jtools)
states <- as.data.frame(state.x77)
fit1 <- lm(Income ~ Frost + Illiteracy + Murder +
Population + Area + `Life Exp` + `HS Grad`,
data = states, weights = runif(50, 0.1, 3))
fit2 <- lm(Income ~ Frost + Illiteracy + Murder +
Population + Area + `Life Exp` + `HS Grad`,
data = states, weights = runif(50, 0.1, 3))
fit3 <- lm(Income ~ Frost + Illiteracy + Murder +
Population + Area + `Life Exp` + `HS Grad`,
data = states, weights = runif(50, 0.1, 3))
# Plot all 3 regressions with custom predictor labels,
# standardized coefficients, and robust standard errors
plot_summs(fit1, fit2, fit3,
coefs = c("Frost Days" = "Frost", "% Illiterate" = "Illiteracy",
"Murder Rate" = "Murder"),
scale = TRUE, robust = TRUE)
I can certainly edit the axis text like so:
p <- plot_summs(fit1, fit2, fit3,
coefs = c("Frost Days" = "Frost", "% Illiterate" = "Illiteracy",
"Murder Rate" = "Murder"),
scale = TRUE, robust = TRUE)
p + theme(axis.text.x = element_text(size = 50), axis.text.y = element_text(size = 50) # makes it really big
For the axis lines, that one was a bit more complicated but it appears to be originating in theme_nice()
to some extent. It sets axis.line.x.bottom
, axis.line.x.top
, axis.line.y.left
, and axis.line.y.right
to element_blank()
. For some reason these take precedence over a user-specified axis.line
or axis.line.x
/axis.line.y
. I've removed these from theme_nice()
so now using theme()
after the fact should work as expected. As a general rule, if some argument to theme()
isn't working it would be a good idea to try a specific version of it (e.g., instead of axis.line
, axis.line.xor
axis.line.x.bottom) because of the way
ggplot2seems to handle conflicting instructions from themes versus user calls to
theme()`.
Hi,
I can't change the text and line of axis in my graph. I created a graph with the following code. But the graph doesn't have both x and y axis. And I can't edit text size and color of x and y axis. I think axis.line and axis.text function do not work. (Other functions, including plot.title, legend.title and panel.grid, do work well.)