Discussion:
Customization in nMDS
Christos Gkenas
2018-06-09 01:25:08 UTC
Permalink
Dear all
Many thanks for your help and suggestions.
I was looking at the web for a routine and I managed to plot a graph in ggplot, similar to what I need (see attachment). However I can not match the color of the symbols with the polygons. I would appreciate if someone has a suggestion how to adjust the colors of the following routine for the background of ggplot polygons and symbols or how to remove the background and have the same color for the outline polygon border and symbols.
Thank you very much in advance


ggplot() +
geom_text(data=species.scores,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) + # add the species labels
geom_point(data=data.scores,aes(x=NMDS1,y=NMDS2,shape=classes,colour=classes),size=3) + # add the point markers
geom_text(data=data.scores,aes(x=NMDS1,y=NMDS2,label=site),size=6,vjust=0) + # add the site labels
scale_colour_manual(values=c("1" = "grey66", "2" = "red", "3" = "violet", "4" = "blue")) +
coord_equal() +
theme_bw() +
theme(axis.text.x = element_blank(), # remove x-axis text
axis.text.y = element_blank(), # remove y-axis text
axis.ticks = element_blank(), # remove axis ticks
axis.title.x = element_text(size=18), # remove x-axis labels
axis.title.y = element_text(size=18), # remove y-axis labels
panel.background = element_blank(),
panel.grid.major = element_blank(), #remove major-grid labels
panel.grid.minor = element_blank(), #remove minor-grid labels
plot.background = element_blank())
Hi Chris,
Is this plot a ggplot or a base R plot?
It seems to be base R, but I would need your script to help more.
However, you should be able to find this on a number of blogs/stack posts. Colouring points according to a factor in a plot is pretty straight forward. If you are plotting this NMDS with base R, you would need to include a factor column in the data frame that contains your NMDS species scores. This column could be called "Origin" for example and would mention weather each species is native or non-native. Then using the plot() command you would plot the scores and add, colour=c("black", "red")[the_name_of_your_factor_column].
The same action would need to be repeated for the site scores, in order to colour the sites. Then you should be able to overlay both plots using add=T.
Hope it helps.
Theo
Theo Mouton
Research Assistant
+64-7-859-1889 | Gate 10 Silverdale Road, Hillcrest, Hamilton | www.niwa.co.nz <http://www.niwa.co.nz/>
<imagea7b07e.JPG> <http://www.niwa.co.nz/>
To ensure compliance with legal requirements and to maintain cyber security standards, NIWA's IT systems are subject to ongoing monitoring, activity logging and auditing. This monitoring and auditing service may be provided by third parties. Such third parties can access information transmitted to, processed by and stored on NIWA's IT systems.
-----Original Message-----
Sent: Wednesday, 6 June 2018 12:20 p.m.
Subject: Customization in nMDS
Dear all
I have a small question regarding customization in an NMDS plot. I have a dataset from different river sites and I want to elucidate the spatial pattern of fish distribution, to identify areas with similar fish assemblages and to compare these assemblages among areas. As you can see from the picture attached, I managed to do the NMDS but I want to ask you how I can highlight with different color the native and nonnative fish (e.g. black and red) and also highlight the river sites as upstream and downstream. For your convenience I attached also the csv file and the script.
Thank you in advance
Regards
Chris
--
--
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 <https://github.com/hadley/devtools/wiki/Reproducibility>
More options: http://groups.google.com/group/ggplot2 <http://groups.google.com/group/ggplot2>
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
--
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.
Loading...