Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty plotting NMDS #7

Closed
RaebonucleicAcid opened this issue Apr 25, 2020 · 4 comments
Closed

Difficulty plotting NMDS #7

RaebonucleicAcid opened this issue Apr 25, 2020 · 4 comments

Comments

@RaebonucleicAcid
Copy link

Hello,

I am trying to plot an NMDS output from metaMDS(), which successfully plotted using ggplot(). I am trying to use ggordiplot to plot the same ordination and use the gg_envfit function to more easily add environmental vectors, however the plot itself isn't looking right. I can't get the right axes to be plotted.

##GGPLOT PLOT:
##PLOTTING NMDS

toPlot <- data.frame(NMDS1$points, Sample_ID = metadata$Sample_ID);
a <- ggplot(toPlot, aes(-MDS1, MDS2, colour=Sample_ID)) +
    geom_point(size=3) +
    xlab("NMDS1") +
    ylab("NMDS2") +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank(),
          axis.title = element_text(size = 20),
          legend.text = element_text(size = 20),
          legend.title = element_text(size = 20),
          #legend.key.size = unit(1.0, "cm"),
          legend.key = element_rect(colour = "gray"));
    


a <- a + theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
                            panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"));
a

image

However when I plot using gg_ordiplot my output looks like this:

image

I cannot figure out how to change the axes.

I am sorry if this is a very remedial question - I am new to R and trying to figure it out as I go! Thank you!

@gcuster1991
Copy link

gcuster1991 commented Apr 25, 2020 via email

@jfq3
Copy link
Owner

jfq3 commented Apr 25, 2020

The reason the X axis is flipped is that you have a negative sign before MDS1 in the first plot. I cannot answer why the gg_ordiplot result looks as it does without the data. I find it curious that the Y axis label is NA.

@jfq3
Copy link
Owner

jfq3 commented Apr 25, 2020

I fixed the problem with the axis labels. You will have to reinstall for my change to take effect.

@RaebonucleicAcid
Copy link
Author

Thank you so much! I will reinstall and try again today.

@jfq3 jfq3 closed this as completed Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants