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

Already on GitHub? Sign in to your account

Specify alpha for outlier points in geom_boxplot. #1644

Merged
merged 10 commits into from Sep 15, 2016

Conversation

Projects
None yet
4 participants
Contributor

jonathan-g commented Jun 3, 2016 edited

Add a parameter outlier.alpha to geom_boxplot to allow the outlier points to have different alpha from the boxes. This parameter works the same way as outlier.colour, outlier.shape, etc.

This is useful when plotting large data sets, so even when only a small fraction of the data is outliers, the number of outlier points can be large enough that it's hard to see them all. In such a case, setting alpha.outlier < 1 makes it easier to see the density of outliers.

jonathan-g added some commits Mar 26, 2016

@jonathan-g jonathan-g Added outlier.alpha to options for geom_boxplot. 57faddd
@jonathan-g jonathan-g Roll back development version number
Roll back development version number in order to prepare for pull request to hadley's repo.
cb741f8

codecov-io commented Jun 3, 2016 edited

Current coverage is 65.53%

Merging #1644 into master will increase coverage by <.01%

@@             master      #1644   diff @@
==========================================
  Files           158        158          
  Lines          5547       5548     +1   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           3635       3636     +1   
  Misses         1912       1912          
  Partials          0          0          

Powered by Codecov. Last updated by b181e9a...e34868a

jonathan-g closed this Jun 3, 2016

@jonathan-g jonathan-g Merge pull request #1 from hadley/master
Updated to hadley's latest.
5edecf9

jonathan-g reopened this Jun 3, 2016

jonathan-g changed the title from Updated to hadley's latest. to Specify alpha for outlier points in geom_boxplot. Jun 6, 2016

@jonathan-g jonathan-g Update NEWS
e34868a

@hadley hadley commented on the diff Jul 28, 2016

R/geom-boxplot.r
@@ -204,7 +207,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
size = outlier.size %||% data$size[1],
stroke = outlier.stroke %||% data$stroke[1],
fill = NA,
- alpha = NA,
+ alpha = outlier.alpha %||% data$alpha[1],
@hadley

hadley Jul 28, 2016

Owner

%||% works with NULL not NA. I think that just means the default function param above should be NULL.

@jonathan-g

jonathan-g Jul 29, 2016

Contributor

Thanks for catching that. I changed the default NULL and tested and it seems to work fine that way.

@hadley hadley commented on an outdated diff Jul 28, 2016

@@ -1,3 +1,7 @@
+* `geom_boxplot` gain new `outlier.alpha` argument for controlling the alpha of
@hadley

hadley Jul 28, 2016

Owner

Should be in NEWS.md

Owner

hadley commented Jul 28, 2016

Could you please include a couple of before/after example plots in the PR?

hadley added this to the v2.2.0 milestone Jul 28, 2016

Contributor

jonathan-g commented Jul 29, 2016

Will do.

Contributor

jonathan-g commented Jul 29, 2016

I have made the changes you requested, including adding an example of using outlier.alpha with the diamonds data.

jonathan-g added some commits Jul 29, 2016

@jonathan-g jonathan-g Corrected whitespace in news.md item. 6eb9b36
@jonathan-g jonathan-g Merge branch 'master' of https://github.com/hadley/ggplot2
# Conflicts:
#	NEWS.md
6ca172f
@jonathan-g jonathan-g Cleaned up old NEWS file (moved note about outlier.alpha for geom_box…
…plot to NEWS.md)
c61acfe
Contributor

jonathan-g commented Jul 30, 2016 edited

Just for completeness, here is the output from the example plots so you can see them without having to run the example code yourself:

ggplot(diamonds, aes(carat, price)) +
     geom_boxplot(aes(group = cut_width(carat, 0.25))) + 
     ggtitle('Before (no outlier.alpha)')
ggplot(diamonds, aes(carat, price)) +
     geom_boxplot(aes(group = cut_width(carat, 0.25)), outlier.alpha = 0.1) + 
     ggtitle("After (outlier.alpha = 0.1)")

before
after

thomasp85 was assigned by hadley Sep 6, 2016

Owner

hadley commented Sep 6, 2016

@thomasp85 can you help finish this one off please?

Collaborator

thomasp85 commented Sep 15, 2016

@jonathan-g Can you bring this PR up to date with the main branch and I'll have a look through it so we can get it merged

@jonathan-g jonathan-g Merged with latest from hadley.
Merge remote-tracking branch 'hadley/master'

# Conflicts:
#	NEWS.md
f8c264d
Contributor

jonathan-g commented Sep 15, 2016

@thomasp85 I've fixed the conflicts with the main branch and confirmed that it passes R CMD check with no warnings or errors.

@thomasp85 thomasp85 merged commit 0b3a8be into tidyverse:master Sep 15, 2016

3 checks passed

codecov/patch 100% of diff hit (target 67.47%)
Details
codecov/project 67.48% (+<.01%) compared to 9181611
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

hadley removed the in progress label Sep 15, 2016

Collaborator

thomasp85 commented Sep 15, 2016

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment