Multiple plot with mapCoord [message #88902] |
Wed, 02 July 2014 10:29  |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
Hello,
I'm struggling to create a 6 panel multiple graph plot. I started trying to use !P.Multi=[3,3,1] and tried to follow these suggestions https://www.idlcoyote.com/tips/oplot_pmulti.html since I need to put several lines of data on each graph separately. I have a map background for each plot that I've created using
mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
center_lat=centarlat, center_lon=centerlon, position=pp)
mapCoord -> Draw
cgMap_Grid, map=mapCoord, /box
cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /advance
cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4
p1 = !P & x1 = !X & y1 = !Y
I'm hoping someone can give me some guidance because what I'm doing is not working. Thank you.
Sincerely,
Morgan
|
|
|
Re: Multiple plot with mapCoord [message #88904 is a reply to message #88902] |
Wed, 02 July 2014 10:58   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Morgan Silverman writes:
> I'm struggling to create a 6 panel multiple graph plot. I started trying to use !P.Multi=[3,3,1] and tried to follow these suggestions https://www.idlcoyote.com/tips/oplot_pmulti.html since I need to put several lines of data on each graph separately. I have a map background for each plot that I've created using
>
> mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
> center_lat=centarlat, center_lon=centerlon, position=pp)
> mapCoord -> Draw
> cgMap_Grid, map=mapCoord, /box
> cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /advance
> cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4
> p1 = !P & x1 = !X & y1 = !Y
>
> I'm hoping someone can give me some guidance because what I'm doing is not working. Thank you.
Yes, I can see that. If you are trying to get your six plots in three
columns and two rows, you might try setting up !P.Multi=[0,3,2].
Does that help?
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: Multiple plot with mapCoord [message #88905 is a reply to message #88904] |
Wed, 02 July 2014 11:15   |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
On Wednesday, July 2, 2014 1:58:16 PM UTC-4, David Fanning wrote:
> Morgan Silverman writes:
>
>
>
>> I'm struggling to create a 6 panel multiple graph plot. I started trying to use !P.Multi=[3,3,1] and tried to follow these suggestions https://www.idlcoyote.com/tips/oplot_pmulti.html since I need to put several lines of data on each graph separately. I have a map background for each plot that I've created using
>
>>
>
>> mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
>
>> center_lat=centarlat, center_lon=centerlon, position=pp)
>
>> mapCoord -> Draw
>
>> cgMap_Grid, map=mapCoord, /box
>
>> cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /advance
>
>> cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4
>
>> p1 = !P & x1 = !X & y1 = !Y
>
>>
>
>> I'm hoping someone can give me some guidance because what I'm doing is not working. Thank you.
>
>
>
> Yes, I can see that. If you are trying to get your six plots in three
>
> columns and two rows, you might try setting up !P.Multi=[0,3,2].
>
>
>
> Does that help?
>
>
>
> 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.")
Well that made it the correct number of panels but the graphs continue to flash across the screen over and over until I'm left with a pieces of the graph in scattered locations (i.e. map in one corner, grid in another, data in another). I also tried to use cgWindow and wMulti since that's what I was originally using but get the same problem with the the graphs flashing across the screen for several seconds. In an unrelated question, I also get this error message when using cgWindow and mapCoord CGCOORD::DRAW: Received unexpected keywords.
** Structure <1fca1968>, 1 tags, length=2, data length=2, refs=1:
ADDCMD INT 1
Thanks,
Morgan
My cgWindow code is...
loadct, 33
pp=[0.1,0.1,0.95,0.90]
lonmin = -125
lonmax = -65
latmin = 25
latmax = 60
centerlon = (lonmax-lonmin)/2.0 + lonmin
centerlat = (latmax-latmin)/2.0 + latmin
limit = [latmin, lonmin, latmax, lonmax]
xrange = [lonmin, lonmax]
yrange = [latmin, latmax]
mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
center_lat=centarlat, center_lon=centerlon, position=pp, /AddCmd)
mapCoord -> Draw, /AddCmd
cgMap_Grid, map=mapCoord, /box, /AddCmd
cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /AddCmd
cgControl, Multi=[0,3,2]
wids = cgQuery(Title=titles, Count=count)
if (count ne 0) then begin
windex=where(titles eq 'Plot_DAQ_Trajectories', tcnt)
endif else tcnt = 0
if (tcnt eq 0) then begin
cgWindow, wtitle='Plot_DAQ_Trajectories', wxsize=800, wysize=800
endif else begin
cgSet, wids[windex[0]]
endelse
cgControl, Execute=0
ShoreData = './gshhs/gshhs_h.b'
cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4, WMulti=[0,2,3], /AddCmd
cgControl, Execute=1
|
|
|
Re: Multiple plot with mapCoord [message #88906 is a reply to message #88904] |
Wed, 02 July 2014 11:18   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>
> Morgan Silverman writes:
>
>> I'm struggling to create a 6 panel multiple graph plot. I started trying to use !P.Multi=[3,3,1] and tried to follow these suggestions https://www.idlcoyote.com/tips/oplot_pmulti.html since I need to put several lines of data on each graph separately. I have a map background for each plot that I've created using
>>
>> mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
>> center_lat=centarlat, center_lon=centerlon, position=pp)
>> mapCoord -> Draw
>> cgMap_Grid, map=mapCoord, /box
>> cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /advance
>> cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4
>> p1 = !P & x1 = !X & y1 = !Y
>>
>> I'm hoping someone can give me some guidance because what I'm doing is not working. Thank you.
>
> Yes, I can see that. If you are trying to get your six plots in three
> columns and two rows, you might try setting up !P.Multi=[0,3,2].
You might also find this article helpful:
https://www.idlcoyote.com/code_tips/multiplots.php
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: Multiple plot with mapCoord [message #88908 is a reply to message #88906] |
Wed, 02 July 2014 11:57   |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
On Wednesday, July 2, 2014 2:18:38 PM UTC-4, David Fanning wrote:
> David Fanning writes:
>
>
>
>>
>
>> Morgan Silverman writes:
>
>>
>
>>> I'm struggling to create a 6 panel multiple graph plot. I started trying to use !P.Multi=[3,3,1] and tried to follow these suggestions https://www.idlcoyote.com/tips/oplot_pmulti.html since I need to put several lines of data on each graph separately. I have a map background for each plot that I've created using
>
>>>
>
>>> mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
>
>>> center_lat=centarlat, center_lon=centerlon, position=pp)
>
>>> mapCoord -> Draw
>
>>> cgMap_Grid, map=mapCoord, /box
>
>>> cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /advance
>
>>> cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4
>
>>> p1 = !P & x1 = !X & y1 = !Y
>
>>>
>
>>> I'm hoping someone can give me some guidance because what I'm doing is not working. Thank you.
>
>>
>
>> Yes, I can see that. If you are trying to get your six plots in three
>
>> columns and two rows, you might try setting up !P.Multi=[0,3,2].
>
>
>
> You might also find this article helpful:
>
>
>
> https://www.idlcoyote.com/code_tips/multiplots.php
>
>
>
> 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.")
Good article. I'm still missing something though. I'd like to use coyote graphics because I'm trying to make publication figures and from my understanding better quality can be gotten using cgWindow and ImageMagick. When I run my code I see the maps then they flash away and i'm left with just 4 colored lines that should be overlaid on the maps. I've tried with the mapCoord statements both inside and outside the loop both with the same results.
loadct, 33
pp=[0.1,0.1,0.95,0.90]
lonmin = -125
lonmax = -65
latmin = 25
latmax = 60
centerlon = (lonmax-lonmin)/2.0 + lonmin
centerlat = (latmax-latmin)/2.0 + latmin
limit = [latmin, lonmin, latmax, lonmax]
xrange = [lonmin, lonmax]
yrange = [latmin, latmax]
cgWindow, wxsize=800, wysize=800, wmulti=[0,2,3], xomargin=[2,6], woymargin=[2,8], $ wtitle='Plot_DAQ_Trajectories'
ShoreData = './gshhs/gshhs_h.b'
mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
center_lat=centarlat, center_lon=centerlon, /AddCmd)
mapCoord -> Draw, /AddCmd
cgMap_Grid, map=mapCoord, /box, /AddCmd
cgMap_Continents, map=mapCoord, /continents, /countries, /usa, /AddCmd
for j=0,5 do begin
cgplots, Avg1000Lon, Avg1000Lat, map=mapCoord, color='orange', thick=4, /AddCmd
cgplots, Avg1500Lon, Avg1500Lat, map=mapCoord, color='red', thick=4, /AddCmd
cgplots, Avg2000Lon, Avg2000Lat, map=mapCoord, color='blue', thick=4, /AddCmd
cgplots, Avg2500Lon, Avg2500Lat, map=mapCoord, color='green', thick=4, /AddCmd
cgplots, Avg3000Lon, Avg3000Lat, map=mapCoord, color='cyan', thick=4, /AddCmd
cgplots, Avg3500Lon, Avg3500Lat, map=mapCoord, color='magenta', thick=4, /AddCmd
end
cgControl, Execute=1
|
|
|
Re: Multiple plot with mapCoord [message #88909 is a reply to message #88908] |
Wed, 02 July 2014 12:21   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Morgan Silverman writes:
> Good article. I'm still missing something though. I'd like to use coyote graphics because I'm trying to make publication figures and from my understanding better quality can be gotten using cgWindow and ImageMagick. When I run my code I see the maps then they flash away and i'm left with just 4 colored lines that should be overlaid on the maps. I've tried with the mapCoord statements both inside and outside the loop both with the same results.
Well, there are a lot of things are wrong with your code. :-)
I would try something like this:
;*********************************************************** ********
PRO Map_Test
cities = ['Denver','Omaha','Atlanta','Portland','Seattle','Trenton']
city_lats = [ 39.75, 41.29, 33.84, 45.49, 47.62, 40.22]
city_lons = [ -105.00, -95.92, -84.38, -122.69, -122.34, -74.78]
cgLoadCT, 33, NColors=6, Bottom=1
lonmin = -125
lonmax = -65
latmin = 25
latmax = 60
centerlon = (lonmax-lonmin)/2.0 + lonmin
centerlat = (latmax-latmin)/2.0 + latmin
limit = [latmin, lonmin, latmax, lonmax]
xrange = [lonmin, lonmax]
yrange = [latmin, latmax]
mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', $
Limit=limit, Center_Lat=centarlat, center_lon=centerlon)
; Convert city locations to projected meters.
xy = mapCoord->Forward(city_lons, city_lats)
city_x = Reform(xy[0,*])
city_y = Reform(xy[1,*])
; Set up 3-col by 2-row grid.
p = cgLayout([3,2], Aspect=0.5, YGAP=4, XGAP=6, $
OXMargin=[4,4], OYMargin=[4,6])
; Draw the plots.
FOR j=0,5 DO BEGIN
pos = p[*,j]
mapCoord -> SetProperty, Position=pos, /Draw
cgMap_Grid, MAP=mapCoord, /Box
cgMap_Continents, MAP=mapCoord, /Continents, /Countries, /USA
cgPlotS, city_x[j], city_y[j], Color=Byte(j+1), PSYM=16, SYMSize=2.0
x = (pos[2]-pos[0])/2.0 + pos[0]
y = pos[3] + (!D.Y_CH_SIZE * 2) / Float(!D.Y_Size)
cgText, x, y, cities[j], /Normal, Alignment=0.5
ENDFOR
END
; Run the program in a cgWindow.
cgWindow, 'Map_Test', WXSize=800, WYSize=400, WBackground='White'
END
;*********************************************************** ********
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: Multiple plot with mapCoord [message #88914 is a reply to message #88909] |
Thu, 03 July 2014 06:15   |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
On Wednesday, July 2, 2014 3:21:03 PM UTC-4, David Fanning wrote:
> Morgan Silverman writes:
>
>
>
>> Good article. I'm still missing something though. I'd like to use coyote graphics because I'm trying to make publication figures and from my understanding better quality can be gotten using cgWindow and ImageMagick. When I run my code I see the maps then they flash away and i'm left with just 4 colored lines that should be overlaid on the maps. I've tried with the mapCoord statements both inside and outside the loop both with the same results.
>
>
>
> Well, there are a lot of things are wrong with your code. :-)
>
>
>
> I would try something like this:
>
>
>
> ;*********************************************************** ********
>
> PRO Map_Test
>
>
>
> cities = ['Denver','Omaha','Atlanta','Portland','Seattle','Trenton']
>
> city_lats = [ 39.75, 41.29, 33.84, 45.49, 47.62, 40.22]
>
> city_lons = [ -105.00, -95.92, -84.38, -122.69, -122.34, -74.78]
>
>
>
> cgLoadCT, 33, NColors=6, Bottom=1
>
>
>
> lonmin = -125
>
> lonmax = -65
>
> latmin = 25
>
> latmax = 60
>
> centerlon = (lonmax-lonmin)/2.0 + lonmin
>
> centerlat = (latmax-latmin)/2.0 + latmin
>
> limit = [latmin, lonmin, latmax, lonmax]
>
> xrange = [lonmin, lonmax]
>
> yrange = [latmin, latmax]
>
> mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', $
>
> Limit=limit, Center_Lat=centarlat, center_lon=centerlon)
>
>
>
> ; Convert city locations to projected meters.
>
> xy = mapCoord->Forward(city_lons, city_lats)
>
> city_x = Reform(xy[0,*])
>
> city_y = Reform(xy[1,*])
>
>
>
> ; Set up 3-col by 2-row grid.
>
> p = cgLayout([3,2], Aspect=0.5, YGAP=4, XGAP=6, $
>
> OXMargin=[4,4], OYMargin=[4,6])
>
>
>
> ; Draw the plots.
>
> FOR j=0,5 DO BEGIN
>
> pos = p[*,j]
>
> mapCoord -> SetProperty, Position=pos, /Draw
>
> cgMap_Grid, MAP=mapCoord, /Box
>
> cgMap_Continents, MAP=mapCoord, /Continents, /Countries, /USA
>
> cgPlotS, city_x[j], city_y[j], Color=Byte(j+1), PSYM=16, SYMSize=2.0
>
> x = (pos[2]-pos[0])/2.0 + pos[0]
>
> y = pos[3] + (!D.Y_CH_SIZE * 2) / Float(!D.Y_Size)
>
> cgText, x, y, cities[j], /Normal, Alignment=0.5
>
> ENDFOR
>
> END
>
>
>
> ; Run the program in a cgWindow.
>
> cgWindow, 'Map_Test', WXSize=800, WYSize=400, WBackground='White'
>
> END
>
> ;*********************************************************** ********
>
>
>
> 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.")
I'm sorry for all the trouble but I tried modifying your code to work with my data and I get both a black background IDL window (which didn't happen in your Map_Test) and a white background resizable graphics window that creates an infinite number of windows until I hard quite IDL. I think this is because Avg2000Lon=float(73) so my code is trying to create 73 windows. Map_Test is based on 6 discrete city lat/lons. How do I modify this to work with my array of values. I'm plotting trajectories so each window has several different trajectories plotted in each graph. Thanks.
Pro Plot6PanelTraj_MOZAICpaper
restore, './DAQPadonia_AvgBackTraj_Flight7.sav'
lonmin = -125
lonmax = -65
latmin = 25
latmax = 60
centerlon = (lonmax-lonmin)/2.0 + lonmin
centerlat = (latmax-latmin)/2.0 + latmin
limit = [latmin, lonmin, latmax, lonmax]
xrange = [lonmin, lonmax]
yrange = [latmin, latmax]
mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
center_lat=centarlat, center_lon=centerlon)
; Convert trajectory locations to projected meter space
xy = mapCoord->Forward(Avg2000Lon, Avg2000Lat)
locx = Reform(xy[0,*])
locy = Reform(xy[1,*])
; Set up 2-col by 3-row grid
p = cgLayout([2,3], Aspect=0.5, YGap=4, XGap=6, OXMargin=[4,4], OYMargin=[4,6])
; Draw plots
for j=0,5 do begin
pos = p(*,j)
mapCoord->SetProperty, Position=pos, /Draw
cgMap_Grid, map=mapCoord, /box
cgMap_Continents, map=mapCoord, /continents, /countries, /usa
cgplotS, locx, locy, color='blue', thick=4
end
; Run the program in a cgWindow.
cgWindow, 'Plot6PanelTraj_MOZAICPaper', WXSize=800, WYSize=400, WBackground='White'
|
|
|
Re: Multiple plot with mapCoord [message #88915 is a reply to message #88914] |
Thu, 03 July 2014 06:46   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Morgan Silverman writes:
> I'm sorry for all the trouble but I tried modifying your code
> to work with my data and I get both a black background IDL window
> (which didn't happen in your Map_Test) and a white background
> resizable graphics window that creates an infinite number of windows
> until I hard quite IDL. I think this is because Avg2000Lon=float(73)
> so my code is trying to create 73 windows. Map_Test is based on 6
> discrete city lat/lons. How do I modify this to work with my array of
> values. I'm plotting trajectories so each window has several different
> trajectories plotted in each graph.
The DRAW method of the cgMap object doesn't "erase" the display before
it draws, in the way, for example, a cgPlot command would. So, it draws
in whatever window is currently open and in the "opposite" color. If you
want to draw into a white background window, create one:
cgDisplay, 800, 400
No one who has read this newsgroup for any length of time can not know
by now that the first thing to do when you have a problem with a Coyote
Graphic routine is to update your library:
http://www.idlcoyote.com/code_tips/fixcoyoteprogram.php
So, I presume you have done that and this is not why you are generating
multiple windows.
I think it is more likely that you still have an ADDCMD keyword on one
of the commands you are using that you haven't shown us.
I drew points in my example, but if converting that cgPlotS command to
draw lines takes more than 10 seconds it is taking way too long. :-)
If you would like to purchase some consulting time and send me the code,
the Coyote Store is always open. :-)
http://www.idlcoyote.com/coyotestore/
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: Multiple plot with mapCoord [message #88916 is a reply to message #88915] |
Thu, 03 July 2014 07:24  |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
On Thursday, July 3, 2014 9:46:28 AM UTC-4, David Fanning wrote:
> Morgan Silverman writes:
>
>
>
>> I'm sorry for all the trouble but I tried modifying your code
>
>> to work with my data and I get both a black background IDL window
>
>> (which didn't happen in your Map_Test) and a white background
>
>> resizable graphics window that creates an infinite number of windows
>
>> until I hard quite IDL. I think this is because Avg2000Lon=float(73)
>
>> so my code is trying to create 73 windows. Map_Test is based on 6
>
>> discrete city lat/lons. How do I modify this to work with my array of
>
>> values. I'm plotting trajectories so each window has several different
>
>> trajectories plotted in each graph.
>
>
>
> The DRAW method of the cgMap object doesn't "erase" the display before
>
> it draws, in the way, for example, a cgPlot command would. So, it draws
>
> in whatever window is currently open and in the "opposite" color. If you
>
> want to draw into a white background window, create one:
>
>
>
> cgDisplay, 800, 400
>
>
>
> No one who has read this newsgroup for any length of time can not know
>
> by now that the first thing to do when you have a problem with a Coyote
>
> Graphic routine is to update your library:
>
>
>
> http://www.idlcoyote.com/code_tips/fixcoyoteprogram.php
>
>
>
> So, I presume you have done that and this is not why you are generating
>
> multiple windows.
>
>
>
> I think it is more likely that you still have an ADDCMD keyword on one
>
> of the commands you are using that you haven't shown us.
>
>
>
> I drew points in my example, but if converting that cgPlotS command to
>
> draw lines takes more than 10 seconds it is taking way too long. :-)
>
>
>
> If you would like to purchase some consulting time and send me the code,
>
> the Coyote Store is always open. :-)
>
>
>
> http://www.idlcoyote.com/coyotestore/
>
>
>
> 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.")
Thank you for all your help. Just wanted to let you know that I figured the problem out. I was missing an end statement before the cgWindow command to close the procedure. Now only 1 resizable window created!!
|
|
|