dev.new(width=6, height=1.5,mar=c(0,0,0,0)) par(mfrow=c(1,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0)) barplot(c(1,1,1,1,1,1),col=c("blue","purple","red","green","orange","yellow"), axes = FALSE) I have a barplot that returns six colors in a line. I would like to get the same six color blocks in a hexagram layout (if it were a clock, the blocks would be at 12, 2, 4, 6, 8 and 10 o'clock). Is this possible with R? I do not know java or c++ to make this with GUI, so I have been doing it in R instead and it has worked great, except now I need to change the layout just a bit. Thank you, Adele ----- In theory, practice and theory are the same. In practice, they are not - Albert Einstein -- View this message in context: http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3807600.html Sent from the R help mailing list archive at Nabble.com.
I'm not sure this is the right location (maybe R-devel would be better). ----- In theory, practice and theory are the same. In practice, they are not - Albert Einstein -- View this message in context: http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3807608.html Sent from the R help mailing list archive at Nabble.com.
I will try stacking 5 barplots (with 5 bars per plot) and somehow only showing the middle bar for the top and bottom plots and the two end bars for the two middle plots. ----- In theory, practice and theory are the same. In practice, they are not - Albert Einstein -- View this message in context: http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3807939.html Sent from the R help mailing list archive at Nabble.com.
Here is the new code. It works just like I wanted. dev.new(width=6, height=6.5,mar=c(0,0,0,0)) par(mfrow=c(5,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0)) barplot(c(1,1,1,1,1),col=c("white","white","red","white","white"), axes FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("orange","white","white","white","yellow"), axes = FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("white","white","white","white","white"), axes FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("blue","white","white","white","green"), axes FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("white","white","brown","white","white"), axes FALSE,border=NA) ----- In theory, practice and theory are the same. In practice, they are not - Albert Einstein -- View this message in context: http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3807953.html Sent from the R help mailing list archive at Nabble.com.
I updated the code as follows: dev.new(width=2.5, height=3,mar=c(0,0,0,0)) par(mfrow=c(5,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0)) barplot(c(1,1,1,1,1),col=c("white","white","red","white","white"), axes FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("orange","white","white","white","yellow"), axes = FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("white","white","white","white","white"), axes FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("blue","white","white","white","green"), axes FALSE,border=NA) barplot(c(1,1,1,1,1),col=c("white","white","brown","white","white"), axes FALSE,border=NA) I added the middle plot to add a space between the two middle barplots. The problem is that it is a bit too large of a space (they are further apart than the other points). I tried adjusting different options - mar, mgp, omd - of par and the "height" option of barplot and none of them seemed to help. Do you have any ideas of how to make the invisible middle plot a bit shorter or the plots above and below the middle slightly closer? Thank you, Adele ----- In theory, practice and theory are the same. In practice, they are not - Albert Einstein -- View this message in context: http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3808044.html Sent from the R help mailing list archive at Nabble.com.
On 09/13/2011 03:08 AM, Schatzi wrote:> I updated the code as follows: > dev.new(width=2.5, height=3,mar=c(0,0,0,0)) > par(mfrow=c(5,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0)) > barplot(c(1,1,1,1,1),col=c("white","white","red","white","white"), axes > FALSE,border=NA) > barplot(c(1,1,1,1,1),col=c("orange","white","white","white","yellow"), axes > = FALSE,border=NA) > barplot(c(1,1,1,1,1),col=c("white","white","white","white","white"), axes > FALSE,border=NA) > barplot(c(1,1,1,1,1),col=c("blue","white","white","white","green"), axes > FALSE,border=NA) > barplot(c(1,1,1,1,1),col=c("white","white","brown","white","white"), axes > FALSE,border=NA) > > I added the middle plot to add a space between the two middle barplots. The > problem is that it is a bit too large of a space (they are further apart > than the other points). I tried adjusting different options - mar, mgp, omd > - of par and the "height" option of barplot and none of them seemed to help. > Do you have any ideas of how to make the invisible middle plot a bit shorter > or the plots above and below the middle slightly closer? >Hi Adele, If you just want six rectangles on a white field, it might be simpler to make a blank plot: plot(0,xlim=c(-2,2),ylim=c(-2,2),type="n",axes=FALSE,xlab="",ylab="") and then display some rectangles: rect(c(-0.5,-2,-2,-0.5,1,1),c(-1.8,-1.2,0.2,0.8,0.2,-1.2), c(0.5,-1,-1,0.5,2,2),c(-0.8,-0.2,1.2,1.8,1.2,-0.2), col=c("brown","blue","orange","red","yellow","green")) You can make it into a function that would display different heights in a "hexagonal" pattern. Jim
I decided to go with circles instead of rectangles. Thank you for your help. Here is the new code: dev.new(width=2.5, height=3,mar=c(0,0,0,0)) par(mfrow=c(1,1),mar=c(0,0,0,0)) x=c(-1,1,1,-1,-3,-3,5) y=c(1.2,0.6,-.7,-1.3,-.7,0.6,5) plot(0,xlim=c(-4,2),ylim=c(-2,2),type="n",axes=FALSE,xlab="",ylab="") symbols(x,y,circles=c(1,1,1,1,1,1,4), bg=c("brown","blue","orange","red","yellow","green","white"),fg="white",add=TRUE) I added in the "white" one because that makes all the circles smaller. I tried changing the radii of the circles, but it seems they are relative so I made a white one big and the rest small. ----- In theory, practice and theory are the same. In practice, they are not - Albert Einstein -- View this message in context: http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3811046.html Sent from the R help mailing list archive at Nabble.com.