fsolt / dotwhisker

Dot-and-Whisker Plots of Regression Results
https://fsolt.org/dotwhisker/
Other
60 stars 10 forks source link

Change shape of the point estimate? #61

Closed zhiyzuo closed 7 years ago

zhiyzuo commented 7 years ago

First, this is a great tool!

Do you think it is possible to add an option for different models instead of just one default filled circle?

fsolt commented 7 years ago

Hmm. To change the shape for all models is (fairly) straightforward:

m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor
m3 <- update(m2, . ~ . + am) # and another 
dwplot(list(m1, m2, m3), dot_args = c(shape=1))

but I wasn't able to get it to vary the shape across models. We'll put it on the list.

stefan-mueller commented 7 years ago

I faced the exact same problem today (changing shape across models). Here is my solution:

m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor

m1_df <- tidy(m1) %>% filter(term != "(Intercept)") %>% mutate(model = "Model 1")
m2_df <- tidy(m2) %>% filter(term != "(Intercept)") %>% mutate(model = "Model 2")

two_models <- rbind(m1_df, m2_df)

dwplot(two_models) + 
  geom_point(aes(shape = model), size = 4) + # change shape
  scale_colour_grey(start = .1, end = .7) + 
  theme_bw()

Maybe there is a more straightforward way of doing it, but the code above does the job.

fsolt commented 7 years ago

That's great, Stefan—thanks for sharing! We'll have to add that to the vignette, too. In fact, do you care to submit a pull request?