My dataframe (see below for link) contains output from several models, which I want to "categorize" according to:
- model name (9 models) -> 9 shape fill colors
- model domain (each model has one of either of these two: "MED" or "EURO") -> two hollow shape types
- native resolution (each model has two "versions": "HR" and "LR") -> 2 shape contour colors
Additionally, a single observational dataset is also included, which should be shown with it's own color and filled shape.
So all in all I have 9x2=18 point types, each of which also has a "domain" tag, plus a single observational point type.
The following, which is the simplest thing one may start from, does not work at all. Also, I don't want to manually specify colors and shapes for each item using scale_*_manual.
library(ggplot2)
#Sorry for the wget, I can't seem to make load() read the url directly
system("wget https://copy.com/LrEznd8QCmzVBNyz/df_pr_PDF_alps_044.Rdata?download=1")
load("df_pr_PDF_alps_044.Rdata?download=1") #This loads df
colnames(df) #Take a look at the columns
ggplot(data=df[which(df$PDF > 0),], aes(x=x, y=PDF)) +
geom_point(aes(shape=domain, colour=nativeresolution, fill=model), alpha=0.7, size=2)+
scale_shape_manual(values=c(21,22,23))
I have tried some fixes such as those suggested here:
ggplot2: One legend with two visual properties derived from common variable
Combine legends for color and shape into a single legend
How to merge colour and shape?
But I can't seem to find a solution to this seemingly simple problem.
scale_*_manual
", please read?pch
: "21:25 can be colored and filled with different colors". Thus, I think you need to map the levels of your variable topch
:s which you definemanual
ly. – Henrik