similar to: [R ]Plot a colored rectangle under the points of a graph

Displaying 20 results from an estimated 11000 matches similar to: "[R ]Plot a colored rectangle under the points of a graph"

2007 Jan 24
2
modify rectangle color from image
Hi, I need some suggestion on how I could modify the color on some rectangle that I have created using "image". In other words, I have a 5x5 matrix, say, m. m <- matrix(rnorm(25), nrow=5) I create a grid of rectangles by: image(m) Now I want to change the color of rectangle (3,3) to blue. I don't know how this could be done, and searching the web has
2011 Jul 15
2
plot a vertical column of colored rectangles
Hi, I've been really struggling with this. If I have a vector like dat <- c(0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0) I want to plot each element as a colored rectangle (red=1, blue=1) in the right order, so they all stack up forming a vertical column on the graph. Sort of like a building, with each floor in the appropriate color. Any ideas? I've tried using ggplot and geom_tile, but my
2008 Apr 08
2
diagonally fill a rectangle with color gradient
Hi, Is it possible to diagonally fill a rectangle with a color gradient? I noticed that the gradient.rect of plotrix could fill a rect either up and down or from side to side. I am looking for something similar but fills diagonally instead, e.g., from the upper left corner to the bottom right. Does anyone know how to do it in R? Thanks, -- Tom [[alternative HTML version deleted]]
2006 Jul 29
3
placing rectangle behind plot
I am trying to create a lattice plot and would like to later, i.e. after the plot is drawn, add a grey rectangle behind a portion of it. The following works except that the rectrangle is on top of and obscures a portion of the chart. I also tried adding col = "transparent" to the gpar list but that did not help -- I am on windows and perhaps the windows device does not support
2010 Aug 15
2
Adding colored background area to a time series plot
Hi, I am trying to add a rectangular colored background area to a plot of a time series of relative price changes. I believe that what I'm trying to do is very similar to the question and example given here: http://www.mail-archive.com/r-help at stat.math.ethz.ch/msg73948.html http://www.mayin.org/ajayshah/KB/R/html/g5.html My problem/difference is that my time series looks like so: >
2004 Dec 14
2
drawing a rectangle through multiple plots
How do I draw a rectangle across multiple plots on a device? E.g., def.par <- par(no.readonly = TRUE) par(mfrow = c(3, 1)) plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") rect(2, -4, 3, 4) par(def.par) I want the rectangle to extend across the whole device. How
2004 Dec 02
2
Drawing a rectangle around a barplot()
Hi I want to draw a rectangle behind a barplot such that it highlights those particular bars from the rest of the plot. I have figured out how to draw a barplot(), and then how to draw a rectangle of the correct shape and size (using rect()), but when I use rect() it draws over the top of the bars, and then when I re-draw the bars, it draws with a white background, thus eliminating my rectangle!
2008 Jul 26
1
the C function drawing a rectangle: heatmap() -> image() -> do_image() -> GRect() -> GERect() -> rect() -> do_rect() -> GRect() ??
Hello anyone used to do similar things: search for the final C function that corresponding to the drawing of a rectangle? As listed in the subject, I started from heatmap() in R and after several steps reached the GRect() in C. However, then it refers to rect() which further seems to refer to do_rect(), and then, surpringly, do_rect refers to GRect()!!! A dependency circle! How can it work if no
2008 Feb 27
2
Add a rectangle behind a plot
Hi there, I found one reference to add a reactangle behind a plot using plot(...,add=T), I tried this but didn't obtain the desired result. If a I have the following code: plot(x,y) rect(xleft, ybottom, xright,ytop,col='green) The rectangle appear on top of the plot. Any help will be greatly appreciated, Judith
2009 Apr 14
1
Lattice xyplot: Line and Rectangle in legend.
Hello fellow R users, I have a problem. I have created a barchart overlayed by an xyplot line, both of which read off the same Y axis. The problem comes when I try to generate a key. It seems that I can only create either two lines, or two rectangles. I would much prefer to have the barchat series depicted by a rectangle, and the xyplot series by a line. Is there a way to do this? Your help
2008 Oct 16
1
draw a 5cm x 3cm rectangle
Hi I want to draw sth in a pdf file with a predefined defined size. Say a 5cm x 3cm rectangle (a ruler): pdf("rect.pdf", paper="a4") plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes="n") dev.off() but how do I fix that one unit is 1cm? Thanks thomas
2011 May 09
2
Creating Observation ID
If I have a data frame something like: Value=rnorm(30) Group = sample(c('A','B','C'), 30, replace=TRUE) df = data.frame(Value, Group) It seems like it should be simple to create an 'ObsID' column which indicates the observation order of each Value within each of the 3 groups. Somehow, I can't quite see how to do it without manually sub-setting the parent data
2010 Mar 21
2
Find a rectangle of maximal area
For an application in image processing -- using R for statistical purposes -- I need to solve the following task: Given n (e.g. n = 100 or 200) points in the unit square, more or less randomly distributed. Find a rectangle of maximal area within the square that does not contain any of these points in its interior. If a, b are height and width of the rectangel, other constraints may have to be
2011 May 19
2
recursive function
Hi, I created a function for obtaining the normal cumulative distribution (I know all this already exists in R, I just wanted to verify my understanding of it). below is the code I came up with. cdf<-function(x) { erf<-function(x) { # approximation to the error function (erf) of the # normal cumulative distribution function # from Winitzki
2013 Mar 22
4
ggplot2 will not draw a rectangle. Error: ggplot2 doesn't know how to deal with data of class XXX"
What am I missing? When I run the code below I get the error message "Error: ggplot2 doesn't know how to deal with data of class function" Googling suggests a message of "Error: ggplot2 doesn't know how to deal with data of class XXX" is not uncommon but I don't see why I am getting a "function" error unless I am using some reserved word?
2005 Dec 08
1
grid graphics gpar(fill) argument and jpeg device
Hi everybody, I just notice a strange behaviour of gpar's fill argument when using non-postscript devices: The default of the argument is transparent (according to get.gpar("fill")). So as expected, the following code draws a nice red rectangle in the middle of my X11 or postscript device. pushViewport(viewport(width=0.5, height=0.5)) grid.rect(gp=gpar(fill="red"))
2012 Oct 09
2
plot.new() and grid functions in multipage pdfs
Hi, when using the grid package, I've come across this weird behaviour where a call to plot.new() will start a new page for a multi-page pdf, but then the margins will somehow behave strangely for all but the first page: here is some code: pdf("test.pdf"); plot.new(); grid.rect(gp = gpar(fill="blue")); plot.new(); grid.rect(gp = gpar(fill="blue")); dev.off()
2011 May 20
5
regression coefficient for different factors
Dear R-helpers, In my dataset I have two continuous variable (A and B) and one factor. I'm investigating the regression between the two variables usign the command lm(A ~ B, ...) but now I want to know the regression coefficient (r2) of A vs. B for every factors. I know that I can obtain this information with excel, but the factor have 68 levels...maybe [r] have a useful command. Thanks,
2009 Oct 14
1
rect function
Dear all, I have a question about how to load data or (entering data )to each cell of a rectangle created by rect . e.g. I have a matrix rbind(1:2,1:2) I have created a 2x2 rectangle by using: a<-0:1/10 b<-0:1/10 kk<-expand.grid(a,b) plot.new() rect(kk[, 1], kk[, 2], kk[, 1] + .1,kk[, 2] + .1) so how do we put the value of rbind(1:2,1:2) into the relevant
2018 Jul 16
2
persp command
Dear R-devel mailing list, I am wondering whether the "theta" and "phi" parameters of the "persp" function in the graphics commands are named in error (the names seem to have been swapped). Also, in the documentation to "persp", reference is made to "colatitude" when the effect in the image is actually that of "latitude". Thank you,