ychu066
2009-Nov-19 00:33 UTC
[R] How do I change the colour and format for the trelli plot ?
http://old.nabble.com/file/p26418382/hist1.png hist1.png i want three plots along on the side , how to i do that ? and I also want to change the colour of the bars for each plot, how do i do that ? i got the code here to draw that .. columns <- 8:153 plots <- vector("list", length(columns)) j <- 0 for (i in columns) { plots[[ j <- j+1 ]] <- histogram( ~ data[,i], ylab = "Frequency", xlab = "Score", xlim = c(1,5), ylim = c(0,100), main = colnames(data)[i] ) } print(plots[[1]]) # or export for (i in seq_along(plots)) { png(paste("hist", i, ".png", sep = "")) print(plots[[i]]) dev.off() } -- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26418382.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-19 01:41 UTC
[R] How do I change the colour and format for the trelli plot ?
I have solved the first problem by using layout=c(1,3) but still cant find the solution for the next problem of getting differenct colour for the bars in the 3 different histogram plots.... ychu066 wrote:> > http://old.nabble.com/file/p26418382/hist1.png hist1.png i want three > plots along on the side , how to i do that ? > > and I also want to change the colour of the bars for each plot, how do i > do that ? > > i got the code here to draw that .. > columns <- 8:153 > plots <- vector("list", length(columns)) > j <- 0 > for (i in columns) > { > plots[[ j <- j+1 ]] <- > histogram( ~ data[,i], > ylab = "Frequency", xlab = "Score", > xlim = c(1,5), ylim = c(0,100), > main = colnames(data)[i] > ) > } > > print(plots[[1]]) > > # or export > > for (i in seq_along(plots)) > { > png(paste("hist", i, ".png", sep = "")) > print(plots[[i]]) > dev.off() > } >-- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26419007.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-19 01:42 UTC
[R] How do I change the colour and format for the trelli plot ?
tried reading the help(histogram) but didnt fiind it helpful ychu066 wrote:> > I have solved the first problem by using layout=c(1,3) > > but still cant find the solution for the next problem of getting > differenct colour for the bars in the 3 different histogram plots.... > > > ychu066 wrote: >> >> http://old.nabble.com/file/p26418382/hist1.png hist1.png i want three >> plots along on the side , how to i do that ? >> >> and I also want to change the colour of the bars for each plot, how do i >> do that ? >> >> i got the code here to draw that .. >> columns <- 8:153 >> plots <- vector("list", length(columns)) >> j <- 0 >> for (i in columns) >> { >> plots[[ j <- j+1 ]] <- >> histogram( ~ data[,i], >> ylab = "Frequency", xlab = "Score", >> xlim = c(1,5), ylim = c(0,100), >> main = colnames(data)[i] >> ) >> } >> >> print(plots[[1]]) >> >> # or export >> >> for (i in seq_along(plots)) >> { >> png(paste("hist", i, ".png", sep = "")) >> print(plots[[i]]) >> dev.off() >> } >> > >-- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26419023.html Sent from the R help mailing list archive at Nabble.com.
Deepayan Sarkar
2009-Nov-19 07:05 UTC
[R] How do I change the colour and format for the trelli plot ?
On Thu, Nov 19, 2009 at 6:03 AM, ychu066 <ychu066 at aucklanduni.ac.nz> wrote:> > http://old.nabble.com/file/p26418382/hist1.png hist1.png ?i want three plots > along on the side , how to i do that ? > > ?and I also want to change the colour of the bars for each plot, how do i do > that ? > > i got the code here to draw that ..This code did not produce the plot you have linked to. The answer to your question depends on how you created the plot, so you have to tell us that. Changing the color in all panels is easy: histogram(rnorm(100), col = "goldenrod") Different colors in different panels is a little more work: histogram(~rnorm(100) | gl(3, 1, 100), mycolors = sample(colors(), 3), panel = function(..., col, mycolors) { panel.histogram(..., col = mycolors[panel.number()]) }) -Deepayan> columns <- 8:153 > plots <- vector("list", length(columns)) > j <- 0 > for (i in columns) > { > ?plots[[ j <- j+1 ]] <- > ? ?histogram( ~ data[,i], > ? ? ?ylab = "Frequency", xlab = "Score", > ? ? ?xlim = c(1,5), ylim = c(0,100), > ? ? ?main = colnames(data)[i] > ? ?) > } > > print(plots[[1]]) > > # or export > > for (i in seq_along(plots)) > { > ?png(paste("hist", i, ".png", sep = "")) > ?print(plots[[i]]) > ?dev.off() > } > -- > View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26418382.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
Hrishi Mittal
2009-Nov-19 12:07 UTC
[R] How do I change the colour and format for the trelli plot ?
Add col=i in the histogram call. -- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421302.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-19 19:37 UTC
[R] How do I change the colour and format for the trelli plot ?
what is that ? Hrishi Mittal wrote:> > Add col=i in the histogram call. >-- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421453.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-19 19:59 UTC
[R] How do I change the colour and format for the trelli plot ?
Fore example my code is histogram(~data[,8]|data[,2], ylab = "Frequency", xlab = "Score", xlim c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] ) and i want the colour to be depended on the level of the factor in data[,2]. how do i do that ? ychu066 wrote:> > what is that ? > > > > Hrishi Mittal wrote: >> >> Add col=i in the histogram call. >> > >-- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421461.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-19 20:10 UTC
[R] How do I change the colour and format for the trelli plot ?
I want to change the colour of the histogram in each panel by the levels of the conoditonal factor. I have 3 levels in the factor levels(data[,2])[1] levels(data[,2])[2] levels(data[,2])[3] what can i do , in order to chnage the colour ?? ychu066 wrote:> > Fore example my code is > histogram(~data[,8]|data[,2], ylab = "Frequency", xlab = "Score", xlim > c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] ) > > and i want the colour to be depended on the level of the factor in > data[,2]. how do i do that ? > > > > > > ychu066 wrote: >> >> what is that ? >> >> >> >> Hrishi Mittal wrote: >>> >>> Add col=i in the histogram call. >>> >> >> > >-- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421465.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2009-Nov-19 23:30 UTC
[R] How do I change the colour and format for the trelli plot ?
On Nov 19, 2009, at 3:10 PM, ychu066 wrote:> > I want to change the colour of the histogram in each panel by the > levels of > the conoditonal factor. > > I have 3 levels in the factor > > levels(data[,2])[1] > levels(data[,2])[2] > levels(data[,2])[3] > > what can i do , in order to chnage the colour ??Why do you suppose there is a FAQ? Assuming that the underlying levels are coercible to numeric type then: col = as.numeric(as.character(data[ , 2] ) ) and of course: library(fortunes) fortune("dog") -- David> > > > ychu066 wrote: >> >> Fore example my code is >> histogram(~data[,8]|data[,2], ylab = "Frequency", xlab = "Score", >> xlim >> c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] ) >> >> and i want the colour to be depended on the level of the factor in >> data[,2]. how do i do that ? >> >> >> >> >> >> ychu066 wrote: >>> >>> what is that ? >>> >>> >>> >>> Hrishi Mittal wrote: >>>> >>>> Add col=i in the histogram call. >>>> >>> >>> >> >> > > -- > View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26421465.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT
ychu066
2009-Nov-20 02:45 UTC
[R] How do I change the colour and format for the trelli plot ?
I AM REALLY LOST ......... ychu066 wrote:> > I want to change the colour of the histogram in each panel by the levels > of the conoditonal factor. > > I have 3 levels in the factor > > levels(data[,2])[1] > levels(data[,2])[2] > levels(data[,2])[3] > > what can i do , in order to chnage the colour ?? > > > > ychu066 wrote: >> >> Fore example my code is >> histogram(~data[,8]|data[,2], ylab = "Frequency", xlab = "Score", xlim >> c(1,5), ylim = c(0,100),layout = c(3,1),col=data[,2] ) >> >> and i want the colour to be depended on the level of the factor in >> data[,2]. how do i do that ? >> >> >> >> >> >> ychu066 wrote: >>> >>> what is that ? >>> >>> >>> >>> Hrishi Mittal wrote: >>>> >>>> Add col=i in the histogram call. >>>> >>> >>> >> >> > >%-|%-|%-|%-|%-|%-|%-| -- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26422110.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-23 01:46 UTC
[R] How do I change the colour and format for the trelli plot ?
NICE!!! thanks Deepayan Sarkar wrote:> > On Thu, Nov 19, 2009 at 6:03 AM, ychu066 <ychu066 at aucklanduni.ac.nz> > wrote: >> >> http://old.nabble.com/file/p26418382/hist1.png hist1.png ?i want three >> plots >> along on the side , how to i do that ? >> >> ?and I also want to change the colour of the bars for each plot, how do i >> do >> that ? >> >> i got the code here to draw that .. > > This code did not produce the plot you have linked to. The answer to > your question depends on how you created the plot, so you have to tell > us that. Changing the color in all panels is easy: > > histogram(rnorm(100), col = "goldenrod") > > Different colors in different panels is a little more work: > > histogram(~rnorm(100) | gl(3, 1, 100), > mycolors = sample(colors(), 3), > panel = function(..., col, mycolors) { > panel.histogram(..., col = mycolors[panel.number()]) > }) > > -Deepayan > >> columns <- 8:153 >> plots <- vector("list", length(columns)) >> j <- 0 >> for (i in columns) >> { >> ?plots[[ j <- j+1 ]] <- >> ? ?histogram( ~ data[,i], >> ? ? ?ylab = "Frequency", xlab = "Score", >> ? ? ?xlim = c(1,5), ylim = c(0,100), >> ? ? ?main = colnames(data)[i] >> ? ?) >> } >> >> print(plots[[1]]) >> >> # or export >> >> for (i in seq_along(plots)) >> { >> ?png(paste("hist", i, ".png", sep = "")) >> ?print(plots[[i]]) >> ?dev.off() >> } >> -- >> View this message in context: >> http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26418382.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> > > ______________________________________________ > 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. > >-- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26471627.html Sent from the R help mailing list archive at Nabble.com.
ychu066
2009-Nov-23 01:58 UTC
[R] How do I change the colour and format for the trelli plot ?
anyone know how to add some text on the panel ??? for example 2.5, 50 and 1000 are mearsured in Litre, and i want to put the units beside the measurements. How could i do that? ychu066 wrote:> > NICE!!! thanks > > Deepayan Sarkar wrote: >> >> On Thu, Nov 19, 2009 at 6:03 AM, ychu066 <ychu066 at aucklanduni.ac.nz> >> wrote: >>> >>> http://old.nabble.com/file/p26418382/hist1.png hist1.png ?i want three >>> plots >>> along on the side , how to i do that ? >>> >>> ?and I also want to change the colour of the bars for each plot, how do >>> i do >>> that ? >>> >>> i got the code here to draw that .. >> >> This code did not produce the plot you have linked to. The answer to >> your question depends on how you created the plot, so you have to tell >> us that. Changing the color in all panels is easy: >> >> histogram(rnorm(100), col = "goldenrod") >> >> Different colors in different panels is a little more work: >> >> histogram(~rnorm(100) | gl(3, 1, 100), >> mycolors = sample(colors(), 3), >> panel = function(..., col, mycolors) { >> panel.histogram(..., col = mycolors[panel.number()]) >> }) >> >> -Deepayan >> >>> columns <- 8:153 >>> plots <- vector("list", length(columns)) >>> j <- 0 >>> for (i in columns) >>> { >>> ?plots[[ j <- j+1 ]] <- >>> ? ?histogram( ~ data[,i], >>> ? ? ?ylab = "Frequency", xlab = "Score", >>> ? ? ?xlim = c(1,5), ylim = c(0,100), >>> ? ? ?main = colnames(data)[i] >>> ? ?) >>> } >>> >>> print(plots[[1]]) >>> >>> # or export >>> >>> for (i in seq_along(plots)) >>> { >>> ?png(paste("hist", i, ".png", sep = "")) >>> ?print(plots[[i]]) >>> ?dev.off() >>> } >>> -- >>> View this message in context: >>> http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26418382.html >>> Sent from the R help mailing list archive at Nabble.com. >>> >>> ______________________________________________ >>> 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. >>> >> >> ______________________________________________ >> 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. >> >> > >http://old.nabble.com/file/p26471713/hist1.png hist1.png -- View this message in context: http://old.nabble.com/How-do-I-change-the-colour-and-format-for-the-trelli-plot---tp26418382p26471713.html Sent from the R help mailing list archive at Nabble.com.