boxplot

ggplot::geom_boxplot() How to change the width of one box group in R

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 07:55:48
问题 I want to adapt the width of the box in the category "random" to the same width of the other boxes in the plot. It is now a single group, whereas the other groups contain two subgroups... Any ideas on how to do that? Using geom_boxplot(width=0.2) just changes the width of all boxes. So far I used the following code: ggplot(TablePerCatchmentAndYear,aes(x=NoiseType, y= POA, fill = TempRes)) + geom_boxplot(lwd=0.05) + ylim(c(-1.25, 1)) + theme(legend.position='bottom') + ggtitle('title')+ scale

Face pattern for boxes in boxplots

风格不统一 提交于 2019-12-01 05:58:21
I would like to do something of the sort (using matplotlib): (from Colorfill boxplot in R-cran with lines, dots, or similar ) I saw some info about hatch(ing)? But I really can't make heads or tails on how to use this. Also I find myself wondering how can I change parameters like the possible attributes of a boxprop dict -- used in plt.boxplot(..., boxprops=boxpropsdict). Is it possible to just have a list of all the possible attributes for this? The important aspect is to set patch_artist=True when calling boxplot . import numpy as np import matplotlib.pyplot as plt # fake up some data spread

can one offset jitter points in ggplot boxplot

元气小坏坏 提交于 2019-12-01 05:57:10
In a ggplot boxplot , it is easy to use jitter to add the raw data points with varying degrees of jitter. With zero jitter the following code dat <- data.frame(group=c('a', 'b', 'c'), values = runif(90)) ggplot(dat, aes(group, values)) + geom_boxplot(outlier.size = 0) + geom_jitter(position=position_jitter(width=0), aes(colour=group), alpha=0.7) + ylim(0, 1) + stat_summary(fun.y=mean, shape=3, col='red', geom='point') + opts(legend.position = "right") + ylab("values") + xlab("group") produces the plot below. Is it possible to use zero jitter but add an offset such that the points are in a line

Labeling boxplot with median values

試著忘記壹切 提交于 2019-12-01 05:32:20
问题 In addition to the solution posted in this link I would also like if I can also add the Hue Parameter, and add the Median Values in each of the plots. The Current Code: testPlot = sns.boxplot(x='Pclass', y='Age', hue='Sex', data=trainData) m1 = trainData.groupby(['Pclass', 'Sex'])['Age'].median().values mL1 = [str(np.round(s, 2)) for s in m1] p1 = range(len(m1)) for tick, label in zip(p1, testPlot.get_xticklabels()): print(testPlot.text(p1[tick], m1[tick] + 1, mL1[tick])) Gives a Output Like:

How to apply custom column order (on Categorical) to pandas boxplot?

谁都会走 提交于 2019-12-01 03:21:41
EDIT: this question arose with pandas ~0.13 and was obsoleted by direct support somewhere between version 0.15-0.18 (as per @Cireo's late answer ) I can get a boxplot of a salary column in a pandas DataFrame... train.boxplot(column='Salary', by='Category', sym='') ...however I can't figure out how to define the index-order used on column 'Category' - I want to supply my own custom order, according to another criterion: category_order_by_mean_salary = train.groupby('Category')['Salary'].mean().order().keys() How can I apply my custom column order to the boxplot columns? (other than ugly

Boxplotting Masked Arrays

我怕爱的太早我们不能终老 提交于 2019-12-01 03:13:23
问题 How can i boxplot only the non-masked values of a MaskedArray ? I tought this would happen automatically by boxplot(ma) but this seems to boxplot the non-masked array. 回答1: I think you are right -- plt.boxplot ignores the mask if sent a masked array. So it looks like you'll have to give boxplot some extra help by sending it only the values which are not masked. Since each row of the array may have a different number of unmasked values, you won't be able to use a numpy array. You'll have to

What is the most elegant way to split data and produce seasonal boxplots?

我怕爱的太早我们不能终老 提交于 2019-12-01 02:43:56
问题 I want to produce seasonal boxplots for a lot of different time series. I hope that the code below clearly illustrates what I want to do. My question is now, how to do this in the most elegant way with as few lines of code as possible. I can create an new object for each month with the function "subset" and then plot it, but this seems to be not very elegant. I tried to use the "split" function, but I don't know, how to proceed from there. Please tell me if my question is not clearly stated

Changing x axis tick labels in R using ggplot2 [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-01 02:30:37
This question already has an answer here: Customize axis labels 3 answers How can I change the names of my x axis labels in ggplot2? See below: ggbox <- ggplot(buffer, aes(SampledLUL, SOC)) + geom_boxplot() ggbox <- ggbox + theme(axis.text.x=element_text(color = "black", size=11, angle=30, vjust=.8, hjust=0.8)) ggbox<- ggbox + labs(title = "Land cover Classes") + ylab("SOC (g C/m2/yr)") + xlab("Land cover classes") The above code creates the following figure: I would like to be able to capitilize the first letter of these classes (i.e Crop, as opposed to crop). I've tried the code below but

How to group boxplot outliers in gnuplot

 ̄綄美尐妖づ 提交于 2019-12-01 00:56:11
I have a large set of data points. I try to plot them with a boxplot, but some of the outliers are the exact same value and they are represented on a line beside each other. I found How to set the horizontal distance between outliers in gnuplot boxplot , but it doesn't help too much, as it is apparently not possible. Is it possible to group the outliers together, print one point and then print a number in brackets beside it to indicate how many points there are? I think this would make it more readable in a graph. For information, I have three boxplots for one x value and that times six in one

How to apply custom column order (on Categorical) to pandas boxplot?

 ̄綄美尐妖づ 提交于 2019-11-30 23:37:36
问题 EDIT: this question arose with pandas ~0.13 and was obsoleted by direct support somewhere between version 0.15-0.18 (as per @Cireo's late answer) I can get a boxplot of a salary column in a pandas DataFrame... train.boxplot(column='Salary', by='Category', sym='') ...however I can't figure out how to define the index-order used on column 'Category' - I want to supply my own custom order, according to another criterion: category_order_by_mean_salary = train.groupby('Category')['Salary'].mean()