boxplot

ordering in boxplot according to an object

筅森魡賤 提交于 2019-12-04 06:15:01
问题 I would like to have some grouped boxplot in a pandas df. var2 is an object, and I would like to display the boxplot in alphabetical order according to var2 order import seaborn as sns sns.set_style("whitegrid") ax = sns.boxplot(x="var1", y="var2",order=???, data=df) without putting manually: order=["a","b","c","d","e"] 回答1: Not 100% sure what needs to be sorted, but essentially you need to use unique(): order = sorted(df.var1.unique()) ax = sns.boxplot(x="var1", y="var2", order=order, data

Matplotlib boxplot show only max and min fliers

别说谁变了你拦得住时间么 提交于 2019-12-04 05:28:56
I am making standard Matplotlib boxplots using the plt.boxplot() command. My line of code that creates the boxplot is: bp = plt.boxplot(data, whis=[5, 95], showfliers=True) Because my data has a large distribution, I am getting a lot of fliers outside the range of the whiskers. To get a cleaner publication quality plot, I would like to only show single fliers at the max. and at the min. values of the data, instead of all fliers. Is this possible? I don't see any built-in options in the documentation to do this. (I can set the range of the whiskers to max/min, but this is not what I want. I

ggplot2: does boxplot use for calculations only values lying within limits of y-axis?

99封情书 提交于 2019-12-04 04:34:07
问题 I noticed that median of boxplot (constructed with restricted ylim-parameter) may differ from the median obtained by median()-function or boxplot without adjusted y-axis. Does it mean that boxplot use for calculations only values lying within defined interval of y-axis?? And if so, how could I get correct boxplot (based on all values), but plot it on particular interval of y.axis?? Thank you very much. 回答1: Using ylim restricts the scale for y . In ggplot, data that falls outside the scale's

How to plot bar plot in parallel to horizontal to box plot with fraction of area in boxplot?

a 夏天 提交于 2019-12-04 04:20:21
问题 I am working on data presentation and i need to plot boxplot with stacked barplot in parallel. With colored in different shade colors with proportion of points covering area. How can i plot it? 回答1: Here a generic solution that you can use to add parallel percent box to a lattice bowplot. It computes the exact percent descrbing parts of boxplot (whisker and main part). The solution is based on the grid package. Viewport manipulation is easier with lattice than ggplot2, that's why I choose a

ggplot: How to change boxplot settings when stat_summary is used

▼魔方 西西 提交于 2019-12-04 04:02:08
问题 I would like to have grouped boxplots which whiskers is defined by stat_summary. With help of changing-whisker-definition I wrote the following code: # Data xdf2 <- data.frame(month = rep(1:6,each=100) , grp = rep(c('A','B'), 50*6) ) xdf2$m <- rpois(n=nrow(xdf2),10) # Definition of whiskers f <- function(x) { r <- quantile(x, probs = c(0.10, 0.25, 0.5, 0.75, 0.90)) names(r) <- c("ymin", "lower", "middle", "upper", "ymax") r } # Add points outside of whiskers o <- function(x) { subset(x, x <

How to sort a boxplot by the median values in pandas

非 Y 不嫁゛ 提交于 2019-12-04 03:32:54
I've got a dataframe outcome2 that I generate a grouped boxplot with in the following manner: In [11]: outcome2.boxplot(column='Hospital 30-Day Death (Mortality) Rates from Heart Attack',by='State') plt.ylabel('30 Day Death Rate') plt.title('30 Day Death Rate by State') Out [11]: What I'd like to do is sort the plot by the median for each state, instead of alphabetically. Not sure how to go about doing so. To sort by the median, just compute the median, then sort it and use the resulting Index to slice the DataFrame : In [45]: df.iloc[:10, :5] Out[45]: AK AL AR AZ CA 0 0.047 0.199 0.969 -0.205

How to remove default axis from the plot produced by boxplot()?

妖精的绣舞 提交于 2019-12-04 02:52:12
问题 Probably this is a simple question, Does anyone know how to hide the default axis x labels in boxplot() in R? It should be simple, but I search on several sites and on boxplot help but could not find the answer. 回答1: You mean like this? d <- data.frame(x = 2, y=1:5) boxplot(d) boxplot(d, axes=FALSE) # add axes=FALSE to remove axes you can then add axes however you please: e.g. d <- data.frame(x = 2, y=1:5) boxplot(d, axes=FALSE) axis(2, at=1:5, labels=c(rep("whatever I want",5))) EDIT as per

R ggplot boxplot: change y-axis limit

风格不统一 提交于 2019-12-04 02:48:35
I'm using ggplot to create sevral boxplots from the following data: df<-(structure(list(Effect2 = c("A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A2", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "A3", "B1", "B1", "B1", "B1", "B1", "B1", "B1", "B1", "B1",

Can I get boxplot notches in ggplot2?

我只是一个虾纸丫 提交于 2019-12-04 00:28:57
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 graphics question is never complete without the graphic kohske Update In addition to the options

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

拟墨画扇 提交于 2019-12-03 23:50:37
问题 This question already has answers here : Customize axis labels (3 answers) Closed last year . 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