boxplot

How to create geom_boxplot with large amount of continuous x-variables

◇◆丶佛笑我妖孽 提交于 2019-11-30 05:08:10
I have a data frame which contains x-axis numeric bins and continuous y-axis data across multiple categories. Initially, I created a boxplot by making the x-axis bins "factors", and doing a boxplot of the melted data. Reproducible data: x <- seq(1,10,by=1) y1 <- rnorm(10, mean=3) y2 <- rnorm(10, mean=10) y3<- rnorm(10, mean=1) y4<- rnorm(10, mean=8) y5<- rnorm(10, mean=12) df <- data.frame(x,y1,y2,y3,y4,y5) df.m <- melt(df, id="x") My code to create the x-axis data as a factor: df.m$x <- as.factor(df.m$x) My ggplot: ggplot(df.m, aes(x=x, y=value))+ geom_boxplot(notch=FALSE, outlier.shape=NA,

ggplot2: boxplot with facet_grid and free scale

我怕爱的太早我们不能终老 提交于 2019-11-30 04:19:23
问题 I am trying to have free scales on a Boxplot image with faceting. Using this example dataset, if I try this: ggplot(data=mpg) + geom_boxplot(aes(x=cty, y=model))+ facet_grid(manufacturer ~ drv, scales = "free", space = "free") Plot incorrect boxplot http://dl.dropbox.com/u/9788680/plot1.png Here, the free scales are implemented exactly as I would like, with the different scales for the y-axis depending on the number of available factors for a horizontal facet rule. The boxplots are however

r boxplot tilted labels x axis

大城市里の小女人 提交于 2019-11-30 03:30:42
问题 how can you rotate the labels of the x axis for boxplot in r? I know which code to use but I can't apply it: text(**????**, par("usr")[3] - 0.25, srt = 45, adj = 1, labels = labels, xpd = TRUE) What variable goes where I have the question marks? I created this boxplot: using this code: soil=read.csv("soil_temp_boxplot.csv", header=TRUE, sep=";") tiff("soil_boxplot.tiff") par(mar=c(5.5,3.5,0.5,0.5)) labels<-paste(c("RB-GL830-[16]-10","RB-GL830-[16]-30", "SB-GL834-[11]-10","SB-GL834-[11]-30",

Boxplots ranked by mean value

你。 提交于 2019-11-29 23:58:59
问题 I would like to show boxplots for multiple variables, and rank them by column means in descending order, just like in the Performance Analytics package. I use the following code to generate the boxplots: zx <- replicate (5, rnorm(50)) zx_means <- (colMeans(zx, na.rm = TRUE)) boxplot(zx, horizontal = FALSE, outline = FALSE) points(zx_means, pch = 22, col = "darkgrey", lwd = 7) So far I have not been able to come up with a way to rank them as described above. I have tried using both sort and

Sorting a boxplot based on median value

梦想与她 提交于 2019-11-29 22:55:37
I'd like to use R to make a series of boxplots which are sorted by median value. Suppose then I execute: boxplot(cost ~ type) This would give me some boxplots were cost is shown on the y axis and the type category is visible on the x-axis: ----- ----- | | [ ] | | [ ] | | ----- ----- A B However, what I'd like is the boxplot figures sorted from highest to lowest median value. My suspicion is that what I need to do is change the labels of the type (A or B) to numerically indicate which is the lowest and highest median value, but I wonder if there is a more clever way to solve the problem. Check

How to create a grouped boxplot in R?

倖福魔咒の 提交于 2019-11-29 19:39:04
问题 I want to merge the three datasets grouped and obtain a graph with only two boxes, 1 for A and 1 for B. Can you suggest how to get that? I'm tryng to create a grouped boxplot in R. I have 2 groups: A and B, in each group I have 3 subgroups with 5 measurements each. The following is the way that I constructed the boxplot, but if someone has a better, shorter or easy way to do, I'll appreciate A1 <- c(1,2,9,6,4) A2 <- c(5,1,9,2,3) A3 <- c(1,2,3,4,5) B1 <- c(2,4,6,8,10) B2 <- c(0,3,6,9,12) B3 <-

ggplot2 boxplot medians aren't plotting as expected

谁说我不能喝 提交于 2019-11-29 19:14:20
问题 So, I have a fairly large dataset (Dropbox: csv file) that I'm trying to plot using geom_boxplot . The following produces what appears to be a reasonable plot: require(reshape2) require(ggplot2) require(scales) require(grid) require(gridExtra) df <- read.csv("\\Downloads\\boxplot.csv", na.strings = "*") df$year <- factor(df$year, levels = c(2010,2011,2012,2013,2014), labels = c(2010,2011,2012,2013,2014)) d <- ggplot(data = df, aes(x = year, y = value)) + geom_boxplot(aes(fill = station)) +

Set color for xticklabels individually in matplotlib

一曲冷凌霜 提交于 2019-11-29 18:55:54
问题 How can I give the labels "a", "b", "c" individual colors (e.g. "a" in green, "b" in blue, "c" in red) in the example below? import numpy as np import matplotlib.pyplot as plt fig, ax = plt.subplots() p = plt.boxplot(np.random.normal(size=(10,3))) ax.set_xticklabels(list("abc")) plt.show() 回答1: The code: import numpy as np import matplotlib.pyplot as plt fig, ax = plt.subplots() p = plt.boxplot(np.random.normal(size=(10,3))) ax.set_xticklabels(list("abc")) [t.set_color(i) for (i,t) in zip([

How to add data to BoxPlot in WFA?

心已入冬 提交于 2019-11-29 17:14:11
I'm creating manually a boxplot chart. I have 4 double[] arrays with some calculations results that i want show on chart. I don't know how to connect correctly my arrays with chart Series. Here is my chart: Chart chart = new Chart(); chart.Series.Add("S1"); chart.Series.Add("S2"); chart.Series.Add("S3"); chart.Series.Add("S4"); chart.ChartAreas.Add("ChartArea1"); chart.ChartAreas[0].Visible = true; chart.ChartAreas[0].Position.Auto = true; chart.Series[0].ChartType = SeriesChartType.BoxPlot; chart.Series[1].ChartType = SeriesChartType.BoxPlot; chart.Series[2].ChartType = SeriesChartType

ggplot boxplot - length of whiskers with logarithmic axis

痞子三分冷 提交于 2019-11-29 16:05:25
I'm trying to create a horizontal boxplot with logarithmic axis using ggplot2. But, the length of whiskers are wrong. A minimal reproducible example: Some data library(ggplot2) library(reshape2) set.seed(1234) my.df <- data.frame(a = rnorm(1000,150,50), b = rnorm(1000,500,150)) my.df$a[which(my.df$a < 5)] <- 5 my.df$b[which(my.df$b < 5)] <- 5 If I plot this using base R boxplot() , everything is fine boxplot(my.df, log="x", horizontal=T) But with ggplot, my.df.long <- melt(my.df, value.name = "vals") ggplot(my.df.long, aes(x=variable, y=vals)) + geom_boxplot() + scale_y_log10(breaks=c(5,10,20