0

I have computed two complex hulls in R (using convhulln in geometry package)

tt7
dd7

When I plot them, though:

 plot(dd7, main="Convex hull for benchmark 7 with delay", xlab="Ticks per fault", ylab="Total Faults", xlim=c(550,1300), ylim=c(1650, 2400))
 plot(tt7, add=TRUE, col="red")

I only get the outline of the second one - how do I get the points as well?

enter image description here

Cannot find any documentation for this.

adrianmcmenamin
  • 1,081
  • 1
  • 15
  • 44

1 Answers1

0

I would use chull from base R for polygons because convhulln gives triangles. If you insist on using convhulln, you'll have to sort the indices of points first. Use plot at the beginning and then use polygon or points

#DATA
set.seed(42)
m1 = matrix(rnorm(40), ncol = 2)
m2 = 3 + matrix(rnorm(40), ncol = 2)

ch1 = chull(m1)
ch2 = chull(m2)

#Create empty plot with all points
plot(rbind(m1, m2), type = "n")

#First set of Data
points(m1)
polygon(m1[ch1,])

#Second set of Data
points(m2, col = "red")
polygon(m2[ch2,], border = "red")

enter image description here

d.b
  • 32,245
  • 6
  • 36
  • 77