Based on this code:
ggplot(inputR_performances, aes(x=reorder(X,MCCHVAR))) +
geom_point(aes(y=MCCGS, col="chartreuse4")) +
geom_point(aes(y=MCCHVAR, col="cyan2")) +
geom_point(aes(y=MCCHDIV, col="cornflowerblue")) +
geom_smooth(aes(y=MCCHVAR, group=1), method="loess", se=FALSE, col="cyan2") +
geom_smooth(aes(y=MCCHDIV, group=1), method="loess", se=FALSE, col="cornflowerblue") +
geom_smooth(aes(y=MCCGS, group=1), method="loess", se=FALSE, col="chartreuse4") +
panel.configuration
That gives:
What should I change so that:
- the dots appear in the expected (custom) colour and not the pink-green-blue default?
- the legend labels are "MCC.." and not "chartreuse4..."?
First I tried placing col=...
outside aes
in geom_point
, like it appears in geom_smooth
. That gave the right colour but no legend was shown. Thanks.
UPDATE: After @beetroot comment:
Starting data: Dataframe with 4 columns (one for X and 3 for Y: X [factors], MCCGS [numeric], MCCHVAR [numeric], MCCHDIV [numeric]):
colnames(df1input) <- c("X","MCCGS","MCCHVAR","MCCHDIV")
I changed it to a 3 column dataframe using melt function so that all numeric values are in one column (column called "value") and a column ("variable") indicates whether it comes from MCCHVAR, MCCHDIV, etc.
df1input_m <- melt(df1input, id="X")
str(df1input_m)
'data.frame': 204 obs. of 3 variables:
$ X : Factor w/ 68 levels "O00255","O15118",..: 1 2 3 4 5 6 7 8 9 10 ...
$ variable: Factor w/ 3 levels "MCCGS","MCCHVAR",..: 1 1 1 1 1 1 1 1 1 1 ...
$ value : num 0.78 0.49 0.83 0.69 0.74 0.54 0.48 0.57 0.69 0.84 ...