-
Notifications
You must be signed in to change notification settings - Fork 4
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
ggplot minimal example #2
Conversation
Added minimal ggplot2 example using mtcars dataset.
added subhead for clarity
added minimal ggplot example and dichromatic heading for clarity
minimal ggplot2 example now loads required packages to be stand-alone
minimal ggplot2 example now loads required packages to be stand-alone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! It looks good, but I think a few tweaks are needed
README.Rmd
Outdated
@@ -53,6 +53,7 @@ c("red","blue") %>% brightness(0.6) %>% saturation(seq(0,1,0.25)) %>% swatch | |||
|
|||
This operation takes the original two colours, reduces their brightness to 60%, assigns a whole series of saturation levels to the result, and then passes it to `swatch` for visualisation. Notice that the pipeline is combinative (like the base function `outer`), returning each combination of parameters in a multidimensional array. The final shades are arranged in two rows by `swatch`, for convenience. | |||
|
|||
### dichromat function and colour-blindness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather this was removed for now, as it doesn't apply to everything below it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me, I'll take it out!
README.Rmd
Outdated
@@ -87,6 +88,19 @@ Finally, you can calculate perceptual distances to a reference colour, as in | |||
distance(c("red","green","blue"), "red") | |||
``` | |||
|
|||
### Minimal ggplot2 example | |||
```r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think knitr
requires braces around the r
. We probably need to also increase the figure height a bit for these cases—otherwise they look a bit squashed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being the gitHub newby I am, I wasn't aware the Rmd gets knitted - is that resulting in the readme's html display people see on your repo? If so, what is the md for, why do we maintain both?
README.Rmd
Outdated
ggplot(mtcars, aes(mpg, qsec, col=cyl)) + geom_point() + | ||
scale_color_manual(values=gradient("viridis",3) %>% dichromat) | ||
ggplot(mtcars, aes(cyl, mpg, fill=cyl)) + geom_boxplot() + | ||
scale_fill_manual(values=gradient("viridis",3) %>% dichromat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't go through dichromat()
—that is only for simulating colour blindness, but the scales carry more information for those with normal colour perception in their original form
README.Rmd
Outdated
library(magrittr) | ||
library(ggplot2) | ||
library(shades) | ||
data("mtcars") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magrittr
isn't needed here (see below), and I don't think the dataset needs to be loaded explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included data("mtcars") to make it very obvious and clear for beginners. But now I agree with you, even ggplot's absolute beginner tutorials at tidyverse.org do not explicitly do it. I'll take it out! This is fun. Thanks for doing this with me, I'm inappropriately excited given how small this contribution is - it's just fun to learn how to contribute on gitHub!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this with me! Not sure why we have both .md and .Rmd, google didn't spit out immediately useful explanations - can you shortly explain?
README.Rmd
Outdated
@@ -87,6 +88,19 @@ Finally, you can calculate perceptual distances to a reference colour, as in | |||
distance(c("red","green","blue"), "red") | |||
``` | |||
|
|||
### Minimal ggplot2 example | |||
```r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being the gitHub newby I am, I wasn't aware the Rmd gets knitted - is that resulting in the readme's html display people see on your repo? If so, what is the md for, why do we maintain both?
README.Rmd
Outdated
library(magrittr) | ||
library(ggplot2) | ||
library(shades) | ||
data("mtcars") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included data("mtcars") to make it very obvious and clear for beginners. But now I agree with you, even ggplot's absolute beginner tutorials at tidyverse.org do not explicitly do it. I'll take it out! This is fun. Thanks for doing this with me, I'm inappropriately excited given how small this contribution is - it's just fun to learn how to contribute on gitHub!
I'm happy to explain. In brief, GitHub converts the contents of |
The changes I've suggested are fairly trivial, and I could easily make them myself, but I thought you might find it useful to see what a PR code review looks like, for future reference. The workflow now is that you make any changes you want locally, you push them to the master branch in your repository (FelixTheStudent/shades), and this PR will then be automatically updated. I can then approve the changes and merge the PR into my version of the repository. |
Hi, @FelixTheStudent! Just checking whether you want to make these changes, or you'd rather I merged the PR as-is, and then made them myself? |
Hi @jonclayden, thanks for your explanations and patients, sorry it took so long. You are absolutely right in saying it's helpful to go through PR code review! I'll get on it right away. |
Exactly - many thanks. Please don't overwrite the existing figures that haven't changed, though (as in d69fcf4). |
Good you would mention it. Knitting the Rmd file automatically overwrites them and git recognizes them as changed (not sure why, though - due to different creation date perhaps?). |
That's fine. They will differ for trivial reasons, such as the exact software versions on your system, but you can choose not to commit them. Having already done so, yes, checking out the versions from commit ec573e6 and making a new commit should work. |
Excellent - the PR is now merged! Thanks again for your efforts. |
Amazing! Thanks so much for guiding me through that first PR experience. That was fun! |
Good luck with your future projects, see you some time 🗡️ |
🗡️ should be this: :D |
Hi Jon,
thanks for our little chat on twitter. It was in fact very trivial to use shades in ggplot, but perhaps seeing it can motivate beginners to install and play with your package.
I leave it up to you whether you include this or not, in any case it was fun to play around with it!
Cheers,
Felix