errorbar

Change capstyle for errorbars in matplotlib

為{幸葍}努か 提交于 2019-12-10 11:04:52
问题 I would like to set the capstyle for the vertical lines of an error bar to 'round'. For example, the following code produces some points with errorbars: import matplotlib.pyplot as plt fig, ax = plt.subplots() plt.plot([1,2,3], [2,3,4], marker='o', linestyle='None') plt.errorbar([1,2,3], [2,3,4], yerr=[1,1,1], fmt=None, linewidth=3, capsize=0) plt.xlim([0,4]) plt.show() For normal lines, I can set the cap style in the rcParams using this: plt.rcParams['lines.dash_capstyle'] = 'round' and I

How add asymmetric errorbars to Pandas grouped barplot?

旧街凉风 提交于 2019-12-08 21:44:00
问题 Following the accepted answer to this question I am able to reproduce the same results for my own data. However, I need to plot asymmetric error bars. dfdict = {'ID': ['A', 'A', 'B', 'B', 'C', 'C', 'D', 'D'], 'quarter': ['2015 2Q', '2016 1Q', '2015 2Q', '2016 1Q', '2015 2Q', '2016 1Q', '2015 2Q', '2016 1Q'], 'Percent': [0.851789, 0.333333, 0.355240, 0.167224, 1.533220, 0.333333, 0.170358, 0.000000], 'AgrCoullLower': [ 0.378046, 0.057962, 0.061850, -0.027515, 0.866025, 0.057962, -0.028012, -0

Remove endpoints from error bars in ggplot2

与世无争的帅哥 提交于 2019-12-07 00:11:53
问题 My goal is to create boxplots in R (doesn't have to be with ggplot2, but that's what I'm using now) that are as stylistically similar to this example that I found somewhere (minus the text): Here's the code I have so far: dat <- read.table(file = "https://www.dropbox.com/s/b59b03rc8erea5d/dat.txt?dl=1", header = TRUE, sep = " ") library(ggplot2) p <- ggplot(dat, aes(x = Subscale, y = Score, fill = Class)) p + stat_boxplot(geom = "errorbar", width = 1.2, size = 2.5, color = "#0077B3") + geom

matplotlib.pyplot.errorbar is throwing an error it shouldn't?

喜夏-厌秋 提交于 2019-12-06 16:01:01
I'm trying to make an errorbar plot with my data. X is a 9 element ndarray. Y and Yerr are 9x5 ndarrays. When I call: matplotlib.pyplot.errorbar(X, Y, Yerr) I get a ValueError: "yerr must be a scalar, the same dimensions as y, or 2xN." But Y.shape == Yerr.shape is True. I'm running on 64 bit Windows 7 with Spyder 2.3.8 and Python 3.5.1. Matplotlib is up to date. I've installed Visual C++ Redistributable for Visual Studio 2015. Any ideas? Edit: Some data. X=numpy.array([1,2,3]) Y=numpy.array([[1,5,2],[3,6,4],[9,3,7]]) Yerr=numpy.ones_like(Y) Maybe by "dimension of y" the docs actually meant 1xN

Change capstyle for errorbars in matplotlib

你。 提交于 2019-12-06 07:10:43
I would like to set the capstyle for the vertical lines of an error bar to 'round'. For example, the following code produces some points with errorbars: import matplotlib.pyplot as plt fig, ax = plt.subplots() plt.plot([1,2,3], [2,3,4], marker='o', linestyle='None') plt.errorbar([1,2,3], [2,3,4], yerr=[1,1,1], fmt=None, linewidth=3, capsize=0) plt.xlim([0,4]) plt.show() For normal lines, I can set the cap style in the rcParams using this: plt.rcParams['lines.dash_capstyle'] = 'round' and I also found some nice examples how to get round capstyles for ticks: for i in ax.xaxis.get_ticklines(): i.

Making stacked bar plot with specified error bar values in R

一笑奈何 提交于 2019-12-02 13:35:41
问题 I'm trying to make a stacked bar plot in R with error bars for a value that I want to predefine, rather than calculate, but each bar has a different value. For example, if my data frame was: x<-data.frame( Period = c("B1","D1a"), Sample = c("Glucose","Glucose"), Mi = c(2,3), M0 = c(4,6) ) I can make the bar plot I need with this code: mx <- melt(x, id.vars=1:2) ggplot(mx, aes(x=Period, y=value, fill=variable), xLabels=NA) + geom_bar(stat="identity") + facet_grid(~Sample) + scale_fill_manual

Change size of a line plot, understand how the size argument works

孤人 提交于 2019-12-02 08:07:55
I'm making a multiple lines plot with errorbars. If I don't use the size argument, everything is fine: # sample data Response=runif(4) ResponseMin=Response-Response/5 ResponseMax=Response+Response/5 Cases=rep(c("Case1","Case2"),each=2) df=data.frame(x=1:2,Average=Response,Lower=ResponseMin,Upper=ResponseMax,Case=Cases) # let's plot library(ggplot2) ggplot(df,aes(x=x,y=Average,colour=Case)) + geom_line(aes(group=Case)) + geom_point() + geom_errorbar(aes(ymin=Lower,ymax=Upper,width=0.25)) + labs(y="foo",title="Some plot fu") However, when I modify the line size, I start getting weird stuff:

How to plot a figure similar to the one produced by lassoPlot.m to specify a regularization parameter?

不问归期 提交于 2019-12-02 05:19:27
I am trying to apply a regularized optimization other than Lasso. How can I plot the figure similar to the one produced by lassoPlot.m included in MATLAB as shown below if all data needed can be provide? How to plot the I -shaped lines? I read the lassoPlot.m but cannot find out how it is done. If I had to create a plot like this manually, I'd do something like this: function q53809665 DATASET = [ 0.601240818 459.5714648 6.549320679 0.38951982 407.6789162 6.915203670 0.250128593 366.9277664 8.668936114 0.162048287 339.5657219 9.739510946 0.104984588 307.3415556 8.790018144 0.067415433 285

How do I add SE error bars to my barplot in ggplot2?

自闭症网瘾萝莉.ら 提交于 2019-11-28 01:45:25
问题 I made a simple barplot with ggplot2 comparing the mean lifespan (age) of males and females for 2 insect species. My code looks like this, with "dataset" being, well, my data set... gplot(dataset, aes(Species, Age, fill=Sex))+ stat_summary(fun.y = mean, geom = "bar", position = "dodge")+ scale_fill_manual(values = c("Grey25", "Grey"))+ theme(legend.title = element_blank())+ scale_y_continuous(limits = c(0,15)) I tried using the following code to manually enter the value of the mean±SE to set

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

此生再无相见时 提交于 2019-11-26 07:30:42
问题 For each X -value I calculated the average Y -value and the standard deviation ( sd ) of each Y-value x = 1:5 y = c(1.1, 1.5, 2.9, 3.8, 5.2) sd = c(0.1, 0.3, 0.2, 0.2, 0.4) plot (x, y) How can I use the standard deviation to add error bars to each datapoint of my plot? 回答1: A Problem with csgillespie solution appears, when You have an logarithmic X axis. The you will have a different length of the small bars on the right an the left side (the epsilon follows the x-values). You should better