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

Problems with plot.candisc() #1

Closed
d-carlson opened this issue Oct 23, 2017 · 3 comments
Closed

Problems with plot.candisc() #1

d-carlson opened this issue Oct 23, 2017 · 3 comments

Comments

@d-carlson
Copy link

There are two issues with the plotting of points and centroids in the current version of candisc. The default behavior fails to plot one group of points when three groups are present:

Original data

library(candisc)
data(iris)
iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris)
iris.can <- candisc(iris.mod, data=iris)
plot(iris.can)

Note that the virginica points are not plotted (the 3rd factor level and the last group in the data frame. Note also that the centroid color for both virginica and setosa is the same (red). If we specify the symbols and colors, that seems to fix the problem:

plot(iris.can, pch=1:3, col=1:3)

Now all seems fine, but this is only because the data frame is sorted by the factor levels.

Randomize the order of the data,

set.seed(42)
iris.rnd <- iris[sample(rownames(iris)), ]
head(iris.rnd, 4)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
138 6.4 3.1 5.5 1.8 virginica
140 6.9 3.1 5.4 2.1 virginica
43 4.4 3.2 1.3 0.2 setosa
123 7.7 2.8 6.7 2.0 virginica
iris.rnd.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris.rnd)
iris.rnd.can <- candisc(iris.rnd.mod, data=iris.rnd)
plot(iris.rnd.can)

This time versicolor is not plotted. It appears last in the randomized data order (in the 4th row). Also virginica and setosa still use the same color (red). Now we try specifying the symbol and color as previously:

plot(iris.rnd.can, pch=1:3, col=1:3)

Note that the colors of the centroids and the data points do not match. The centroid colors are in factor order, but the point symbol/colors are in order of appearance in the data.

friendly added a commit that referenced this issue Nov 5, 2017
@friendly
Copy link
Owner

friendly commented Nov 5, 2017

@d-carlson Pls. check out the latest version to confirm that this problem has been fixed.

@d-carlson
Copy link
Author

Yes. It is working perfectly now.

@friendly
Copy link
Owner

friendly commented Nov 6, 2017

Great. Thanks for checking it out.

@friendly friendly closed this as completed Nov 6, 2017
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

2 participants