search for: geom_density

Displaying 20 results from an estimated 27 matches for "geom_density".

2009 Mar 25
2
[ggplot2] Densityplot, grouping and NAs
Dear all, I do not fully understand how ggplot2 handles NAs. See the following example: library(ggplot2) x <- rnorm(150) g <- as.factor(c(rep(c(0,1,NA),50))) mydf <- data.frame(x,g) m <- ggplot(aes(x = x, group = g, color = g), data = mydf) m + geom_density() How do I get rid of the NAs (i.e. the blue colored curve)? I thought ## m <- ggplot(aes(x = x, group = g, color = g, na.rm = TRUE), ## data = mydf) ## m + geom_density() or ## m <- ggplot(aes(x = x, group = g, color = g), data = mydf) ## m + geom_density() ## m + stat_density(na.rm =...
2011 Jun 07
1
ggplot2 Histogram with density curve
I am learning ggplot2 commands and I have figured out how to create histograms and density curves but I am not sure how to add a density curve on top of a histogram. Here are the two graphs that I created. ## Histogram t<-rnorm(500) w<-qplot(t, main="Normal Random Sample", fill=I("blue"), colour=I("black"), geom="histogram") w ##Density Curve
2011 Jul 06
2
how to best present concentrated data points/ ggplot2
...hts.y <- abs(b/sum(b)) weight <- c(weights.x, weights.y) ze <- rep(0,10000) type <- c(rep("a",5000), rep("b",5000)) d <- data.frame(expo = x, weight = weight, type = type, ze = ze) m <- ggplot(d, aes(x = expo, group = type, col = type, weight = weight)) m+geom_density()+geom_point(aes(x = expo, y = ze, shape = type))
2009 Aug 19
3
ggplot 2 semi-transparency error
Hi, I used the command ggplot as follows... p<-ggplot(a,aes(x=a$V1,colour=a$V2,fill=a$V2)) p + geom_density(alpha = 0.2,xlim=c(-10,10),ylim=c(0,0.5)) when I say, dev.print(device=postscript,file="/alpha/dct.pdf") I get Warning message: In grid.Call.graphics("L_polygon", x$x, x$y, list(as.integer(1L:length(x$x)))) : semi-transparency is not supported on this device: reported only o...
2012 Aug 06
4
Overlay Histogram
Dear all, For two sets of random variables, say, x <- rnorm(1000, 10, 10) and y <- rnorm(1000. 3, 20). Is there any way to overlay the histograms (and density curves) of x and y on the plot of y vs. x? The histogram of x is on the x axis and that of y is on the y axis. The density curve here is to approximate the shape of the distribution and does not have to have area 1. Thank you
2008 Jul 24
1
ggplot question
...each with an alpha =0.25). I have tried a number of variations of the following, but cannot find a way to define the colour of the fill, its transparency and the line around it individually - something in the syntax continues to defy me. ggplot(data.plot, aes(x=x, y=..density..))+ geom_density(aes(group=group)) I am sure a simple solution is out there. Any help appreciated, Scott _____________________________ Dr. Scott Williams MBBS BScMed FRANZCR Radiation Oncologist Peter MacCallum Cancer Centre Melbourne, Australia ph +61 3 9656 1111 fax +61 3 9656 1424 scott.will...
2009 Jul 28
2
Density plot in ggplot2
Hi all, I was trying to draw a stacked density plot like that : library(ggplot2); library(plyr) dat <- cbind(rnorm(300), rep(c(1,2), each=150)) ggplot() + geom_density(aes(x=dat[,1], fill=factor(dat[,2]), position="stack")) + xlab("") + ylab("") + scale_colour_manual(name = "Pallet", labels = c("X", "Y")) Here everything is ok, except few points : 1. I want to remove the name of y-...
2007 Nov 08
1
ggplot2 facets as rows and columns
...x | system, data = TDBU, xlab = "LRR Effect Size",type="density", panel = function(x, ...) { panel.histogram(x, ...) panel.densityplot(x,...) } ) library(ggplot2) ggplot(TDBU,aes(x=x))+geom_histogram(aes(y=..density..))+ geom_density()+facet_grid(system~.) -- View this message in context: http://www.nabble.com/ggplot2-facets-as-rows-and-columns-tf4771000.html#a13647294 Sent from the R help mailing list archive at Nabble.com.
2009 Sep 02
1
Howto Superimpose Multiple Density Curves Into One Plot
I have a data that looks like this: http://dpaste.com/88561/plain/ And I intend to create multiple density curve into one plot, where each curve correspond to the unique ID. I tried to use "sm" package, with this code, but without success. __BEGIN__ library(sm) dat <- read.table("mydat.txt"); plotfn <- ("~/Desktop/flowgram_superimposed.pdf"); pdf(plotfn);
2008 Mar 04
1
ggplot2 - Problem with grid plot
...wo density plots (colored by factor) and two vertical lines at the respective medians (also colored by the factor). Using the diamonds dataset as an example, the following commands give me price density plots by factor cut in a single, ungridded plot. p <- ggplot(data=diamonds, aes(x=price)) + geom_density(aes(color=cut)) p I can add vertical lines at the medians of each density as follows. medians <- data.frame(cut=levels(diamonds$cut), intercept=tapply(diamonds$price, list(diamonds$cut), median)) p + geom_vline(data=medians, aes(color=factor(cut))) I can create a gridded plot of price dens...
2008 Jan 15
4
Overlay plots from different data sets using the Lattice package
#After spending the entire day working on this question, I have decided to reach out for support: #I am trying to overlay a densityplot from one data set over a histogram of another, if I were to plot the two individually, they would look like: # data frame construction data.frame.A <- data.frame(rnorm(12*8), c(rep("one", 4), rep("two", 4), rep("three", 4)),
2020 Aug 24
2
(sin asunto)
Buenas tardes, tengo una variable bimodal (*var)*, de presencias y ausencias (1s y 0s) y otra variable, *prob*, con las probabilidades que le asigna un modelo (entre 0 y 1). Con: *ggplot(Preds, aes(x=prob, fill= var )) + geom_density(alpha=.3)* obtengo la distribución de las presencias y de las ausencias, por separado, en función del valor de probabilidad asignado. Las dos curvas se cruzan en un punto. ¿Sabéis si hay forma de averiguar el valor de *prob* de ese punto analíticamente? Gracias, Manuel [image: image.png] ---------...
2009 Aug 20
1
ggsave to .png bug in ggplot2 (?)
...p through ignorance. We'll see I guess. Here's the example. require(ggplot2) x <- data.frame(value=rnorm(5000, mean=0), case="A") y <- data.frame(value=rnorm(5000, mean=3), case="B") xy <- rbind(x, y) p <- ggplot(xy, aes(x=value, colour=case, group=case)) + geom_density() p ggsave(p, filename = "xy_ggsave.png") dev.print(device=png, width=600, height=600, file="xy_devprint.png") ggsave(p, filename = "xy_ggsave.pdf") dev.print(device=pdf, file="xy_devprint.pdf") -- View this message in context: http://www.nabble.com/gg...
2018 Apr 16
0
Fwd: Help with R-Calling forth csv.
...VI ALLA DATA PUNKTER ###### ggplot(data=tryck, aes(tryck[,1])) + geom_histogram(aes(y =..density..), breaks=seq(min(tryck[,1]-1), max(tryck[,1]+1), by = 0.5), col="black", fill="green", alpha = .2) + geom_density(col=2) + labs(title="Pressure for r?dmans?") + labs(x="Pressure [kPa]", y="Amount of vehicles (Percentage)")+ stat_function(fun=dnorm, colour="blue", args = list(mean = mean(tryck[,1]), sd = sd(tryck[,1]))) My problem now is to find a statistical...
2008 Apr 04
0
ggplot2 - version 0.6
...r * geom_boxplot: now has it's own legend which actually looks like a boxplot * geom_boxplot: reports if missing values removed * geom_crossbar: the middle line is now display thicker than the other lines, controlled by the parameter fatten (thanks to Heike Hofmann for the suggestion) * geom_density: fix scale adjustment bug in geom_density * geom_line, geom_text: all size measurements (now lines and text as well) are measured in mm, lines/paths default to paths 0.5mm wide * geom_rug: new to add marginal rug plots * geom_smooth: added example showing how to use geom_smooth with your own...
2008 Apr 04
0
ggplot2 - version 0.6
...r * geom_boxplot: now has it's own legend which actually looks like a boxplot * geom_boxplot: reports if missing values removed * geom_crossbar: the middle line is now display thicker than the other lines, controlled by the parameter fatten (thanks to Heike Hofmann for the suggestion) * geom_density: fix scale adjustment bug in geom_density * geom_line, geom_text: all size measurements (now lines and text as well) are measured in mm, lines/paths default to paths 0.5mm wide * geom_rug: new to add marginal rug plots * geom_smooth: added example showing how to use geom_smooth with your own...
2008 Feb 27
1
ggplot2 boxplot confusion
...ve read the density plot help and noticed the reference to ..density.. as a means to pass density data instead of original data. But I can't seem to get a boxplot to overlay a density plot. This is what I've got so far with consequent error message: m <- ggplot(mydata, aes(x=VALUE)) m + geom_density()+ geom_boxplot(aes(x=..density..)) Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 0, 180 I've tried y=..density.., both x= and y = ..density.. and neither and all fail somehow. Problem is I don't really understand what I'm doing at this...
2008 Aug 26
1
processing subset lists and then plot(density())
d <- structure(list(Site = structure(c(8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L,
2007 Oct 21
0
ggplot2 - version 0.5.6
...re identifiable) now work correctly * all ggplot objects should now print properly from the command line * fixed bug in geom_path when only 1 point * segments geom now works correctly for more coordinate systems * order variables in scatterplot matrix by order of variables in data.frame * geom_density deals with missing values correctly when displaying scaled densities * fixed bug in calculating categorical ranges * fixed bug in drawing error bars Subtractions * now relies on R 2.6 * removed grid.gedit and grid.gremove, and code replaced by grid.ls -- http://had.co.nz/ _____________...
2007 Oct 21
0
ggplot2 - version 0.5.6
...re identifiable) now work correctly * all ggplot objects should now print properly from the command line * fixed bug in geom_path when only 1 point * segments geom now works correctly for more coordinate systems * order variables in scatterplot matrix by order of variables in data.frame * geom_density deals with missing values correctly when displaying scaled densities * fixed bug in calculating categorical ranges * fixed bug in drawing error bars Subtractions * now relies on R 2.6 * removed grid.gedit and grid.gremove, and code replaced by grid.ls -- http://had.co.nz/ _____________...