comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Displaced errorbars on log-log scale with cgPlot
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Displaced errorbars on log-log scale with cgPlot [message #90113 is a reply to message #90112] Wed, 28 January 2015 07:53 Go to previous messageGo to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Wednesday, January 28, 2015 at 4:25:24 PM UTC+1, Madhavan Bomidi wrote:
> Hello David,
>
> Please check the below code and the resulting output:
>
> ---------------------------------
> PRO testerr
>
> xdt = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240]
>
>
> ymean = [ 5.7071102e-07, 1.9411492e-07, 2.4366391e-07, 3.9646722e-07, $
> 8.8304703e-07, 3.6161633e-06, 1.5931371e-05, 6.4912913e-05, $
> 0.00019788680, 0.00042545785, 0.00033186864, 0.00031074151 ]
>
> ystd = [ 4.1662774e-07, 2.7208043e-07, 4.5170846e-07, 7.2870838e-07, $
> 1.2310552e-06, 3.6163696e-06, 1.4698943e-05, 6.3878156e-05, $
> 0.00023048977, 0.00053752256, 0.00033514162, 0.00018645177 ]
>
> low_yerr = (ymean - ystd)
> high_yerr = (ymean + ystd)
>
> FigFile = 'testerrplot.ps'
>
> cgPS_Open,FigFile
> cgDisplay
>
> cgPlot,xdt,ymean, Font=-1,/XLOG,XStyle=1,YStyle=1, $
> XRange=[100000,1],YRange=[0.000000001,0.1], /YLOG, $
> CharSize=1.2, ERR_YLow=low_yerr, $
> ERR_YHigh=high_yerr, Psym=-16, $
> ERR_Color='red7',SymColor='red7',Color='red7'
>
> cgPS_Close
>
> ; Create a PNG file
> cgPS2Raster,FigFile,/PNG
>
> END
> --------------------------------------
>
> Thanks in advance,
> Regards,
> Madhavan

Hi,
that's because the errors are automatically added to the y values. According to David's documentation:

; err_yhigh: in, optional
; The high error values that should be added to the dependent or Y data values.
; err_ylow: in, optional
; The low error values that should be subtracted from the dependent or Y data values.

therefore if you change:
low_yerr = (ymean - ystd)
high_yerr = (ymean + ystd)
to
low_yerr = ystd
high_yerr = ystd

Then comes the real problem... Did you look at the numbers? So here it goes:
1.54083e-007
-7.79655e-008
-2.08045e-007
-3.32241e-007
-3.48008e-007
-2.06455e-010
1.23243e-006
1.03476e-006
-3.26030e-005
-0.000112065
-3.27296e-006
0.000124290

Now the graphics has to place errorbars for negative values. If you select only positive values (4 of them), the plot looks fine:

goodVals = where(ymean-ystd gt 0.0, cnt)
ymean = ymean[goodVals]
ystd = ystd[goodVals]
xdt = xdt[goodVals]
cgDisplay, 600, 600, WID=1, Title='log-log'
cgPlot,xdt,ymean, Font=-1,/XLOG,XStyle=1,YStyle=1, $
XRange=[100000,1],YRange=[0.000000001,0.1], /YLOG, $
CharSize=1.2, ERR_YLow=ystd, $
ERR_YHigh=ystd, Psym=-16, $
ERR_Color='red7',SymColor='red7',Color='red7'

Cheers,
Helder
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Contour annotations
Next Topic: Krig2d from point to image

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 09:27:00 PDT 2025

Total time taken to generate the page: 1.92278 seconds