While using xyplot or barchart, how does on move the x or y axis? I am trying to plot ratios ranging from 0.77 to 1.3 in a bargraph, with the y axis at x = 1. I want ratios greater than 1 to appear as on the right side of the y-axis and the ratios less than 1 to appear on the left. My dataframe US looks like this State Ratio MA 1.3 CT 1.02 TX 0.9 AK 0.77 When I do barchart(formula = State ~ Ratio, data = US), the y axis is positioned at x = 0.7. How do I move it to x = 1? Thanks, Nirmala
On Tuesday 21 January 2003 02:19 pm, Nirmala Ravishankar wrote:> While using xyplot or barchart, how does on move the x or y axis? I am > trying to plot ratios ranging from 0.77 to 1.3 in a bargraph, with the y > axis at x = 1. I want ratios greater than 1 to appear as on the right side > of the y-axis and the ratios less than 1 to appear on the left. > > > My dataframe US looks like this > > State Ratio > > MA 1.3 > CT 1.02 > TX 0.9 > AK 0.77 > > When I do barchart(formula = State ~ Ratio, data = US), the y axis is > positioned at x = 0.7. How do I move it to x = 1?This feature is currently missing (but planned for the future). This was discussed a while back, and a panel function which does this was posted. Try looking at the thread starting with https://www.stat.math.ethz.ch/pipermail/r-help/2002-December/052506.html Deepayan
So, I am trying to label the points in a graph, but cannot quite figure out how to use ltext. I get an error about the lengths of x and y not being the same, when I have defined them as the same.> a <- data.frame(num = 1:4) > a$country <- c("A", "B", "C", "D") > a$p <- c(0.34, .54, .41, .33) > a$q <- c(.07, .03, .05, .10)> anum country p q 1 1 A 0.34 0.07 2 2 B 0.54 0.03 3 3 C 0.41 0.05 4 4 D 0.33 0.10> xyplot(p ~ q, data = a, ltext(x=x, y=y, label = a$country))Error in xy.coords(x, y) : x and y lengths differ> xyplot(p ~ q, data = a, groups = as.character(a$country), ltext(x=x,y=y, label = groups[subscripts])) Error in xy.coords(x, y) : x and y lengths differ - Nirmala