Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jul 09, 2014; 11:55pm
URL: http://imagej.273.s1.nabble.com/horizontal-error-bars-using-Plot-function-tp5008640p5008663.html
On Jul 9, 2014, at 5:50 PM, Neil Fazel wrote:
> Thanks very much for making this available. I tried it and it works.
>
> A comment: I noticed that in order to get the error bars displayed, I needed to pass the X and Y arrays when calling Plot.create(). Something like the following, which adds data points via calls to Plot.add(), does create plot points (in red), connected by lines (in light gray), but error bars do not appear:
This bug is fixed in the latest daily build (1.49e1). The following updated example macro draws the curve in light gray, labels each point with a red circle and draws black error bars that are thinner than the curve.
-wayne
requires("1.49e");
xValues = newArray(0.1, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95);
yValues = newArray(2,5.6,7.4,9,9.4,8.7,6.3,4.5,1);
yErrorBars = newArray(0.8,0.6,0.5,0.4,0.3,0.5,0.6,0.7,0.8);
xErrorBars = newArray(0.05,0.05,0.04,0.03,0.06,0.06,0.03,0.04,0.05);
Plot.create("Error Bars", "X", "Y");
Plot.setLimits(0, 1, 0, 10);
Plot.setLineWidth(2);
Plot.setColor("lightGray");
Plot.add("line", xValues, yValues);
Plot.setColor("red");
Plot.add("circles", xValues, yValues);
Plot.setColor("black");
Plot.setLineWidth(1);
Plot.add("yerrors", yErrorBars);
Plot.add("xerrors", xErrorBars);
Plot.show();
> Plot.create("Spectrum"," E[keV]", "#photons / keV / sr");
> Plot.setLimits(0, 75, 0, max*1.3);
> Plot.setLineWidth(2);
> Plot.setColor("lightGray");
> Plot.add("line", energies, spectrumPoints);
> Plot.setColor("red");
> Plot.add("circles", energies, spectrumPoints);
> Plot.setColor("black");
> Plot.add("yerrors", verticalErrors);
> Plot.add("xerrors", energyErrors);
> Plot.show();
>
> Best regards,
> Neil
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html