boxplot

how to include in legend symbol of mean in boxplot with ggplot?

元气小坏坏 提交于 2019-12-11 05:19:30
问题 I would like to have in the legend the symbol of the mean together with the symbols of the boxes. So my legend should include "Exposure 1, Exposure 2, Exposure 3" but also the word mean and its symbol. How to do this using ggplot in R? This is the code I'm using to produce the boxplot: library(ggplot2) mydata <- read.csv("~/mydata.csv") bp<-ggplot(mydata,aes(x=Category,y=MeanValues,,fill=as.factor(Category))) + geom_boxplot() bp+labs(x = NULL, y = "Result")+ theme_bw()+stat_summary(fun.y =

How do I change the outline colours of a boxplot with ggplot?

我的未来我决定 提交于 2019-12-11 04:45:04
问题 My data has values which are all the same so they are coming up as just a line in a box plot. This, however, means that I can't tell the difference between groups as the fill doesn't show up. How can I change the outlines of the boxplot to be a specific colour. Note: I do not want all the outline colours to be the same colour, as in the next line of code: library(dplyr) library(ggplot2) diamonds %>% filter(clarity %in% c("I1","SI2")) %>% ggplot(aes(x= color, y= price, fill = clarity))+ geom

boxplot displays incorrect when coverting from factor to numeric

不打扰是莪最后的温柔 提交于 2019-12-11 04:35:59
问题 My graph displays correctly without using scale. I want to have it looks better so I convert factor to numeric then using scale_x_continuous. However, the graph looks incorrect when I convert from factor to numeric (How to convert a factor to an integer\numeric without a loss of information?). I can't use scale without converting to numeric. Please run a sample code below with and without these lines ( main$U <- as.numeric(as.character(main$U)) , and + scale_x_continuous(name="Temperature",

watchTransition() is not a function in nv.d3.js with angular.js

六眼飞鱼酱① 提交于 2019-12-11 04:28:14
问题 I am trying to render a boxplot from nv.d3.js. v.1.8.5 and d3.js v.3.4.4 . I am adding the d3.js file before nv.d3.js file from the index.html .The code breaks saying boxplots.watchTransition is not a function The following is my code d3.selection.prototype.watchTransition = function(renderWatch){ var args = [this].concat([].slice.call(arguments, 1)); return renderWatch.transition.apply(renderWatch, args); }; And later in the code boxplots.watchTransition(renderWatch, 'nv-boxplot: boxplots')

Produce a boxplot for multiple ACFs

点点圈 提交于 2019-12-11 04:19:17
问题 I used the following to run forecast::Acf over about 200 columns. Now I would like to generate a boxplot showing the distribution of correlation values at lag 1:36. ## a simple example d <- data.frame(ts1 = rnorm(100), ts2 = rnorm(100)) acorr <- apply(d, 2, Acf) What I now want is a boxplot where x-values are 1,2 and the y-values are ACF for ts1 and ts2 . 回答1: Suppose you have multiple time series stored in a data frame d (each column is one series), we can use the following to obtain ACF up

making Boxplot with 3 variables in r

大城市里の小女人 提交于 2019-12-11 03:39:45
问题 I want to make a boxplot in r but I struggle with grouping the boxplot by a third variable. I want to have boxplots- all on one y-axes (score on a treatment outcome questionnaire), called HAMD)) - for weeks 0-5 (called week) and all twice for two treatment groups (called Treatment). I made two boxplots with boxplot(MP$HAMD ~ MP$week) and six with boxplot(MP$HAMD ~ MP$Treatment) But now I want 12 boxplots together, each per week per treatment. How can I do this in r? By all means thank you

How to customize whisker lines on a geom_box plot differently than the lines of the box itself

大城市里の小女人 提交于 2019-12-11 02:46:33
问题 Because of a demanding end user, I need to learn whether the whisker lines on a geom_box plot can be colored or typed differently than the box itself? Having just considered boxplot with colored and dotted lines, I have created a minimal example. year <- rep("2014", 10) total <- c(seq(55, 90, 5), 100, 40) df <- data.frame(year = as.factor(year), total = total) ggplot(df, aes(x=factor(year), y=total)) + geom_boxplot(linetype = "dotted", color = "red") + theme_bw() Can the plot below have green

r lattice - wrong position of horizontal abline after bwplot

醉酒当歌 提交于 2019-12-11 02:33:32
问题 I can do this without problems: boxplot(coef ~ habitat, data = res) abline(h = 0, col = "green") But when I use lattice, the horizontal line is misplaced: bwplot(coef ~ habitat, data = res) abline(h = 0, col = "green") I tried to use panel.abline instead but that places the green line on top of the picture. 回答1: Use a panel function; order the contained functions in the order you'd like parts added; make use of ... to avoid having to know / manage all parameters to the panel function bwplot

Yearly BoxPlots with Pandas

匆匆过客 提交于 2019-12-11 01:52:15
问题 I have a DataFrame (multiple daily timeseries) with DateTimeIndex as index and MultiIndex as columns . I would like to select a column and create a Box Plot where data are grouped by year. I thought it was easy but I am struggling to get some result. >>> daily.shape (11319, 118) >>> daily.index DatetimeIndex(['1986-01-01', '1986-01-02', '1986-01-03', '1986-01-04', '1986-01-05', '1986-01-06', '1986-01-07', '1986-01-08', '1986-01-09', '1986-01-10', ... '2016-12-22', '2016-12-23', '2016-12-24',

R Side-by-side grouped boxplot

匆匆过客 提交于 2019-12-11 01:44:23
问题 I have temporal data of gas emissions from two species of plant, both of which have been subjected to the same treatments. With some previous help to get this code together [edit]: soilflux = read.csv("soil_fluxes.csv") library(ggplot2) soilflux$Treatment <- factor(soilflux$Treatment,levels=c("L-","C","L+")) soilplot = ggplot(soilflux, aes(factor(Week), Flux, fill=Species, alpha=Treatment)) + stat_boxplot(geom ='errorbar') + geom_boxplot() soilplot = soilplot + labs(x = "Week", y = "Flux (mg