Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement request: allowing different colors for the dots and the whiskers #81

Closed
IndrajeetPatil opened this issue Jun 9, 2018 · 2 comments

Comments

@IndrajeetPatil
Copy link

@IndrajeetPatil IndrajeetPatil commented Jun 9, 2018

Is there any way to change the color of both dot and the whisker separately?
This is something I can do with GGally::ggcoef, but I much prefer using dotwhisker package and so it would be lovely if you can implement this.

I am providing a minimal example below:

# loading the library
library(dotwhisker)
#> Loading required package: ggplot2
library(GGally)

# linear model of interest
lm_object <- stats::lm(formula = wt ~ am * cyl, data = mtcars)

# creating the plot with dwplot
dotwhisker::dwplot(
  x = lm_object,

  dot_args = list(color = "red"),
  # color for the dot
  line_args = list(color = "black")   # color for the whisker
) +
  ggplot2::geom_vline(
    xintercept = 0,
    colour = "grey60",
    linetype = 2,
    size = 1
  )

# creating the plot with ggcoef
GGally::ggcoef(x = lm_object,
               exclude_intercept = TRUE,
               color = "red",
               errorbar_color = "black")

Created on 2018-06-09 by the reprex package (v0.2.0).

@fsolt
Copy link
Owner

@fsolt fsolt commented Jun 27, 2018

Okay, the development version does this now by reintroducing the whisker_args argument, which we had for a while but dropped at some point. (Note that line_args is just for style = "distribution". I suppose it could do double duty for both styles, but I think I'll keep the two separate.) As soon as I confirm it all works fine with the newest ggplot2, I'll get it up on CRAN.

# loading the library
library(dotwhisker)
#> Loading required package: ggplot2

# linear model of interest
lm_object <- stats::lm(formula = wt ~ am * cyl, data = mtcars)

# creating the plot with dwplot
dwplot(x = lm_object,
       dot_args = list(color = "red"), # color for the dot
       whisker_args = list(color = "black"),   # color for the whisker
       vline = ggplot2::geom_vline(xintercept = 0,  # put vline _behind_ coefs; see https://github.com/fsolt/dotwhisker/issues/84
                                   colour = "grey60",
                                   linetype = 2,
                                   size = 1))

Created on 2018-06-27 by the reprex
package
(v0.2.0).

@fsolt fsolt closed this Jun 27, 2018
@brandybiggar
Copy link

@brandybiggar brandybiggar commented May 19, 2020

fsolt is this available now? I'm trying to use it but not having any luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.