plot_summs()改变绘制的回归系数的大小

时间:2018-06-17 02:21:51

标签: r plot ggplot2 formatting coefficients

我使用plot_summs()包中的jtools绘制回归系数。我试图让情节大到足以看到演示文稿,我想出了如何改变除实际绘制系数之外的所有内容的大小(参见下面的示例图)。

任何人都有任何想法如何使绘制的系数更大?

#example data and models
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
testplot <- plot_summs(fit1, fit2, fit3, coefs = c("Frost Days" =
     "Frost", "% Illiterate" = "Illiteracy","Murder Rate" = "Murder"),
                   scale = TRUE, robust = TRUE)

#custom theme to format 
apatheme=theme_bw()+
theme(panel.grid.major=element_blank(),
    panel.grid.minor=element_blank(),
    panel.border=element_blank(),
    axis.line=element_line(),
    text=element_text(family='Helvetica'),
    legend.title=element_blank(), 
    axis.text=element_text(size=25),
    axis.title=element_text(size=15),
    legend.text = element_text(size = 20))


testplot  + apatheme + labs(x = "\n Beta Estimate \n ", y = NULL)  

Example plot (I want to change the size of the plotted coefficients)

1 个答案:

答案 0 :(得分:0)

您必须设置所需的高度和宽度。在代码顶部键入以下内容:

plot.new()
dev.new(width=5, height=4)

根据需要调整宽度和高度。