boxplot

change thickness median line geom_boxplot()

拜拜、爱过 提交于 2019-11-29 06:46:23
I want to do some modifications of a geom_boxplot(). Because my boxplots are really "small" sometimes (see yellow and green clade in the graphic here ) i want to highlight the median even more. so is it possible to adjust the thickness of the median line? This solution is not obvious from the documentation, but luckily does not require us to edit the source code of ggplot2 . After digging through the source of ggplot2 I found that the thickness of the median line is controlled by the fatten parameter. By default fatten has a value of two: require(reshape) require(ggplot2) cars_melt = melt(cars

Boxplots for groups?

谁说胖子不能爱 提交于 2019-11-29 06:21:06
问题 I have a dataset (test) as given below: Type Met1 Met2 Met3 Met4 TypeA 65 43 97 77 TypeA 46 25 76 77 TypeA 44 23 55 46 TypeA 46 44 55 77 TypeA 33 22 55 54 TypeB 66 8 66 47 TypeB 55 76 66 65 TypeB 55 77 88 46 TypeB 36 67 55 44 TypeB 67 55 76 65 I have checked a lot of links on box plots, but I still have not succeeded for the type of box plot I want. I wish to have a boxplot with my X-axis having type A (yellow, orange) for all the Mets (Met1, Met2, Met3, Met4). In essence, I want something

Connect ggplot boxplots using lines and multiple factor

≡放荡痞女 提交于 2019-11-29 05:20:45
I'm trying to connect ggplot2 boxplots with geom_lines for multiple factors. I'd been able to accomplish so far to connect all the boxplot with lines, see attach picture. But I wish to connect the only boxplots by their corresponding factor. For example for my variable FL, I want to connect only those two boxplot, without connecting them with the remaining variables. Similarly for the variable RW, connecting those two sex boxplot without the remaining others. library("MASS") data(crabs) melt_crabs <- melt(crabs,id.var=c("sp","sex","index")) ggplot(melt_crabs, aes(x = variable, y = value)) +

Sort boxplot by mean (and not median) in R

戏子无情 提交于 2019-11-29 03:55:13
I have a simple boxplot, showing the distribution of a score for factor TYPE: myDataFrame = data.frame( TYPE=c("a","a","b","b","c","c"), SCORE=c(1,1,2,3,2,1) ) boxplot( SCORE~TYPE, data=myDataFrame ) The various types are shown in the order they have in the data frame. I'd like to sort the boxplot by the mean of SCORE in each TYPE (in the example above, the order should be a,c,b ). Any hint? This is a job for reorder() : myDataFrame$TYPE <- with(myDataFrame, reorder(TYPE, SCORE, mean)) boxplot( SCORE~TYPE, data=myDataFrame ) 来源: https://stackoverflow.com/questions/9741600/sort-boxplot-by-mean

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

拟墨画扇 提交于 2019-11-29 02:27:37
问题 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

Generate ggplot2 boxplot with different colours for multiple groups

旧时模样 提交于 2019-11-29 00:02:35
I'm fairly new to R and ggplot. I'm trying to generate a boxplot sorted by two variables. In my case Species and Experiment. What I got so far by using ggplot(DF, aes(Species, Protein, fill=Experiment, dodge=Experiment)) + stat_boxplot(geom ='errorbar')+ geom_boxplot() are boxplots of my species and each species has 2 bars, one for each experiment. My question is now, is it possible to change the colours in this way, that I have different colours per species and lets say, different shading of those colours for the experiments? Lets say, the first species would than have a dark and light blue

python matplotlib filled boxplots

孤人 提交于 2019-11-28 20:53:04
Does anyone know if we can plot filled boxplots in python matplotlib? I've checked http://matplotlib.org/api/pyplot_api.html but I couldn't find useful information about that. The example that @Fenikso shows an example of doing this, but it actually does it in a sub-optimal way. Basically, you want to pass patch_artist=True to boxplot . As a quick example: import matplotlib.pyplot as plt import numpy as np data = [np.random.normal(0, std, 1000) for std in range(1, 6)] plt.boxplot(data, notch=True, patch_artist=True) plt.show() If you'd like to control the color, do something similar to this:

Sorting a boxplot based on median value

喜欢而已 提交于 2019-11-28 20:45:22
问题 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

How do I turn the numeric output of boxplot (with plot=FALSE) into something usable?

余生颓废 提交于 2019-11-28 19:52:52
I'm successfully using the boxplot function to generate... boxplots. Now I need to generate tables containing the stats that boxplot calculates in order to create plots. I do this by using the plot=FALSE option. The problem is that this produces data in a rather bizarre format that I simply can't do anything with. Here's an example: structure(list(stats = structure(c(178.998262143545, 182.227431564442, 202.108456373209, 220.375358994654, 221.990406228232, 216.59986775699, 217.054997032148, 228.509462713206, 267.070720949859, 284.832378859975, 189.864120937198, 201.876421960518, 219

Boxplot in R showing the mean

眉间皱痕 提交于 2019-11-28 17:53:14
Does anybody know of a way of generating a boxplot in R with a line (or another symbol) in the value corresponding to the mean? Thank you! abline(h=mean(x)) for a horizontal line (use v instead of h for vertical if you orient your boxplot horizontally), or points(mean(x)) for a point. Use the parameter pch to change the symbol. You may want to colour them to improve visibility too. Note that these are called after you have drawn the boxplot. If you are using the formula interface, you would have to construct the vector of means. For example, taking the first example from ?boxplot : boxplot