On Wednesday, January 28, 2015 at 4:54:01 PM UTC+1, Helder wrote:
> 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
Ups... a line went missing.
The values showed are a result of
print, ymean-ystd
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
sorry for missing that.
Cheers,
Helder
|