errorbar

Position problem with geom_bar when using both width and dodge

柔情痞子 提交于 2020-07-03 10:10:32
问题 I have the following data frame group1 = c('a', 'b') group2 = c('1', '1', '2', '2') mean = 1:4 sd = c(0.2, 0.3, 0.5, 0.8) df = data.frame(group1, group2, mean, sd) I want to plot the sd on the graph, either with geom_errorbar() . This works perfectly: ggplot(data = df, aes(x=group1, y = mean))+ geom_col(position = 'dodge') + geom_errorbar(aes(ymin = mean - sd, ymax = mean + sd), position = 'dodge') As I wanted to reduce the width of the error bars I run: ggplot(data = df, aes(x=group1, y =

Position problem with geom_bar when using both width and dodge

烂漫一生 提交于 2020-07-03 10:09:08
问题 I have the following data frame group1 = c('a', 'b') group2 = c('1', '1', '2', '2') mean = 1:4 sd = c(0.2, 0.3, 0.5, 0.8) df = data.frame(group1, group2, mean, sd) I want to plot the sd on the graph, either with geom_errorbar() . This works perfectly: ggplot(data = df, aes(x=group1, y = mean))+ geom_col(position = 'dodge') + geom_errorbar(aes(ymin = mean - sd, ymax = mean + sd), position = 'dodge') As I wanted to reduce the width of the error bars I run: ggplot(data = df, aes(x=group1, y =

ggplot2 - Bars non-aligned to error bars

99封情书 提交于 2020-05-23 10:39:11
问题 I am trying to plot error bars over bars in R using ggplot2. The position of the bars is ok, however the error bars are misaligned, overlapped. Please take a look at the example below: library(ggplot2) df = structure(list(variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("Stage1", "Stage2", "Stage3", "Stage4"), class = "factor"), scenario = c("A", "A", "A", "B", "B", "B", "A", "A", "A", "B", "B", "B", "A", "A",

ggplot using second data source for error bars fails

我与影子孤独终老i 提交于 2020-04-11 05:23:22
问题 This is a follow-on to a previous question about getting some custom error bars. The look of the plot is how I need it, so don't worry about commenting in solely in regards to that (happy to hear opinions attached to other help though) Because these plots are generated in a loop, and the error bars are actually only added if a condition is met, I cant simply merge all the data up front, so assume for the purpose of this exercise the plot data and errorbar data are from different dfs. I have a

Moving error bars in a line graph with three factors

ぐ巨炮叔叔 提交于 2020-02-06 08:49:08
问题 I am trying to make the error bars black in a line graph that has three factors.... structure(list(pot = c(41L, 42L, 43L, 44L, 61L, 62L, 63L, 64L, 45L, 46L, 47L, 48L, 65L, 66L, 67L, 68L, 49L, 50L, 51L, 52L, 69L, 70L, 71L, 72L, 53L, 54L, 55L, 56L, 73L, 74L, 75L, 76L, 57L, 58L, 59L, 60L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 101L, 102L, 103L, 104L, 85L, 86L, 87L, 88L, 105L, 106L, 107L, 108L, 89L, 90L, 91L, 92L, 109L, 110L, 111L, 112L, 93L, 94L, 95L, 96L, 113L, 114L, 115L, 116L, 97L, 98L, 99L,

Color by manual scale for geom errorbar

老子叫甜甜 提交于 2020-01-17 05:03:45
问题 I am having trouble trying to set my errorbars to manual colors to follow the color scheme I have set for my points. Essentially, I would like the color of each errorbar to match the fill color of it's associated point. Create dataframe mean<-c(4,5,6,7) CI<-c(0.5,0.4,0.3,0.2) stress<-c(1,2,3,4) a<-c(10,10,20,20) b<-c(7.5,7.5,8,8) data<-data.frame(mean,CI,stress,a,b) Original Plot library(ggplot2) p<- ggplot(data, aes(a, mean)) p+geom_point()+ geom_errorbar(aes(ymax=mean+CI,ymin=mean-CI),

errorbar plot against datetime fails

元气小坏坏 提交于 2020-01-16 08:47:07
问题 Errorbar plotting does not always work when the x axis is a datetime : z = pd.DataFrame({'timestamp': {0: pd.Timestamp('2018-06-16 04:33:27'), 1: pd.Timestamp('2018-06-16 18:07:40')}, 'average': {0: 1.4158309812874796, 1: 1.4293226152856995}, 'stdev': {0: 0.5721450460404708, 1: 0.5771658975429514}}) Now z is timestamp average stdev 0 2018-06-16 04:33:27 1.415831 0.572145 1 2018-06-16 18:07:40 1.429323 0.577166 plt.plot(z.timestamp, z.average) works as expected, but plt.errorbar(z.timestamp, z

Add error bars to multiple lines to show standard deviation on a plot in R

大城市里の小女人 提交于 2020-01-15 06:08:54
问题 I have a plot with many diferent lines and I'd like to add error bars to each point on every line. df <- matrix(runif(25),5,5) plot(1:5,seq(0,1,1/4),type = 'n') mapply(lines,as.data.frame(df),col=cols,pch=1:5,type="o") I have tried to use the arrows function but with no success. stdev <- matrix(runif(25,0,0.1),5,5) A <- as.data.frame(df) + as.data.frame(stdev) B <- as.data.frame(df) - as.data.frame(stdev) mapply(arrows(1:5,A,1:5,B,col=cols,angle=90,length=0.03, code=3)) Any suggestions? 回答1:

Color of errobar different from the graph matlab

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 04:49:27
问题 i have this problem i want to make a color of errobars different from the color of my graph there is the code i have tried pp=errorbar(x,testMatriceFluxSortie/ValeurFluxSortie(1,1),err) pp.Color=[255 0 1]./255; But it gives me this all in red my graph 回答1: you can always use hold on and plot only the x,y data after the errorbar was plotted, for example: x = 1:10:100; y = [20 30 45 40 60 65 80 75 95 90]; err = 8*ones(size(y)); errorbar(x,y,err,'or'); hold on plot(x,y,'b'); 来源: https:/

How to add 95% confidence intervals to graph of proportions of factor levels in ggplot?

大憨熊 提交于 2020-01-05 08:32:30
问题 I wanted to build on the great answer I got to a previously asked question: Graph proportion within a factor level rather than a count in ggplot2 I was hoping to build on the code: var1 <- c("Left", "Right", NA, "Left", "Right", "Right", "Right", "Left", "Left", "Right", "Left", "Left","Left", "Right", "Left", "Right", "Right", "Right", "Left", "Left", "Right", NA, "Left", "Left","Left", "Right", NA, "Left", "Right", "Right", "Right", "Left", "Left", "Right", "Left", "Left","Left", "Right",