Vittorio de martino
2018-03-25 18:51:00 UTC
I have the following dataset "vc"
13 2017-01-01 3.23 1.98
14 2017-02-01 -4.22 -1.62
15 2017-03-01 -1.14 -1.27
16 2017-04-01 1.83 1.10
17 2017-05-01 0.57 0.23
18 2017-06-01 6.09 -0.47
19 2017-07-01 -2.67 0.28
20 2017-08-01 4.68 1.92
21 2017-09-01 -8.66 -0.20
22 2017-10-01 1.69 -1.11
23 2017-11-01 1.77 0.42
24 2017-12-01 0.70 0.85
p <- ggplot(vc) +
scale_x_date(limits=as.Date(c("2016-12-31","2018-01-01")),
date_labels = "%m/%y",date_minor_breaks="1 month") +
scale_y_continuous(breaks=seq(-9,7,by=2)) +
xlab(NULL) +
ylab("Short-term changes (%)") +
theme(panel.background= element_rect(fill="grey90"), text = element_text
(size=7), axis.ticks = element_line(size=0.1),
panel.grid.major = element_line(size = 0.5, linetype = 'solid'
,colour = "grey95"),
panel.grid.minor = element_line(size = 0.25, linetype = 'solid',
colour = "grey95")) +
geom_hline(yintercept=0, color="brown",size=0.5, linetype="solid") +
geom_point(aes(date,gross, color="Gross"), size=1, shape=3) +
geom_point(aes(date,corrected, color="Corrected"), size=1, shape=16) +
theme(legend.position="bottom") +
scale_colour_manual("", breaks=c("Gross","Corrected"),
values=c("Gross"="blue", "Corrected"="red")) +
theme(legend.title = element_text(colour="black", size = 6, face =
"bold"),
legend.text = element_text(colour="black", size = 6, face = "bold"))
ggsave("test.pdf",plot=p,device="pdf", width=18,height=6,units="cm")
This code produces the attached result.
The colors in the legend are correct but the shape aren't. How can I have a
blue "+" and a red point in the legend?
Thanks
Vittorio
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
vc
date gross corrected13 2017-01-01 3.23 1.98
14 2017-02-01 -4.22 -1.62
15 2017-03-01 -1.14 -1.27
16 2017-04-01 1.83 1.10
17 2017-05-01 0.57 0.23
18 2017-06-01 6.09 -0.47
19 2017-07-01 -2.67 0.28
20 2017-08-01 4.68 1.92
21 2017-09-01 -8.66 -0.20
22 2017-10-01 1.69 -1.11
23 2017-11-01 1.77 0.42
24 2017-12-01 0.70 0.85
p <- ggplot(vc) +
scale_x_date(limits=as.Date(c("2016-12-31","2018-01-01")),
date_labels = "%m/%y",date_minor_breaks="1 month") +
scale_y_continuous(breaks=seq(-9,7,by=2)) +
xlab(NULL) +
ylab("Short-term changes (%)") +
theme(panel.background= element_rect(fill="grey90"), text = element_text
(size=7), axis.ticks = element_line(size=0.1),
panel.grid.major = element_line(size = 0.5, linetype = 'solid'
,colour = "grey95"),
panel.grid.minor = element_line(size = 0.25, linetype = 'solid',
colour = "grey95")) +
geom_hline(yintercept=0, color="brown",size=0.5, linetype="solid") +
geom_point(aes(date,gross, color="Gross"), size=1, shape=3) +
geom_point(aes(date,corrected, color="Corrected"), size=1, shape=16) +
theme(legend.position="bottom") +
scale_colour_manual("", breaks=c("Gross","Corrected"),
values=c("Gross"="blue", "Corrected"="red")) +
theme(legend.title = element_text(colour="black", size = 6, face =
"bold"),
legend.text = element_text(colour="black", size = 6, face = "bold"))
ggsave("test.pdf",plot=p,device="pdf", width=18,height=6,units="cm")
This code produces the attached result.
The colors in the legend are correct but the shape aren't. How can I have a
blue "+" and a red point in the legend?
Thanks
Vittorio
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.