[R] Plotting legend outside of chart area

Samantha Allcock sallcock at bournemouth.ac.uk
Wed Jun 24 18:34:43 CEST 2015


Hello,

I am trying to add a legend to my PCA plot so that it looks neat. I think plotting this outside of the chart area would be good but I cannot seem to fathom the correct code for this. I wondered if anyone could help please?

The code I am using is as follows:

grp<- with(Matan, cut(R_category_no,14, labels=1:14))
cols <- c("grey0", "wheat", "red", "cyan", "orange", "darkolivegreen2", "purple3",
"royalblue", "burlywood4", "orchid", "forestgreen", "green",
"gray", "yellow1")
plot(geopca, display="sites", scaling=3, type="n")
points(geopca, display="sites", scaling=3, col=cols[grp], pch=16)

legend("bottomright", col=c("grey0", "wheat", "red", "cyan", "orange", "darkolivegreen2",
"purple3", "royalblue", "burlywood4", "orchid", "forestgreen", "green",
"gray", "yellow1"), c("Control type 1", "Control type 2",
"External/Courtyard", "Midden", "Animal Occupation",
"External fire installations and ashy deposits",
"Internal fire installations and ashy deposits", "Hearth make-up",
"Floors and surfaces", "Plasters and clay features", "Storage features",
"Platforms and benches", "Mortars", "Roofs and roofing materials"), pch=16,
cex=0.75, bty="n")

Thank you for your time in advance


Dr Samantha Lee Allcock
Faculty of Science and Technology
Department of Archaeology, Anthropology and Forensic Science
Christchurch House Rm: C133
Bournemouth University
Talbot Campus
Poole
BH12 5BB
Tel: 01202 9(62474)

sallcock at bournemouth.ac.uk<mailto:sallcock at bournemouth.ac.uk>
research.bournemouth.ac.uk/2014/07/inea-project-2


BU is a Disability Two Ticks Employer and has signed up to the Mindful Employer charter. Information about the accessibility of University buildings can be found on the BU DisabledGo webpages This email is intended only for the person to whom it is addressed and may contain confidential information. If you have received this email in error, please notify the sender and delete this email, which must not be copied, distributed or disclosed to any other person. Any views or opinions presented are solely those of the author and do not necessarily represent those of Bournemouth University or its subsidiary companies. Nor can any contract be formed on behalf of the University or its subsidiary companies via email.

	[[alternative HTML version deleted]]



More information about the R-help mailing list