matlab,frequency,boxplot,summary

To answer your second question: Yes, you can perform a boxplot on a 5-number summary. Sort of. I mean, it just comes down to the fact that the min/Q1/median/Q3/max of your 5-number summary will be exactly those 5 numbers. So you can just call boxplot on the summary statistics, though...

What if you use fill=interaction(sex, tre) in the ggplot call? I'm not exactly sure what output you want.

r,ggplot2,overlay,boxplot,jitter

Welcome to SO! Here's my attempt. It's a bit clumsy, but does the job. The trick is to map x to a dummy variable with manually constructed offset. I'm adding a fill scale to highlight point positioning. mtcars$cylpt <- as.numeric(factor(mtcars$cyl)) + ifelse(mtcars$am == 0, -0.2, 0.2) ggplot(mtcars, aes(factor(cyl), mpg)) +...

r,ggplot2,data.frame,reshape,boxplot

Here is how I would do this. I think it makes sense to melt your data first. A quick tutorial on melting your data is available here. # First, make this reproducible by using dput for the data frame df <- structure(list(date = 20140101:20140130, MAE_f0 = c(0.2, 1.9, 0.1, 7.8,...

df<-data.frame("Grp" = factor(rep(LETTERS[1:5],each=20)),"V" = rnorm(100),"F" = c(rep("a",80),rep("b",20))) boxplot(V~Grp,df,col=c("red","red","red","red","blue")) # these are the combinations of group and F, the color-by variable unique(df[c('Grp','F')]) # Grp F # 1 A a # 21 B a # 41 C a # 61 D a # 81 E b ## you need a color vector...

I would say that in your first plot you just changed the y axis to log, so the values you plot still range between 1 and 10. In this plot the y axis is a log scale. The whiskers on this axis look different because the space between each "tick"...

r,count,label,boxplot,counting

Try using the sprintf function (or paste or some other one that would allow you to create a set of labels before a call to boxplot). Exemplary data: data <- data.frame(v1=runif(5), v2=runif(5), v3=runif(5)) data[1,1] <- NA data[1,2] <- NA data[2,1] <- NA data ## v1 v2 v3 ## 1 NA...

Make sure your calling suptitle('') on the right figure. In [23]: axes = df.boxplot(by='g') In [24]: fig = axes[0][0].get_figure() In [25]: fig.suptitle('') Out[25]: <matplotlib.text.Text at 0x109496090> ...

javascript,highcharts,boxplot,drilldown

Boxplot point can be created as array (your example) or as an object: { x: 1, low: 15, q1: 17, median: 18, q3: 19, high: 20 } Now, you can add drilldown per point (as required from plugin): { x: 1, low: 15, q1: 17, median: 18, q3: 19, high:...

python,pandas,boxplot,prettyplotlib

The right way to do it, saving from reinventing the wheel, would be to use the .boxplot() in pandas, where the nan handled correctly: In [31]: print df 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...

javascript,angularjs,highcharts,boxplot

okay, problem was related to declaring the chart-type as a boxplot. in native highcharts it's done like this (as can be seen in the fiddle): chart: { type: 'boxplot' }, However, when using angularjs highcharts-ng module, we need to use the following code: options: { chart: {type: 'boxplot'} }, That's...

You misspelled "purple" when you subsetted. Also, in the vioplot function, your first four arguments need to be vectors, not data frames. This code should work. blue <- subset(beeflowers4, colors=="blue", select=c(pollen, colors)) green <- subset(beeflowers4, colors=="green", select=c(pollen, colors)) purple <- subset(beeflowers4, colors=="purple", select=c(pollen, colors)) red <- subset(beeflowers4, colors=="red", select=c(pollen, colors))...

You can do it like this: value <- rnorm(300,mean=100,sd=20) nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3)) par(mar=c(4,4,1,1)) boxplot(value, horizontal=TRUE, outline=TRUE,ylim=c(0,160), frame=F, col = "green1") hist(value,breaks=40,xlab="Runs",ylab="Runs frequency", main = "Score") ...

You can use fun.datato apply a function (f) to the grouped data to return a count (length(y)) and a position for the label (median(y)) f <- function(y) c(label=length(y), y=median(y)) library(ggplot2) data(mtcars) ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) + geom_boxplot() + theme_bw() + stat_summary(fun.data=f, geom="text", vjust=-0.5, col="blue") ...

matplotlib,pandas,dataframes,boxplot,seaborn

A general solution for the boxplot for the entire dataframe, which should work for both seaborn and pandas as their are all matplotlib based under the hood, I will use pandas plot as the example, assuming import matplotlib.pyplot as plt already in place. As you have already have the ax,...

You must rearrange your data for the boxplots. The statistics are computed over complete columns. So, you must rearrange your data like: # 1.0 1.2 1.4 ... 2.2 2.2 3.06 2.0 2.46 2.93 2.2 2.46 3.06 2.0 2.4 2.8 1.73 2.33 2.8 Then you can plot it with: set style...

You need to add the following: h = flipud(findobj(gca,'Tag','Outliers')); for j=1:length(h); ydata = get(h(j),'YData'); xdata = get(h(j),'XData'); remdata = (ydata >= p(1,j)) & (ydata <= p(2,j)); ydata(remdata) = []; xdata(remdata) = []; set(h(j),'XData',xdata,'YData',ydata); end ...

I would approach such a task using aggregate or plyr. With aggregate you get the group means (of Fracht I assume) with the following call: groupMeans <- aggregate(Fracht ~ Bewirtschaftungsform, daten, mean) Rounding is suggested for printing: groupMeans$Fracht <- round(groupMeans$Fracht, 2) Within the ggplot object you can then just add:...

Building off of @shadow's answer, here's how you can manually change the x-axis labels. I also threw in a couple other changes which help improve the look of the graph and legend: colorder <- c( "green", "orange", "red", "blue") bplot<-ggplot(temp, aes(Lineage, RPKM)) + geom_boxplot(aes(fill=factor(Lineage))) + geom_point(aes(colour=factor(Lineage))) + scale_color_manual(breaks=colorder, # color...

plt.boxplot() returns a dictionary, where the key fliers contains the upper and lower fliers as line2d objects. You can manipulate them before plotting like this: Only on matplotlib >= 1.4.0 bp = plt.boxplot(data, whis=[5, 95], showfliers=True) # Get a list of Line2D objects, representing a single line from the #...

python,matplotlib,plot,boxplot,figure

This should work for your example code. However this solution bypasses the sharex aligment In my opinion, the axis labeling when using box plots and sharex is a little unintuitive. %matplotlib inline import matplotlib.pylab as plt import numpy as np np.random.seed(42) # create random data for i in range(1,6): x...

Maybe not the one liner you want but this works for me # Add a column to each data frame with the row index for (i in seq_along(mylist)) { mylist[[i]]$rowID <- 1:nrow(mylist[[i]]) } # Stick all the data frames into one single data frame allData <- do.call(rbind, mylist) # Split...

sinsin. Sorry to see that you're having an issue with our boxplot module. However, this is an issue with the boxplot module itself, and not anything you did! I'm on the ZingChart support team, so I'll be sure to pass this on to our developers. In the meantime, you can...

r,ggplot2,packages,scatter-plot,boxplot

Perhaps this will get you started: d <- data.frame(y = rnorm(20, 9, 2), group = as.factor(rep(c('Post-FAP', 'Post-DEP'), each = 10)), id = rep(1:10, 2)) ggplot(d, aes(y = y)) + geom_boxplot(aes(x = rep(c(-3, 3), each = 10), group = group), fill = 'steelblue') + geom_point(aes(x = rep(c(-1, 1), each = 10)),...

Try: library(splitstackshape) mc <- cSplit(mat.count, "count", sep =",", "long") boxplot(abs(count) ~ position, data = mc, varwidth = TRUE) Or using ggplot2: ggplot(mc, aes(x=as.factor(position), y=abs(count))) + geom_boxplot(varwidth=TRUE) + theme(text = element_text(size=6), axis.text.x = element_text(angle=90, vjust=1)) ...

You can create one variable containing the interaction with interaction. Then you can drop the unused levels with droplevels: boxplot(y ~ droplevels(interaction(x1, x2)), t) points(aggregate(y ~ droplevels(interaction(x1, x2)), t, mean)$y, col="red") ...

geom_boxplot assumes the categorical variables are on the x-axis. coord_flip doesn't work in combination with facet_grid + geom_boxplot. One workaround is to rotate the text. You can export and rotate the image in another program (or figure out how to pull out the grid object and rotate it). a =...

You can create a new column ('xy') using paste, create a logical index using ave for 'xy' groups having more than one elements, and then do the boxplot. df1$xy <- factor(paste(df1$x, df1$y, sep='.')) index <- with(df1, ave(1:nrow(df1), xy, FUN=length))>1 boxplot(z~xy, droplevels(df1[index,])) Or using ggplot library(dplyr) library(tidyr) library(ggplot2) df %>% group_by(x,y)...

As you've figured out, you need to access the members of the return value of boxplot. Namely, e.g. if your return value is stored in bp bp['medians'][0].get_ydata() >> array([ 2.5, 2.5]) As the boxplot is vertical, and the median line is therefore a horizontal line, you only need to focus...

You are right ggplot requires your data to be reshaped, but it isn't that hard using the package reshape2: library(reshape2) df <- melt(df) ggplot(df, aes(x=variable, y=value)) + geom_boxplot() ...

python,matplotlib,pandas,boxplot

pandas.qcut will give you the quartiles, but an histogram like operation will require some numpy trickery which comes in handy here: _, breaks=np.histogram(df.MAT,bins=5) ax=df.boxplot(column='N0_YLDF',by='Class') ax.xaxis.set_ticklabels(['%s'%val for i, val in enumerate(breaks) if i in df.Class]) In case you wonder, the dataframe now looks like this: N0_YLDF MAT Class 0 1.29 13.67...

Sample codes to get you started: ap <- data.frame(AirPassengers) year <- rep(seq(1949,1960), rep(12,12)) boxplot(ap$AirPassengers~year) ...

If you want to have them stacked above each other (in case they don't overlap), then you can just combine the two plot into one with plot for [i=1:3] "A.txt" using (i):i notitle,\ for [i=1:3] "B.txt" using (i):i notitle If they can overlap, you may want to put them side-by-side...

Here is a way using the original data you posted on Google - which actually was much more helpful, IMO. ggplot(df, aes(x=CH, y=value,group=CH))+ geom_boxplot(notch=FALSE, outlier.shape=NA, fill="red", alpha=0.2)+ scale_x_log10() So, as @BenBolker said before he deleted his answer(??), you should leave the x-variable (CH) as numeric, and set group=CH in the...

r,graphics,formula,boxplot,stripchart

See the at argument in ?boxplot: "numeric vector giving the locations where the boxplots should be drawn, [...]; defaults to 1:n where n is the number of boxes." You can get the number of boxes from e.g. the names slot in the boxplot object (see 'Value' in ?boxplot : bp...

Use geom_boxplot(lwd=3) ("lwd" for "line width"). Also, if lwd makes the median too thick, you can use lwd and fatten together to make the median line thinner relative to the other lines.

c#,data-binding,boxplot,oxyplot

So I found a way to create a Boxplot with OxyPlot. Just use the Class BoxPlotSeries of OxyPlot, a List object which holds the Boxplots and a little bit of math. I used CategoryAxes for x axis to distinguish the Boxplots. So for the future, here is the Code if...

One approach is to use a named vector to define the colors, which you can index with the levels of the factor (this assumes the grouping column is a factor; otherwise it must be a character vector, in which case it could be used as the index argument directly): df...

Not that I would suggest you do this, but you can change the statistical summary used to draw the boxplot, and replace any of the stats with your own statistics. For example, to do as you asked and draw the upper bound of the box at the 0.8 quantile of...

To get a single boxplot, you can do boxplot(mtcars$mpg), or with your data it looks like you need boxplot(max_urkoma[[2]]).

Here is a reproducible example of what I think you want. Assuming you have three 4x40 matrix: set.seed(1) d1 <- matrix(rnorm(40), nrow = 4) d2 <- matrix(rnorm(40), nrow = 4) d3 <- matrix(rnorm(40), nrow = 4) You should organize first your data, e.g. stacking them and adding a column: d...

## create some data.frames: this results in a list of four dfs createDF <- quote(data.frame(id=sample(c("NN", "SS"), 100, rep=T), heavy=runif(100), heavier=runif(100), heaviest=runif(100))) dfs <- lapply(1:4, function(i) eval(createDF)) ## join and shape them library(reshape2) dat <- do.call(rbind, dfs) dat$dfid <- paste("df", rep(1:4, times=sapply(dfs, nrow))) dat <- melt(dat, id.vars=c("id", "dfid")) ggplot(dat, aes(id, value,...

There is no class statement in proc boxplot. First, add a "year" variable using a data step. data tsla2; set tsla; year=year(date); run; Sort by year: proc sort data=tsla2; by year; run; Use by statement in proc boxplot: proc boxplot data=tsla2; by year; plot close*year; plot volume*year; run; If you...

python,matplotlib,pyqt,boxplot

Hey I've searched for solutions but could not find any good hint. But then I tried to play a little bit with the code. And somehow it works now (the problem is the line ax.hold(False): If you call it like this (code from your question): data = [{'med': 6.0, 'q1':...

The following does it. Call after that recordedPlot boxplot(count ~ spray, data = InsectSprays, col = "lightgray") recordedPlot = recordPlot() dev.off() ...

Is this what you want? Code: p <- ggplot(data = dtm, aes(x = asDate, y = mortes, group=interaction(date, trmt))) p + geom_boxplot(aes(fill = factor(dtm$trmt))) The key is to group by interaction(date, trmt) so that you get all of the boxes, and not cast asDate to a factor, so that ggplot...

Here is my attempt. First, I reshaped your data. Then, I produced your boxplot. I changed the size and colour of text for mean. Then, I looked into the data that ggplot used, which you can access using ggplot_build(objectname)$data[[1]]. You can see the numbers you need. I selected necessary variables...

I suggest a solution using ggplot+reshape2, with random data: set.seed(10) drools <- data.frame(matrix(round(runif(50, 50, 1000)), ncol=5)) java <- data.frame(matrix(round(runif(50, 50, 1000)), ncol=5)) library(ggplot2) library(reshape2) df <- data.frame(melt(drools), melt(java)[2]) names(df) <- c("column", "drools", "java") df2 <- melt(df) ggplot(data=df2) + geom_boxplot(aes(x=column, y=value, fill=variable)) It gives: What 'melt' actually does is transform the...

ggplot(d[d$species=="abrae" | d$species=="datae",], aes(x=cut_interval(x=elevation, length=200), y=hbl, fill=species)) + geom_boxplot() ...

Although you have a solution for doing it server side, I took a few minutes to convert my PHP solution to a Javascript solution, to address the initial question. step 1) function to calculate percentiles: //get any percentile from an array function getPercentile(data, percentile) { data.sort(numSort); var index = (percentile/100)...

Use this. scale_fill_discrete is what you need: library(ggplot2) bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() + scale_fill_discrete(breaks=c("ctrl","trt2")) bp ...

Problem solved. Embarrassingly, this was a version issue with matplotlib (need at least version 1.4.0).

python,matplotlib,plot,scatter-plot,boxplot

There's a package built on top of matplotlib called beeswarm that positions the points as requested.

Use coord_cartesian instead of scale_y_continuous: ggplot(df, aes(x=Effect2, y=OddsRatioEst)) + geom_boxplot(outlier.colour=NA) + coord_cartesian(ylim = c(0, 100)) From the coord_cartesian documentation: Setting limits on the coordinate system will zoom the plot (like you're looking at it with a magnifying glass), and will not change the underlying data like setting limits on a...

matplotlib,boxplot,seaborn,violin-plot

As discussed in the release notes there have been some changes to the API for categorical plots. In your case, you just need to explicitly pass your list (tuple, technically) of arrays to the data parameter: sns.boxplot(data=x) ...

r,plot,ggplot2,rstudio,boxplot

ggplot2 requires that your data to be plotted on the y-axis are all in one column. Here is an example: set.seed(1) df <- data.frame( value = runif(810,0,6), group = 1:9 ) df library(ggplot2) ggplot(df, aes(factor(group), value)) + geom_boxplot() + coord_cartesian(ylim = c(0,6) The ylim(0,6) sets the y-axis to be between...

Use pointPlacemet for each of the series. See demo: http://jsfiddle.net/6Lftuhzk/ series: [{ pointPlacement: -0.1, // to the left data: [ ... ] }, { pointPlacement: -0.1, // to the left data: [ ... ] }, { pointPlacement: 0.1, // to the right data: [ ... ] }, { pointPlacement: 0.1,...

Actually not that hard with matplotlib. In [22]: fig, ax = plt.subplots() In [23]: df[[0, 1, 2, 3]].plot(kind='box', ax=ax) Out[23]: <matplotlib.axes._subplots.AxesSubplot at 0x4890978> In [24]: ax2 = ax.twinx() In [25]: ax2.boxplot(df[4], positions=[4]) In [27]: ax.set_xlim(0, 5) Out[27]: (0, 5) There's still some cleanup with the styling, ticklabels etc. But that...

Try library(zoo) df2 <- df1[order(as.yearmon(df1$date, '%b-%y')),] boxplot(temp~ factor(date, levels=unique(date)), df2) data df1 <- structure(list(temp = c(11.9, 37.7, 17.7, 18.04, 16.93, 25.95, 12.04, 17.94, 16.9, 17.79, 24.93, 26.9, 15.94, 17.04, 11.97, 13.97, 15.09, 17.79, 19.98, 12.9, 14.09, 16.95, 16.98, 14.04), date = c("Nov-13", "Sep-15", "Sep-13", "Oct-14", "Aug-13", "Oct-14", "Nov-13", "Sep-13", "Aug-13",...

I have fixed a similar problem in an ugly (but effective for me) way by creating a dataframe with the same plotting variables as my original data, but with x (or y) positioned or factored that it fits between the two points I want to separate and missing values for...

For your axis, get the coordinates of the barplots first. bp <-barplot(t(mat[,2:5]), beside=F, legend = levels(mat), col = c("blue",'red','forestgreen','purple')) Now use bp for x-tick labels axis(1,at=bp,labels=mat[,1]) The resulting plot Also, if you play with the width of your plot window/device, you can get all the labels. ...

You could use stat_summary to customize the appearance, e.g. ggplot(dfmelt, aes(x=bin, y=value, fill=variable)) + stat_summary(geom = "boxplot", fun.data = function(x) setNames(quantile(x, c(0.05, 0.25, 0.5, 0.75, 0.95)), c("ymin", "lower", "middle", "upper", "ymax")), position = "dodge") ...

java,statistics,boxplot,random-sample

Supposed that min, a, median, b, max values separate quartiles of distribution (http://en.wikipedia.org/wiki/Quartile): static public double next(Random rnd, double median, double a, double b, double min, double max) { double d = -3; while (d > 2.698 || d < -2.698) { d = rnd.nextGaussian(); } if (Math.abs(d) < 0.6745)...

There are many ways to approach this problem, e.g. here and here. Probably the simplest way is meds <- c(by(mtcars$mpg, mtcars$cyl, median)) ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot() + geom_text(data=data.frame(), aes(x=names(meds), y=meds, label=1:3), col='red', size=10) ...

You can use transform() and ave() to add a column indicating how many observations are in each group and then use the subset() parameter to only keep those with more than 1 obs. For example boxplot(height~group, transform(test, groupcount=ave(ID, group, FUN=length)), subset=groupcount>1) Note that you can only use the subset= parameter...

Workaround could be to use geom_errorbar() and set the ymin and ymax values to mean. Then change color to black. With argument show_guide=TRUE you will get black lines also in legend. Playing with width= argument allows to get width of lines the same as for boxes. + geom_errorbar(aes(ymin=mean,ymax=mean,group=factor(parent.origin)), color="black",width=0.15,show_guide=TRUE) ...

In the old versions, you have to manually do it by chancing boxplot elements individually: Mean=[3.4] #mean IQR=[3.0,3.9] #inter quantile range CL=[2.0,5.0] #confidence limit A=np.random.random(50) D=plt.boxplot(A) # a simple case with just one variable to boxplot D['medians'][0].set_ydata(Mean) D['boxes'][0]._xy[[0,1,4], 1]=IQR[0] D['boxes'][0]._xy[[2,3],1]=IQR[1] D['whiskers'][0].set_ydata(np.array([IQR[0], CL[0]])) D['whiskers'][1].set_ydata(np.array([IQR[1], CL[1]])) D['caps'][0].set_ydata(np.array([CL[0], CL[0]]))...

The most likely difference is that you forgot to make quality into a factor within your rmd file. For example: set.seed(101) dd <- data.frame(quality = sample(6:9,size=200,replace=TRUE), residual.sugar = rnorm(200)) library(ggplot2) ggplot(aes(x = quality, y = residual.sugar),data=dd)+ geom_boxplot() dd2 <- transform(dd,quality=factor(quality)) ggplot(aes(x = quality, y = residual.sugar),data=dd2)+ geom_boxplot() ...

You can create your own dataset class and use it to create the chart. Create your own implementation of BoxAndWhiskerCategoryDataset and use it in place of DefaultBoxAndWhiskerCategoryDataset....

r,shape,boxplot,appearance,linestyle

For complete documentation you should look at ?bxp (linked from the ... description in ?boxplot, and in the "See Also" in ?boxplot, and in the pars description in ?boxplot.). It documents that outpch can change the shape of the outliers (though pch works fine too). It also has boxlty, boxlwd,...

Create the following function and use it as shown: make.italic <- function(x) as.expression(lapply(x, function(y) bquote(italic(.(y))))) boxplot(split(x, cut(x,breaks = c(-Inf, 0, Inf))), names = make.italic(sNames)) which gives: ...

python,python-2.7,matplotlib,boxplot,percentile

To draw the box plot using just the percentile values and the outliers ( if any ) I made a customized_box_plot function that basically modifies attributes in a basic box plot ( generated from a tiny sample data ) to make it fit according to your percentile values. The customized_box_plot...