boxplot

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-22 08:41:37
问题 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

Consistent width of boxplots if missing data by group?

不羁的心 提交于 2019-12-22 07:08:15
问题 I have a similar question previously discussed for barplots , but with missing solution for boxplots : Consistent width for geom_bar in the event of missing data I would like to produce a boxplots by groups . However, data for some groups can be missing, leading to increased width of boxplots with missing groups . I tried to specify geom_boxplot(width = value ) or geom_boxplot(varwidth = F) , but this does not work. Also, as suggested for barplots example, I tried to add NA values for missing

How to save boxplot to as to a variable?

筅森魡賤 提交于 2019-12-22 06:56:12
问题 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? 回答1: The following does it. Call after that recordedPlot boxplot(count ~ spray, data = InsectSprays, col = "lightgray") recordedPlot = recordPlot() dev.off() 来源: https://stackoverflow.com/questions

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

风格不统一 提交于 2019-12-22 05:32:43
问题 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')? 回答1: 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

Python boxplot out of columns of different lengths

ぃ、小莉子 提交于 2019-12-22 05:09:09
问题 I have the following dataframe in Python (the actual dataframe is much bigger, just presenting a small sample): A B C D E F 0 0.43 0.52 0.96 1.17 1.17 2.85 1 0.43 0.52 1.17 2.72 2.75 2.94 2 0.43 0.53 1.48 2.85 2.83 3 0.47 0.59 1.58 3.14 4 0.49 0.80 I convert the dataframe to numpy using df.values and then pass that to boxplot. When I try to make a boxplot out of this pandas dataframe, the number of values picked from each column is restricted to the least number of values in a column (in this

Box plot showing mean as a line

元气小坏坏 提交于 2019-12-22 05:04:44
问题 Is it possible to create a boxplot that shows both mean and median as a line with the standard boxplot function of R ? My current solution displays the mean as a cross: set.seed(1234) values <- runif(10,0,1) boxplot(values) points(mean(values),col="red",pch=4,lwd = 4) 回答1: For the sake of completeness, you could also overplot: set.seed(753) df <- data.frame(y=rt(100, 4), x=gl(5, 20)) bx.p <- boxplot(y~x, df) bx.p$stats[3, ] <- unclass(with(df, by(y, x, FUN = mean))) bxp(bx.p, add=T, boxfill=

R manual boxplot with means and standard deviations (ggplot2)

房东的猫 提交于 2019-12-22 00:00:13
问题 I have two groups with mean scores and standard deviations which represent how confident we are with the mean estimates. Note: I do not have raw scores, just mean estimates outputted from a model and the SD of the estimates outputted from the model, around that mean. I have a feature set around 20, and I want to compare for each feature the mean +/- standard deviations of each of my 2 groups. It will essentially look like this: ggplot() seems to work with data that has the raw data and it

Plotly: Annotate outliers with sample names in boxplot

好久不见. 提交于 2019-12-21 21:43:34
问题 I am trying to create a boxplot with ggplot and plotly with the dataset airquality where Month is on the x-axis and Ozone values are on y-axis. My aim is to annotate the plot so that when I hover over the outlier points it should show the Sample name in addition to the Ozone value: library(tidyverse) library(plotly) library(datasets) data(airquality) # add months airquality$Month <- factor(airquality$Month, labels = c("May", "Jun", "Jul", "Aug", "Sep")) # add sample names airquality$Sample <-

Side-by-side boxplots with Pandas

北慕城南 提交于 2019-12-21 17:46:13
问题 I need to plot comparison of five variable, stored in pandas dataframe . I used an example from here, it worked, but now I need to change the axes and titles, but I'm struggling to do so. Here is my data: df1.groupby('cls').head() Out[171]: sensitivity specificity accuracy ppv auc cls 0 0.772091 0.824487 0.802966 0.799290 0.863700 sig 1 0.748931 0.817238 0.776366 0.785910 0.859041 sig 2 0.774016 0.805909 0.801975 0.789840 0.853132 sig 3 0.826670 0.730071 0.795715 0.784150 0.850024 sig 4 0

Matplotlib boxplot show only max and min fliers

99封情书 提交于 2019-12-21 13:08:13
问题 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