-1

I have successfully created a ternary plot with the following code:

data <- read.csv(file, header=TRUE)
ternaryplot(data[,3:5], scale = 100, 
    pch = 19, cex = 0.4, col = Category,
    dimnames = c("Al", "Mg", "Fe + Ti"),
    labels = c("outside"),
    main = "")

However, I am struggling to create a legend for it. As the package has assigned colours based on the category of the sample I cannot simply write out the entire legend by allocating colours manually. I have tried a few variations of the following but have encountered the error code:

grid_legend(0.8, 0.9, pch = 19, col = Category, rownames(Category), title = "Categories")

Error in grid_legend(0.8, 0.9, pch = 19, col = Category, rownames(Category),  : 
  pch and labels not the same length

This is the first time I have used the vcd package and would appreciate any help on the subject. Thanks, Holly

1
  • Have a look at my package, its based off ggplot2, website is www.ggtern.com Dec 16, 2013 at 14:34

1 Answer 1

0

The error is explicit:

 pch and labels not the same length

So , you should give pch argument with the same length as labels one, replace pch by :

rep(19,nrow(Category))
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.