Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How about creating a new variable as a reference and colour the points by that? Seems to work provided you don't mind the points in the first 3 facets being coloured too.</p> <pre><code>mtcars$ref &lt;- as.factor(mtcars$gear) p &lt;- ggplot(mtcars, aes(mpg, wt)) + geom_point(aes(col=as.factor(gear))) p + facet_grid(.~ref, margins = TRUE) </code></pre> <p><img src="https://i.stack.imgur.com/airkb.png" alt="All points coloured by gear"></p> <p>EDIT: I have managed to get it to remove the colour key from the first 3 facets but not without playing around with the original data;</p> <p>Duplicate the original data (so there are 2 of each record) then instead of using a margin plot to produce the "all" facet, using the redundant records instead.</p> <pre><code>library(ggplot2) mtcars$ref &lt;- (mtcars$gear) # create the duplicate dat &lt;- do.call("rbind", replicate(2, mtcars, simplify = FALSE)) # give the duplicates a false value for "gear" so they can be plotted together #This value can then be used for faceting, grouping everything with "all". dat$ref[1:32] &lt;- "all" # where not in the "all" facet, change "gear" to one (so they are plotted with the same colour) dat$gear[dat$ref != "all"] &lt;- 1 # then plot using ref as the facet and gear to colour points. p &lt;- ggplot(dat, aes(mpg, wt)) + geom_point(aes(col=as.factor(gear))) p + facet_grid(.~ref, margins = F) </code></pre> <p><img src="https://i.stack.imgur.com/EhW4d.png" alt="Points only coloured by gear in final facet"></p> <p>I'm not sure that's the best way to go about it but perhaps someone with more expertise might be able to advise?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload