Jay Douillard
2008-Jul-30 19:04 UTC
[R] Setting fixed size for segement plot using stars() (axes size vs print size)
I have been making some segment plots with five variables. They work great, especially when I used a different scale function, which scaled them by area of the circle rather than radius scale <- function(x, Mr = 1 , Mx = 100) { ((x/Mx)^.5)*Mr} Where x is the the value, Mr is the Maximum radius, and Mx is the maximum data value. You could change the exponent .5 to .57 if you wanted Flannery compensation. My problem is that I want the print size of these proportional symbols to be the same regardless of the number of data points as in this example, where exporting these two plots as PDF(which have been scaled) will produce different size symbols for the same value, when compared side by side.I've tried manually setting the ncol and nrow attributes, and it still produces different results for the data sets. stars(large[2:6], draw.segments = TRUE, labels = large$size,scale = FALSE, flip.labels = TRUE, axes = TRUE,) stars(small[2:6], draw.segments = TRUE, labels = small$size,scale = FALSE, flip.labels = TRUE, axes = TRUE,) Thanks! small <- structure(list(size = c(5, 10, 15, 20, 25, 30, 50), one = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), two = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), three = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), four = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), five = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548)), .Names = c("size", "one", "two", "three", "four", "five"), row.names = c(NA, 7L), class = "data.frame") large <- structure(list(size = c(5L, 10L, 15L, 20L, 25L, 30L, 50L, 5L, 10L, 15L, 20L, 25L, 30L, 50L, 5L, 10L, 15L, 20L, 25L, 30L, 50L, 5L, 10L, 15L, 20L, 25L, 30L, 50L), one = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), two = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), three = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), four = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548), five = c(0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, 0.223606797749979, 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548)), .Names = c("size", "one", "two", "three", "four", "five"), row.names = c(NA, -28L ), class = "data.frame")
Greg Snow
2008-Aug-08 18:30 UTC
[R] Setting fixed size for segement plot using stars() (axes size vs print size)
You could use the symbols function instead of the stars function. This allows you to set the size of the stars in inches and that will not change based on the number of stars. The drawback is that you will have to set the positioning yourself and may need to suppress the axes and add the label and legend manually. You can also look at the my.symbols function in the TeachingDemos package if you want even more control of the individual stars. You could also add additional rows of 0's to your smaller datasets so that the stars function still creates the same number of stars with the later ones just being points rather than whole stars. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Jay Douillard > Sent: Wednesday, July 30, 2008 1:04 PM > To: r-help at r-project.org > Subject: [R] Setting fixed size for segement plot using > stars() (axes size vs print size) > > > I have been making some segment plots with five variables. > They work great, especially when I used a different scale > function, which scaled them by area of the circle rather than radius > > > scale <- function(x, Mr = 1 , Mx = 100) { ((x/Mx)^.5)*Mr} > > Where x is the the value, Mr is the Maximum radius, and Mx is > the maximum data value. You could change the exponent .5 to > .57 if you wanted Flannery compensation. > > > My problem is that I want the print size of these > proportional symbols to be the same regardless of the number > of data points > > as in this example, where exporting these two plots as > PDF(which have been scaled) will produce different size > symbols for the same value, when compared side by side.I've > tried manually setting the ncol and nrow attributes, and it > still produces different results for the data sets. > > stars(large[2:6], draw.segments = TRUE, labels > large$size,scale = FALSE, flip.labels = TRUE, axes = TRUE,) > stars(small[2:6], draw.segments = TRUE, labels > small$size,scale = FALSE, flip.labels = TRUE, axes = TRUE,) > > > Thanks! > > > small <- > structure(list(size = c(5, 10, 15, 20, 25, 30, 50), one > c(0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, > 0.707106781186548), two = c(0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548), three > c(0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, > 0.707106781186548), four = c(0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548), five > c(0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, > 0.707106781186548)), .Names = c("size", "one", "two", > "three", "four", "five"), row.names = c(NA, 7L), class = "data.frame") > > > large <- > structure(list(size = c(5L, 10L, 15L, 20L, 25L, 30L, 50L, 5L, > 10L, 15L, 20L, 25L, 30L, 50L, 5L, 10L, 15L, 20L, 25L, 30L, > 50L, 5L, 10L, 15L, 20L, 25L, 30L, 50L), one > c(0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, > 0.707106781186548), two = c(0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548, 0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548, 0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548, 0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548), three > c(0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, > 0.707106781186548), four = c(0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548, 0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548, 0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548, 0.223606797749979, > 0.316227766016838, 0.387298334620742, 0.447213595499958, 0.5, > 0.547722557505166, 0.707106781186548), five > c(0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, 0.707106781186548, > 0.223606797749979, 0.316227766016838, 0.387298334620742, > 0.447213595499958, 0.5, 0.547722557505166, > 0.707106781186548)), .Names = c("size", "one", "two", > "three", "four", "five"), row.names = c(NA, -28L ), class > "data.frame") > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >