MomX / Momocs

:dove: Morphometrics using R
http://momx.github.io/Momocs/
51 stars 18 forks source link

Error in PCA Plot #217

Open lrocax opened 3 years ago

lrocax commented 3 years ago

Hi,

When I run this code: library(Momocs)

lf <- list.files("C:/Data/outline/", pattern = "\.txt$",full.names=TRUE)
lf1<-lf_structure(lf, split = "C:/ Data /outline/", trim.extension = FALSE) lf2<-data.frame(substr(lf1$V2, 1, 5)) names(lf2)[1] <- "Type"

coordinates <- import_txt(lf)
do <- Out(coordinates, fac = lf2)

do.f <- efourier(do, nb.h=32, norm=TRUE)

do.p <- PCA(do.f) plot_PCA(do.p)
plot_PCA(do.p, ~Type)

do.l <- LDA(do.p, ~Type) plot_LDA(do.l)

I get these errors:

plot_PCA(do.p)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new has not been called yet plot_PCA(do.p, ~Type) factor passed was a character, and coerced to a factor. Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new has not been called yet

What is the issue and how can it be solved?

vbonhomme commented 3 years ago

Yeah. quite boring. came up with that situation myself. I think it's solved using the last github version. Otherwise, just call a plot(1) before your first plot. I'm back on MomX development so hopefully we will be free from all of this (more or less) soon. Hope this helps, v

Le jeu. 11 févr. 2021 à 08:27, Lluis Roca notifications@github.com a écrit :

Hi,

When I run this code: library(Momocs)

lf <- list.files("C:/Data/outline/", pattern = ".txt$",full.names=TRUE) lf1<-lf_structure(lf, split = "C:/ Data /outline/", trim.extension = FALSE) lf2<-data.frame(substr(lf1$V2, 1, 5)) names(lf2)[1] <- "Type"

coordinates <- import_txt(lf) do <- Out(coordinates, fac = lf2)

do.f <- efourier(do, nb.h=32, norm=TRUE)

do.p <- PCA(do.f) plot_PCA(do.p) plot_PCA(do.p, ~Type)

do.l <- LDA(do.p, ~Type) plot_LDA(do.l)

I get these errors:

plot_PCA(do.p) Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new has not been called yet plot_PCA(do.p, ~Type) factor passed was a character, and coerced to a factor. Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new has not been called yet

What is the issue and how can it be solved?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFR6YOUDDMYCZT7C3HTS6OBHXANCNFSM4XOK5VSQ .

-- vincentbonhomme.fr http://www.vincentbonhomme.fr

lrocax commented 3 years ago

Thanks a lot for the support, the new version solve the problem. BTW, How can I increase the line width of the convex hull and shapes (in the _plotPCA(do.p, ~Type))? and how can I add the shapes in the LDA plot.

vbonhomme commented 3 years ago

you can try so silent in the plot_PCA call (chull=FALSE) then "+ layer_chull(lwd=5)" sth like:

plot_PCA(..., chull=FALSE) + layer_chull(lwd=5)

Le jeu. 11 févr. 2021 à 13:29, Lluis Roca notifications@github.com a écrit :

Thanks. it solve the problem. BTW, How can I increase the line width of the convex hull and shapes (in the plot_PCA(do.p, ~Type))?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MomX/Momocs/issues/217#issuecomment-777419244, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABECQFX7JQ7KI4YM5344EQDS6PETVANCNFSM4XOK5VSQ .

-- vincentbonhomme.fr http://www.vincentbonhomme.fr