I have a problem with the ylabs in barplot. When I draw the bars horizontal the text for the y axis is not drawn horizontal too. The text remains vertical. How can I change that. Thank's for your advice. There is an example below. ##Example plot.new() jib <- data.frame(c(1:15),c(11:25),c(15:1),c(25:11)) colnames(jib) <- c("eins","zwei","drei","vier") rownames(jib) <- c("AT", "BE", "DK", "FI", "FR", "DE", "GR", "IE", "IT", "LU", "NL", "PT", "ES", "SE", "UK" ) jib <- as.matrix(jib) jib <- t(jib) barplot(jib, horiz=TRUE) jib ## End Example
Try this: bp <- barplot(jib, horiz=TRUE, yaxt = 'n') axis(2, at = bp, labels = colnames(jib), tick = FALSE, las = 2) On Mon, Jun 2, 2008 at 10:00 AM, dat <naor@gmx.at> wrote:> > I have a problem with the ylabs in barplot. When I draw the bars horizontal > the text for the y axis is not drawn horizontal too. > The text remains vertical. How can I change that. Thank's for your advice. > There is an example below. > > > ##Example > plot.new() > jib <- data.frame(c(1:15),c(11:25),c(15:1),c(25:11)) > colnames(jib) <- c("eins","zwei","drei","vier") > rownames(jib) <- c("AT", "BE", "DK", "FI", "FR", "DE", > "GR", "IE", "IT", "LU", "NL", "PT", "ES", "SE", "UK" ) > jib <- as.matrix(jib) > jib <- t(jib) > barplot(jib, horiz=TRUE) > jib > ## End Example > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Dear dat, Try this: barplot(jib, horiz=TRUE,las=1) HTH, Jorge On Mon, Jun 2, 2008 at 9:00 AM, dat <naor@gmx.at> wrote:> > I have a problem with the ylabs in barplot. When I draw the bars horizontal > the text for the y axis is not drawn horizontal too. > The text remains vertical. How can I change that. Thank's for your advice. > There is an example below. > > > ##Example > plot.new() > jib <- data.frame(c(1:15),c(11:25),c(15:1),c(25:11)) > colnames(jib) <- c("eins","zwei","drei","vier") > rownames(jib) <- c("AT", "BE", "DK", "FI", "FR", "DE", > "GR", "IE", "IT", "LU", "NL", "PT", "ES", "SE", "UK" ) > jib <- as.matrix(jib) > jib <- t(jib) > barplot(jib, horiz=TRUE) > jib > ## End Example > > ______________________________________________ > R-help@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.[[alternative HTML version deleted]]
on 06/02/2008 08:00 AM dat wrote:> > I have a problem with the ylabs in barplot. When I draw the bars > horizontal the text for the y axis is not drawn horizontal too. > The text remains vertical. How can I change that. Thank's for your advice. > There is an example below. > > > ##Example > plot.new() > jib <- data.frame(c(1:15),c(11:25),c(15:1),c(25:11)) > colnames(jib) <- c("eins","zwei","drei","vier") > rownames(jib) <- c("AT", "BE", "DK", "FI", "FR", "DE", > "GR", "IE", "IT", "LU", "NL", "PT", "ES", "SE", "UK" ) > jib <- as.matrix(jib) > jib <- t(jib) > barplot(jib, horiz=TRUE) > jib > ## End ExampleA lot of what you are doing above with respect to managing/structuring the example data is not needed, nor is the plot.new(). Here is your jib: > jib AT BE DK FI FR DE GR IE IT LU NL PT ES SE UK eins 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 zwei 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 drei 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 vier 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 Now use: jib2 <- matrix(c(1:15, 11:25, 15:1, 25:11), nrow = 4, byrow = TRUE) rownames(jib2) <- c("eins", "zwei", "drei", "vier") colnames(jib2) <- c("AT", "BE", "DK", "FI", "FR", "DE", "GR", "IE", "IT", "LU", "NL", "PT", "ES", "SE", "UK" ) > jib2 AT BE DK FI FR DE GR IE IT LU NL PT ES SE UK eins 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 zwei 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 drei 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 vier 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 # Now draw the plot, setting 'las' so the labels are # set to horizontal. See ?par for more information barplot(jib2, horiz = TRUE, las = 1) Data frames are best used when you have columns with differing data types (think database table or spreadsheet). When the data is of a single type, as in this case, just use a matrix directly. HTH, Marc Schwartz