I am playing with the “stars” ({graphics}) function to create a segment of flowers.
I wish to plot a flower of segments, for example in way the following command will produce:
stars1(mtcars[, 1:7],
draw.segments = T,
main = "Motor Trend Cars : stars(*, full = F)", full = T, col.radius = 1:8)
But, I want the segments to not have equal angles, but smaller angles (and between the flowers there could be space).
The goal I am striving for is to be able to give each flower “weight” so that some aspects are more important (larger weight) and some are less (and thus, will have a smaller angle).
I understand this can be changes in the following part of the stars command:
if (draw.segments) {
aangl <- c(angles, if (full) 2 * pi else pi)
for (i in 1L:n.loc) {
px <- py <- numeric()
for (j in 1L:n.seg) {
k <- seq.int(from = aangl[j], to = aangl[j +
1], by = 1 * deg)
px <- c(px, xloc[i], s.x[i, j], x[i, j] * cos(k) +
xloc[i], NA)
py <- c(py, yloc[i], s.y[i, j], x[i, j] * sin(k) +
yloc[i], NA)
}
polygon(px, py, col = col.segments, lwd = lwd, lty = lty)
}
But I am unsure as to how to manipulate it in order to achieve my task (of weighted flowers, by different angles)
I found out how to do it.
For future reference, here is the code:
Here is an example of running this:
(I’ll probably publish this with explanation on my blog sometime soon…)