jfq3 / ggordiplots

Make ggplot Versions of Vegan's Ordiplots
GNU General Public License v2.0
6 stars 2 forks source link

Difficulty plotting NMDS #7

Closed RaebonucleicAcid closed 4 years ago

RaebonucleicAcid commented 4 years ago

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 commented 4 years ago

It looks like the ordination is the same only flipped and scrunched on the vertical axis.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Rae Santora notifications@github.com Sent: Friday, April 24, 2020 6:56:53 PM To: jfq3/ggordiplots ggordiplots@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [jfq3/ggordiplots] Difficulty plotting NMDS (#7)

◆ This message was sent from a non-UWYO address. Please exercise caution when clicking links or opening attachments from external sources.

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]https://user-images.githubusercontent.com/45110586/80267242-9eee1780-8654-11ea-9505-92a76d591254.png

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

[image]https://user-images.githubusercontent.com/45110586/80267313-deb4ff00-8654-11ea-85ac-a5db4e954314.png

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!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jfq3/ggordiplots/issues/7, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFZCCFMPM7MZLIVNR5KAGQLROIYNLANCNFSM4MQQQVOQ.

jfq3 commented 4 years ago

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 commented 4 years ago

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

RaebonucleicAcid commented 4 years ago

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