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

Color change #26

Open
pdwaggoner opened this Issue Mar 29, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@pdwaggoner
Copy link

pdwaggoner commented Mar 29, 2019

Please specify whether your issue is about:

  • a question about package functionality

See below for these things. I just copied and pasted the example for MM's from the package README.

I was curious if you could change the colors to gray scale, for example, instead of rainbow colors for journal publication? Couldn't figure out how to do this. Thanks!

Example here:

## load package
library("cregg")

data("immigration")

# taken from README
f1 <- ChosenImmigrant ~ Gender + Education + LanguageSkills + CountryOfOrigin + Job + JobExperience + JobPlans + ReasonForApplication + 
    PriorEntry
plot(mm(immigration, f1, id = ~CaseID), vline = 0.5) # change colors here?

## session info for your system
sessionInfo()

# OUTPUT:
### R version 3.5.2 (2018-12-20)
### Platform: x86_64-apple-darwin15.6.0 (64-bit)
### Running under: macOS Mojave 10.14.3
@mbarnfield

This comment has been minimized.

Copy link

mbarnfield commented Mar 30, 2019

Hi, I'm pretty sure scale_colour_grey this does the trick. If you're using RStudio and it looks weird in the plots viewer, click the zoom button and look at it that way to check.


library(tidyverse)

data(immigration)

# specify formula
f1 <- ChosenImmigrant ~ Gender + Education + LanguageSkills + CountryOfOrigin + Job + JobExperience + JobPlans + ReasonForApplication + 
  PriorEntry

# create plot object 
p <- plot(mm(immigration, f1, id = ~CaseID), vline = 0.5)

# adjust visuals
p +
  scale_colour_grey() + 
  theme_bw()
  theme(legend.position = "right")

The last two lines aren't necessary, but I think it looks better with them. That is, p + scale_colour_grey() should be fine on its own. Equally you can do it without saving the plot object of course:


library(tidyverse)

data(immigration)

# specify formula
f1 <- ChosenImmigrant ~ Gender + Education + LanguageSkills + CountryOfOrigin + Job + JobExperience + JobPlans + ReasonForApplication + 
  PriorEntry

# calculate mms
mm_immigration <- mm(immigration, f1, id = ~CaseID)

# create plot object 
plot(mm_immigration, vline = 0.5) + 
  scale_colour_grey()
@leeper

This comment has been minimized.

Copy link
Owner

leeper commented Mar 30, 2019

Exactly. It’s a ggplot2 object so you can just + whatever further modifications you want to it. You may need to use an aes() if you want to change shape, fill, etc. rather than colour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.