boxplot

full text label on Boxplot, with added mean point

南笙酒味 提交于 2019-12-05 20:03:29
This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . Am trying to get text label similar to what this https://stats.stackexchange.com/questions/8206/labeling-boxplots-in-r , but I cant get it to work. MWE similar to what I have is this: data <- data.frame(replicate(5,sample(0:100,100,rep=TRUE))) meanFunction <- function(x){ return(data.frame(y=round(mean(x),2),label=round(mean(x,na.rm=T),2)))} ggplot(melt(data), aes(x=variable, y=value)) + geom_boxplot(aes(fill=variable), width = 0.7) + stat_summary(fun.y = mean, geom="point"

How can I resize the boxes in a boxplot created with R and ggplot2 to account for different frequencies amongst different boxplots? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-05 14:07:43
This question already has answers here : Is there an equivalent in ggplot to the varwidth option in plot? (2 answers) Closed 5 years ago . I have a boxplot that I made in R with ggplot2 analagous to the sample boxplot below. The problem is, for the values on the y axis (in this sample, the number of cylinders in the car) I have very different frequencies -- I may have included 2 8 cylinder cars, but 200 4 cylinder cars. Because of this, I'd like to be able to resize the boxplots (in this case, change the height along the y axis) so that the 4 cylinder boxplot is a larger portion of the chart

Add multiple horizontal lines in a boxplot

╄→尐↘猪︶ㄣ 提交于 2019-12-05 14:05:48
I know that I can add a horizontal line to a boxplot using a command like abline(h=3) When there are multiple boxplots in a single panel, can I add different horizontal lines for each single boxplot? In the above plot, I would like to add lines 'y=1.2' for 1, 'y=1.5' for 2, and 'y=2.1' for 3. I am not sure that I understand exactly, what you want, but it might be this: add a line for each boxplot that covers the same x-axis range as the boxplot. The width of the boxes is controlled by pars$boxwex which is set to 0.8 by default. This can be seen from the argument list of boxplot.default :

Can I get boxplot notches in ggplot2?

£可爱£侵袭症+ 提交于 2019-12-05 14:03:42
问题 Yes, I know it's been around, I've also found Hadley's answer on google groups that there is no notches yet for ggplot2 boxplots. So my question is twofold: Has this changed (there's a native implementation of notches already) and if not is there something one could do about it. I mean I do not need the notch optic, representing the confidence bounds by some shaded area that is suitably placed in another layer over the boxplot, would look nice, too. Also added a screenshot because I heard a

NA's are being plotted in boxplot ggplot2

蓝咒 提交于 2019-12-05 12:05:50
问题 I'm trying to plot a v. simple boxplot in ggplot2. I have species richness vs. landuse class. However, I have 2 NA's in my data. For some strange reason, they're being plotted, even when they're being understood as NA's by R. Any suggestion to remove them? The code I'm using is: ggplot(data, aes(x=luse, y=rich))+ geom_boxplot(mapping = NULL, data = NULL, stat = "boxplot", position = "dodge", outlier.colour = "red", outlier.shape = 16, outlier.size = 2, notch = F, notchwidth = 0.5)+ scale_x

How to save boxplot to as to a variable?

老子叫甜甜 提交于 2019-12-05 08:52:03
How can I save the box plot as a variable in R? For example, if I did like this, plot <- boxplot(count ~ spray, data = InsectSprays, col = "lightgray") when I call plot, I want it shows the box plot, that I don't need to run the command for plotting boxplot every time. Does anyone have any idea? The following does it. Call after that recordedPlot boxplot(count ~ spray, data = InsectSprays, col = "lightgray") recordedPlot = recordPlot() dev.off() 来源: https://stackoverflow.com/questions/27064296/how-to-save-boxplot-to-as-to-a-variable

matplotlib: inset axes for multiple boxplots

耗尽温柔 提交于 2019-12-05 08:51:47
I have a few boxplots in matplotlib that I want to zoom in on a particular y-range ([0,0.1]) using inset axes . It is not clear to me from the example in the documentation how I should do this for multiple boxplots on the same figure. I was trying to modify the code provided this example, but there was too much unnecessary complexity. My code is pretty simple: # dataToPlot is a list of lists, containing some data. plt.figure() plt.boxplot(dataToPlot) plt.savefig( 'image.jpeg', bbox_inches=0) How do I add inset axes and zoom in on the first boxplot of the two? How can I do it for both? EDIT: I

How can I change 'PlotStyle' property of a given boxplot figure?

那年仲夏 提交于 2019-12-05 08:01:33
Given a .fig file of a Matlab boxplot (i.e. underlying data not available), is it possible to change the PlotStyle attribute (from 'traditional' to 'compact')? This question is kind of tricky because not like other graphic objects in Matlab, boxplot is a group of lines. As so, all the properties that are set while you create it are inaccessible (and in fact does not exist) after plotting. One option to deal with that is to create a 'dummy' boxplot, and then alter it to your data. Because boxplot has no simple properties of XData and YData , at least not as we use to them, it takes some work to

ggplot2: boxplot with all points distributed evenly in a row

╄→гoц情女王★ 提交于 2019-12-05 07:52:37
I have a boxplot generated with the following code: b.males <- c(6, 7, 8, 8, 8, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 14, 15) b.females <- c(14, 13, 12, 12, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7) b.total<-c(b.males,b.females) b.m<-data.frame(b.males) b.f<-data.frame(b.females) b.t<-data.frame(b.total) myList<-list(b.m, b.f, b.t) df<-melt(myList) colnames(df) <- c("class","count") plt<-ggplot(df, aes(x=class,y=count))+geom_boxplot() plt + geom_point(aes(x = as.numeric(class) + 0, colour=class)) What I'd like to do is, for any given y-axis point, show all individual points in a row.

ggplot increase distance between boxplots

强颜欢笑 提交于 2019-12-05 07:45:48
How can I avoid attached box-plots? Thank you ggplot(df, aes(x=factor(time), y=val, fill=ID))+ geom_boxplot()+ scale_fill_manual(values=c(WT="goldenrod3", KO="steelblue")) Look at position_dodge , the width argument can help with spacing mtcars$sep <- 1:2 # a factor ggplot(mtcars, aes(x=factor(carb), y=mpg, fill=factor(sep))) + geom_boxplot(position=position_dodge(width=0.8)) 来源: https://stackoverflow.com/questions/32342616/ggplot-increase-distance-between-boxplots