plotting x-y error bars in IDL [message #86833] |
Fri, 06 December 2013 02:24  |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello,
Is it possible to make x-y error bars in the IDL plot? I have seen the example for including the y-errorbars but how to do this for including the x-errorbar. Any sample example will be helpful.
Thanks
|
|
|
|
|
|
Re: plotting x-y error bars in IDL [message #86855 is a reply to message #86836] |
Sun, 08 December 2013 18:30   |
dg86
Messages: 118 Registered: September 2012
|
Senior Member |
|
|
On Friday, December 6, 2013 9:16:39 AM UTC-5, David Fanning wrote:
> David Fanning writes:
>
>
>
>>> Is it possible to make x-y error bars in the IDL plot? I have seen the example for including the y-errorbars but how to do this for including the x-errorbar. Any sample example will be helpful.
>
>>
>
>> Yes.
>
>>
>
>> http://www.idlcoyote.com/graphics_tips/yerrorbars.html
>
>
>
> Oh, and, duh, cgErrPlot allows you to create both horizontal and
>
> vertical error bars. :-)
>
>
>
> http://www.idlcoyote.com/idldoc/cg/cgerrplot.html
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
IDL's function graphics routine ERRORPLOT can plot both x and y error bars.
It even allows for asymmetric error bars.
All the best,
David
|
|
|
|
Re: plotting x-y error bars in IDL [message #86857 is a reply to message #86856] |
Mon, 09 December 2013 02:10   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello All,
Thanks for the suggestions. I have an array of latitude, longitude coordinates from GPS measurements from various stations with corresponding variability (i.e., standard deviation) over a period of operation. I am trying to plot the errorbars of latitude and longitude on a latitude-longitude axes. I am first obtaining the latitude-longitude axes and then projecting the lat-lon points. Next, I wanted to plot the errorbars corresponding to lat and lon values by using the commands as suggested in the example of Coyote graphics. While I see the figures and the points on the lat-lon axes nicely, I don't see the error bars and x-y labels. Can you suggest where I am going wrong? Below is my IDL code for your reference...
; ---------------------------------------------
PRO test_errorPlot
xlon = longitude
ylat = latitude
xstd = lon_err & ystd = lat_err
x_higherr=(xlon + xstd) & x_lowerr=(xlon - xstd)
y_higherr=(ylat + ystd) & y_lowerr=(ylat - ystd)
; Set up variables for the plot
xtitle='Longitude'
ytitle='Latitude'
title='Errorbar Plot'
position = [0.125, 0.125, 0.9, 0.925]
thick = (!D.Name EQ 'PS') ? 3 : 1
; Data Projection to Map coordinates
Lats=[50.84D,50.96D] ; deg.N
Lons=[6.36D,6.50D] ; deg E
centerLat=(Max(Lats) + Min(Lats)) / 2.0
centerLon=(Max(Lons) + Min(Lons)) / 2.0
zoom=12
scale = cgGoogle_MetersPerPixel(zoom)
xsize = 600 < 640 ; Max size of Google image with this Google API
ysize = 600 < 640 ; Max size of Google image with this Google API
resolution = STRTRIM(xsize,2) + 'x' + STRTRIM(ysize,2)
map = Obj_New('cgMap', 'Mercator', ELLIPSOID='WGS 84')
uv = map -> Forward(centerLon, centerLat)
uv_xcenter = uv[0,0]
uv_ycenter = uv[1,0]
xrange = [uv_xcenter - (xsize/2.0D*scale), uv_xcenter + (xsize/2.0D*scale)]
yrange = [uv_ycenter - (ysize/2.0D*scale), uv_ycenter + (ysize/2.0D*scale)]
map -> SetProperty, XRANGE=xrange, YRANGE=yrange
cgDisplay, 600, 500, Title=title
cgMap_Grid, MAP=map, /BOX_AXES, /cgGRID, FORMAT='(F0.2)'
cgPlotS, xlon, ylat, PSYM=16, SYMSIZE=1.2, MAP=map, COLOR='red'
; Draw the error bars in the signal Y
cgErrPlot, xlon, y_lowerr, y_higherr, COLOR='blu5',Thick=thick
; Draw the error bars in the signal X
cgErrPlot, ylat, x_lowerr, x_higherr, COLOR='blu5',Thick=thick, /Horizontal
END
; Display the plot in a graphics window.
cgDisplay, 600, 500
test_errorPlot
; Create a PostScript file.
cgPS_Open, Filename='test_errorPlot.ps'
test_errorPlot
cgPS_Close
; Create a PNG file with a width of 600 pixels.
cgPS2Raster, 'test_errorPlot.ps', /PNG
END
;-------------------------------------
Thanks in advance
|
|
|
Re: plotting x-y error bars in IDL [message #86862 is a reply to message #86857] |
Mon, 09 December 2013 05:33   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Madhavan Bomidi writes:
>
> Hello All,
>
> Thanks for the suggestions. I have an array of latitude, longitude coordinates from GPS measurements from various stations with corresponding variability (i.e., standard deviation) over a period of operation. I am trying to plot the errorbars of latitude and longitude on a latitude-longitude axes. I am first obtaining the latitude-longitude axes and then projecting the lat-lon points. Next, I wanted to plot the errorbars corresponding to lat and lon values by using the
commands as suggested in the example of Coyote graphics. While I see the figures and the points on the lat-lon axes nicely, I don't see the error bars and x-y labels. Can you suggest where I am going wrong? Below is my IDL code for your reference...
You have:
; Draw the error bars in the signal Y
cgErrPlot, xlon, y_lowerr, y_higherr, COLOR='blu5',Thick=thick
; Draw the error bars in the signal X
cgErrPlot, ylat, x_lowerr, x_higherr, COLOR='blu5',Thick=thick, $
/Horizontal
I think these should be:
; Draw the error bars in the signal Y
cgErrPlot, xlon, xlat-y_lowerr, xlat+y_higherr, $
COLOR='blu5',Thick=thick
; Draw the error bars in the signal X
cgErrPlot, ylat, xlon-x_lowerr, xlon+x_higherr, $
COLOR='blu5',Thick=thick, /Horizontal
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: plotting x-y error bars in IDL [message #86871 is a reply to message #86862] |
Mon, 09 December 2013 09:58   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello David,
I have already defined in the beginning of my IDL code as:
x_lowerr = (xlon-xstd) & x_higherr = (xlon+xstd)
y_lowerr = (ylat-ystd) & y_higherr = (ylat+ystd)
So, I have used x_lowerr, x_higherr, y_lowerr, y_higherr directly. I don't understand what is going wrong and why I am not able to see both the errorbars?
Thanks...
On Monday, December 9, 2013 2:33:16 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>>
>
>> Hello All,
>
>>
>
>> Thanks for the suggestions. I have an array of latitude, longitude coordinates from GPS measurements from various stations with corresponding variability (i.e., standard deviation) over a period of operation. I am trying to plot the errorbars of latitude and longitude on a latitude-longitude axes. I am first obtaining the latitude-longitude axes and then projecting the lat-lon points. Next, I wanted to plot the errorbars corresponding to lat and lon values by using the
>
> commands as suggested in the example of Coyote graphics. While I see the figures and the points on the lat-lon axes nicely, I don't see the error bars and x-y labels. Can you suggest where I am going wrong? Below is my IDL code for your reference...
>
>
>
> You have:
>
>
>
> ; Draw the error bars in the signal Y
>
> cgErrPlot, xlon, y_lowerr, y_higherr, COLOR='blu5',Thick=thick
>
>
>
> ; Draw the error bars in the signal X
>
> cgErrPlot, ylat, x_lowerr, x_higherr, COLOR='blu5',Thick=thick, $
>
> /Horizontal
>
>
>
> I think these should be:
>
>
>
> ; Draw the error bars in the signal Y
>
> cgErrPlot, xlon, xlat-y_lowerr, xlat+y_higherr, $
>
> COLOR='blu5',Thick=thick
>
>
>
> ; Draw the error bars in the signal X
>
> cgErrPlot, ylat, xlon-x_lowerr, xlon+x_higherr, $
>
> COLOR='blu5',Thick=thick, /Horizontal
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: plotting x-y error bars in IDL [message #86883 is a reply to message #86833] |
Tue, 10 December 2013 02:05   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello,
As suggested, I replaced the following lines in my code, I don't see even lat-lon points that I was able to see earlier. Now, I see only a black grid map with lat-lon axes. I still don't understand why to invert the data and why no display of points or error bars???
xy = map -> Inverse(xlon,ylat)
lon = REFORM(xy[0,*]) & lat = REFORM(xy[1,*])
cgPlotS, xlon, ylat, PSYM=16, SYMSIZE=1.2, MAP=map, COLOR='red'
; Draw the error bars in the signal Y
yhigh = map -> Inverse(y_higherr, ylat)
ylow = map -> Inverse(y_lowerr, ylat)
lon_high = REFORM(yhigh[0,*])
lon_low = REFORM(ylow[0,*])
cgErrPlot, lon, lon_high, lon_low, COLOR='blu5',Thick=thick
; Draw the error bars in the signal X
xhigh = map -> Inverse(xlon, x_higherr)
xlow = map -> Inverse(xlon, x_lowerr)
lat_high = REFORM(xhigh[0,*])
lat_low = REFORM(xlow[0,*])
cgErrPlot, lat, lat_high, lat_low, COLOR='blu5',Thick=thick, /Horizontal
Thanks in advance.
|
|
|
Re: plotting x-y error bars in IDL [message #86885 is a reply to message #86883] |
Tue, 10 December 2013 02:37   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Madhavan Bomidi writes:
> As suggested, I replaced the following lines in my code, I don't see
even lat-lon points that I was able to see earlier. Now, I see only a
black grid map with lat-lon axes. I still don't understand why to invert
the data and why no display of points or error bars???
>
> xy = map -> Inverse(xlon,ylat)
> lon = REFORM(xy[0,*]) & lat = REFORM(xy[1,*])
> cgPlotS, xlon, ylat, PSYM=16, SYMSIZE=1.2, MAP=map, COLOR='red'
>
> ; Draw the error bars in the signal Y
> yhigh = map -> Inverse(y_higherr, ylat)
> ylow = map -> Inverse(y_lowerr, ylat)
>
> lon_high = REFORM(yhigh[0,*])
> lon_low = REFORM(ylow[0,*])
> cgErrPlot, lon, lon_high, lon_low, COLOR='blu5',Thick=thick
>
> ; Draw the error bars in the signal X
> xhigh = map -> Inverse(xlon, x_higherr)
> xlow = map -> Inverse(xlon, x_lowerr)
> lat_high = REFORM(xhigh[0,*])
> lat_low = REFORM(xlow[0,*])
> cgErrPlot, lat, lat_high, lat_low, COLOR='blu5',Thick=thick, /Horizontal
>
>
> Thanks in advance.
Not sure what I was smoking yesterday (or maybe it is just the cloud
from OTHER people smoking here in Colordao), but all of those "Inverse"
calls should be changed to "Forward" calls. Sheesh. I guess I've never
seen map projections before. :-(
It is hard to write code without having data to run with it. I'm just
like everyone else, I make all KINDS of errors.
xy = map -> Forward(xlon,ylat)
lon = REFORM(xy[0,*]) & lat = REFORM(xy[1,*])
cgPlotS, xlon, ylat, PSYM=16, SYMSIZE=1.2, MAP=map, COLOR='red'
; Draw the error bars in the signal Y
yhigh = map -> Forward(y_higherr, ylat)
ylow = map -> Forward(y_lowerr, ylat)
lon_high = REFORM(yhigh[0,*])
lon_low = REFORM(ylow[0,*])
cgErrPlot, lon, lon_high, lon_low, COLOR='blu5',Thick=thick
; Draw the error bars in the signal X
xhigh = map -> Forward(xlon, x_higherr)
xlow = map -> Forward(xlon, x_lowerr)
lat_high = REFORM(xhigh[0,*])
lat_low = REFORM(xlow[0,*])
cgErrPlot, lat, lat_high, lat_low, COLOR='blu5',Thick=thick, /Horiz
Let me know if that works better. If not, I'll probably just rewrite
cgErrPlot. In fact, I may do that anyway. It is a total mess. I should
never have based it on the IDL routine of the same name. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: plotting x-y error bars in IDL [message #86886 is a reply to message #86885] |
Tue, 10 December 2013 03:00   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Sorry for all the troubles.
I don't see my (lon,lat) points on the plot. While I see x-errorbars, I don't see the y-errorbars at all. I don't have any clue what is happening ...
Thanks in advance ...
On Tuesday, December 10, 2013 11:37:12 AM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> As suggested, I replaced the following lines in my code, I don't see
>
> even lat-lon points that I was able to see earlier. Now, I see only a
>
> black grid map with lat-lon axes. I still don't understand why to invert
>
> the data and why no display of points or error bars???
>
>>
>
>> xy = map -> Inverse(xlon,ylat)
>
>> lon = REFORM(xy[0,*]) & lat = REFORM(xy[1,*])
>
>> cgPlotS, xlon, ylat, PSYM=16, SYMSIZE=1.2, MAP=map, COLOR='red'
>
>>
>
>> ; Draw the error bars in the signal Y
>
>> yhigh = map -> Inverse(y_higherr, ylat)
>
>> ylow = map -> Inverse(y_lowerr, ylat)
>
>>
>
>> lon_high = REFORM(yhigh[0,*])
>
>> lon_low = REFORM(ylow[0,*])
>
>> cgErrPlot, lon, lon_high, lon_low, COLOR='blu5',Thick=thick
>
>>
>
>> ; Draw the error bars in the signal X
>
>> xhigh = map -> Inverse(xlon, x_higherr)
>
>> xlow = map -> Inverse(xlon, x_lowerr)
>
>> lat_high = REFORM(xhigh[0,*])
>
>> lat_low = REFORM(xlow[0,*])
>
>> cgErrPlot, lat, lat_high, lat_low, COLOR='blu5',Thick=thick, /Horizontal
>
>>
>
>>
>
>> Thanks in advance.
>
>
>
> Not sure what I was smoking yesterday (or maybe it is just the cloud
>
> from OTHER people smoking here in Colordao), but all of those "Inverse"
>
> calls should be changed to "Forward" calls. Sheesh. I guess I've never
>
> seen map projections before. :-(
>
>
>
> It is hard to write code without having data to run with it. I'm just
>
> like everyone else, I make all KINDS of errors.
>
>
>
> xy = map -> Forward(xlon,ylat)
>
> lon = REFORM(xy[0,*]) & lat = REFORM(xy[1,*])
>
> cgPlotS, xlon, ylat, PSYM=16, SYMSIZE=1.2, MAP=map, COLOR='red'
>
>
>
> ; Draw the error bars in the signal Y
>
> yhigh = map -> Forward(y_higherr, ylat)
>
> ylow = map -> Forward(y_lowerr, ylat)
>
>
>
> lon_high = REFORM(yhigh[0,*])
>
> lon_low = REFORM(ylow[0,*])
>
> cgErrPlot, lon, lon_high, lon_low, COLOR='blu5',Thick=thick
>
>
>
> ; Draw the error bars in the signal X
>
> xhigh = map -> Forward(xlon, x_higherr)
>
> xlow = map -> Forward(xlon, x_lowerr)
>
> lat_high = REFORM(xhigh[0,*])
>
> lat_low = REFORM(xlow[0,*])
>
> cgErrPlot, lat, lat_high, lat_low, COLOR='blu5',Thick=thick, /Horiz
>
>
>
> Let me know if that works better. If not, I'll probably just rewrite
>
> cgErrPlot. In fact, I may do that anyway. It is a total mess. I should
>
> never have based it on the IDL routine of the same name. :-(
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
|
Re: plotting x-y error bars in IDL [message #86888 is a reply to message #86887] |
Tue, 10 December 2013 03:20   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
I sent a sample data file to your email. Please check that ...
On Tuesday, December 10, 2013 12:07:33 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> Sorry for all the troubles.
>
>>
>
>> I don't see my (lon,lat) points on the plot. While I see x-errorbars, I don't see the y-errorbars at all. I don't have any clue what is happening ...
>
>
>
> You're the one with troubles. Send me some data to work with, I'll see
>
> if I can figure it out. An IDL save file will work.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
|
Re: plotting x-y error bars in IDL [message #86902 is a reply to message #86892] |
Wed, 11 December 2013 01:48  |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello David,
I do agree with your suggestion and thanks for updating the cgplot.pro with more keywords including the errorbar options.
Regards ...
On Tuesday, December 10, 2013 8:14:01 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> I don't see my (lon,lat) points on the plot. While I see x-errorbars, I don't see the y-errorbars at all. I don't have any clue what is happening ...
>
>
>
> In your case the errors are so small that even if we can draw the error
>
> bars correctly, they would be completely overwhelmed by the size of the
>
> symbol you are using to represent the point itself. Even if you plot a
>
> line of data with the error lines above and below, it all appears as a
>
> single line on the plot. Essentially, there is no difference between the
>
> data and the data plus or minus the extremely small error.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> P.S. See the announcement in this group for new error bar handling in
>
> Coyote Graphics routines.
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|