Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to recycle colours in a colorbrewer palette using line symbols
    primarykey
    data
    text
    <p>I'm using ggplot2 to create quite a few <code>facet_wrap</code>ped <code>geom_line</code> plot.</p> <p>Although each plot only has a maximum of eight lines, when taken together, there are more like twenty categories to show on the legend.</p> <p>In a similar vein to this: <a href="https://stackoverflow.com/questions/13616515/recommend-a-scale-colour-for-13-or-more-categories">Recommend a scale colour for 13 or more categories</a> and this: <a href="https://stackoverflow.com/questions/6075140/in-r-how-do-i-change-the-color-value-of-just-one-value-in-ggplot2s-scale-fill-b/6076605#6076605">In R,how do I change the color value of just one value in ggplot2&#39;s scale_fill_brewer?</a> I'd like to artificially up the number of colours I can show using colorbrewer's high-contrast colour sets.</p> <p>An obvious way to do this would seem to be to 'recycle' the colours in the palette, with a different line symbol each time. So bright red with 'x's on the line could be a different category than bright red with 'o's etc.</p> <p>Can anyone think how I might do this?</p> <p>Thanks!</p> <h2>Edit</h2> <p>Here's some (sanitised) data to play with, and the R code I'm using to produce my plot.</p> <p>Data: <a href="http://orca.casa.ucl.ac.uk/~rob/Stack%20Overflow%20question/stack%20overflow%20colours%20question%20data.csv" rel="nofollow noreferrer">http://orca.casa.ucl.ac.uk/~rob/Stack%20Overflow%20question/stack%20overflow%20colours%20question%20data.csv</a></p> <p>R code:</p> <pre><code>csvData &lt;- read.csv("stack overflow colours question data.csv") p &lt;- ggplot(csvData, aes(year, percentage_of_output, colour=category, group=category)) p + geom_line(size=1.2) + labs(title = "Can I recycle the palette colours?", y = "% of output") + scale_colour_brewer(palette = "Set1") + theme(plot.title = element_text(size = rel(1.5))) + facet_wrap("country_iso3", scales="free_y") </code></pre>
    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.
 

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