## [Matplotlib-users] Map displayed on a plot

 [Matplotlib-users] Map displayed on a plot From: Brian Larsen - 2010-08-27 17:11:41 Attachments: Message as HTML ```Hello all, I am plotting satellite orbit files and it looks really nice to plot an Earth in the center with the continents on it to orient people to where the spacecraft is. Does anyway know how to do this? All I seem to be able to do is create a whole globe as the figure. In this simple example: from pylab import * r = ndarray(40) r[:] = 3.3 rad = linspace(0, 2*pi, 40) figure() subplot(111, polar=True) plot(rad, r, lw=3) draw() wouldn't it look great to have the earth plotted in the space up to 1.0 (as measured in earth radii)? Thanks much, Brian -- Brian A. Larsen Space Science and Applications Group ISR-1 Los Alamos National Laboratory PO Box 1663, MS-D466 Los Alamos, NM 87545 USA (For overnight add: SM-30, Bikini Atoll Road) Phone: 505-665-7691 Fax: 505-665-7395 email: balarsen@... Correspondence / Technical data or Software Publicly Available ```

 [Matplotlib-users] Map displayed on a plot From: Brian Larsen - 2010-08-27 17:11:41 Attachments: Message as HTML ```Hello all, I am plotting satellite orbit files and it looks really nice to plot an Earth in the center with the continents on it to orient people to where the spacecraft is. Does anyway know how to do this? All I seem to be able to do is create a whole globe as the figure. In this simple example: from pylab import * r = ndarray(40) r[:] = 3.3 rad = linspace(0, 2*pi, 40) figure() subplot(111, polar=True) plot(rad, r, lw=3) draw() wouldn't it look great to have the earth plotted in the space up to 1.0 (as measured in earth radii)? Thanks much, Brian -- Brian A. Larsen Space Science and Applications Group ISR-1 Los Alamos National Laboratory PO Box 1663, MS-D466 Los Alamos, NM 87545 USA (For overnight add: SM-30, Bikini Atoll Road) Phone: 505-665-7691 Fax: 505-665-7395 email: balarsen@... Correspondence / Technical data or Software Publicly Available ```
 Re: [Matplotlib-users] Map displayed on a plot From: Benjamin Root - 2010-08-27 17:25:24 Attachments: Message as HTML ```On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen wrote: > Hello all, > > I am plotting satellite orbit files and it looks really nice to plot an > Earth in the center with the continents on it to orient people to where the > spacecraft is. Does anyway know how to do this? All I seem to be able to > do is create a whole globe as the figure. > > In this simple example: > > from pylab import * > r = ndarray(40) > r[:] = 3.3 > rad = linspace(0, 2*pi, 40) > figure() > subplot(111, polar=True) > plot(rad, r, lw=3) > draw() > > > wouldn't it look great to have the earth plotted in the space up to 1.0 (as > measured in earth radii)? > > Thanks much, > > Brian > > > Have you checked out the basemap tool? http://matplotlib.sourceforge.net/basemap/doc/html/ Ben Root ```
 Re: [Matplotlib-users] Map displayed on a plot From: Jeff Whitaker - 2010-08-27 17:36:13 Attachments: Message as HTML ``` On 8/27/10 11:24 AM, Benjamin Root wrote: > On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen > wrote: > > Hello all, > > I am plotting satellite orbit files and it looks really nice to > plot an Earth in the center with the continents on it to orient > people to where the spacecraft is. Does anyway know how to do > this? All I seem to be able to do is create a whole globe as the > figure. > > In this simple example: > > from pylab import * > r = ndarray(40) > r[:] = 3.3 > rad = linspace(0, 2*pi, 40) > figure() > subplot(111, polar=True) > plot(rad, r, lw=3) > draw() > > > wouldn't it look great to have the earth plotted in the space up > to 1.0 (as measured in earth radii)? > > Thanks much, > > Brian > > > > Have you checked out the basemap tool? > > http://matplotlib.sourceforge.net/basemap/doc/html/ > > Ben Root Sounds like you want the orthographic projection http://matplotlib.sourceforge.net/basemap/doc/html/users/ortho.html http://www.scipy.org/Cookbook/Matplotlib/Maps or the 'near-sided perspective' projection http://matplotlib.sourceforge.net/basemap/doc/html/users/nsper.html -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ```
 Re: [Matplotlib-users] Map displayed on a plot From: Brian Larsen - 2010-08-27 17:39:44 Attachments: Message as HTML ```Ben, I have but no where in there do I see (or at least understand) how to draw a map on top of a current figure with set bounds in data space... Cheers, Brian On Aug 27, 2010, at 11:24 AM, Benjamin Root wrote: > On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen wrote: > Hello all, > > I am plotting satellite orbit files and it looks really nice to plot an Earth in the center with the continents on it to orient people to where the spacecraft is. Does anyway know how to do this? All I seem to be able to do is create a whole globe as the figure. > > In this simple example: > > from pylab import * > r = ndarray(40) > r[:] = 3.3 > rad = linspace(0, 2*pi, 40) > figure() > subplot(111, polar=True) > plot(rad, r, lw=3) > draw() > > > wouldn't it look great to have the earth plotted in the space up to 1.0 (as measured in earth radii)? > > Thanks much, > > Brian > > > > Have you checked out the basemap tool? > > http://matplotlib.sourceforge.net/basemap/doc/html/ > > Ben Root > -- Brian A. Larsen Space Science and Applications Group ISR-1 Los Alamos National Laboratory PO Box 1663, MS-D466 Los Alamos, NM 87545 USA (For overnight add: SM-30, Bikini Atoll Road) Phone: 505-665-7691 Fax: 505-665-7395 email: balarsen@... Correspondence / Technical data or Software Publicly Available ```
 Re: [Matplotlib-users] Map displayed on a plot From: Aman Thakral - 2010-08-27 17:53:16 Attachments: Message as HTML ```Here is an example of the general usage for an orthographic projection. def genMap(fig, ax, llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat): fig.sca(ax) m = Basemap(resolution='i',projection='ortho',lon_0=(urcrnrlon+llcrnrlon)/2,lat_0=(urcrnrlat+llcrnrlat)/2) m.drawcoastlines() m.drawmapboundary(fill_color='aqua') m.drawstates(linewidth=3) m.fillcontinents(color='coral',lake_color='aqua') m.drawcountries(linewidth=3) where: llcrnlon = lower left corner longitude llcrnlat = lower left corner latitude urcrnlon =upper right corner longitude urcrnlat = upper right corner latitude On Fri, Aug 27, 2010 at 1:39 PM, Brian Larsen wrote: > Ben, > > I have but no where in there do I see (or at least understand) how to draw > a map on top of a current figure with set bounds in data space... > > Cheers, > > Brian > > > On Aug 27, 2010, at 11:24 AM, Benjamin Root wrote: > > On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen wrote: > >> Hello all, >> >> I am plotting satellite orbit files and it looks really nice to plot an >> Earth in the center with the continents on it to orient people to where the >> spacecraft is. Does anyway know how to do this? All I seem to be able to >> do is create a whole globe as the figure. >> >> In this simple example: >> >> from pylab import * >> r = ndarray(40) >> r[:] = 3.3 >> rad = linspace(0, 2*pi, 40) >> figure() >> subplot(111, polar=True) >> plot(rad, r, lw=3) >> draw() >> >> >> wouldn't it look great to have the earth plotted in the space up to 1.0 >> (as measured in earth radii)? >> >> Thanks much, >> >> Brian >> >> >> > Have you checked out the basemap tool? > > http://matplotlib.sourceforge.net/basemap/doc/html/ > > Ben Root > > > > > > > -- > > Brian A. Larsen > Space Science and Applications > Group ISR-1 > Los Alamos National Laboratory > PO Box 1663, MS-D466 > Los Alamos, NM 87545 > USA > > (For overnight add: > SM-30, Bikini Atoll Road) > > Phone: 505-665-7691 > Fax: 505-665-7395 > email: balarsen@... > > Correspondence / > Technical data or Software Publicly Available > > > > > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- Aman Thakral B.Eng & Biosci, M.Eng Design ```
 Re: [Matplotlib-users] Map displayed on a plot From: Brian Larsen - 2010-08-27 18:05:34 Attachments: Message as HTML ```Thanks, that a step, but how do I tell matplotlib where to then put this map? It needs to be on the current figure with the current axes but between 0 and 1 in radius. Imagine this plot but the black circle instead contains a map of the earth as seen from space in the right viewing geometry. http://plasmasphere.nasa.gov/models/gcpm_v22_eq_kp1.jpg I can work out the geometry and all but putting the map in that black region has me baffled. Brian On Aug 27, 2010, at 11:52 AM, Aman Thakral wrote: > Here is an example of the general usage for an orthographic projection. > > def genMap(fig, ax, llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat): > fig.sca(ax) > m = Basemap(resolution='i',projection='ortho',lon_0=(urcrnrlon+llcrnrlon)/2,lat_0=(urcrnrlat+llcrnrlat)/2) > m.drawcoastlines() > m.drawmapboundary(fill_color='aqua') > m.drawstates(linewidth=3) > m.fillcontinents(color='coral',lake_color='aqua') > m.drawcountries(linewidth=3) > > where: > llcrnlon = lower left corner longitude > llcrnlat = lower left corner latitude > urcrnlon =upper right corner longitude > urcrnlat = upper right corner latitude > > > On Fri, Aug 27, 2010 at 1:39 PM, Brian Larsen wrote: > Ben, > > I have but no where in there do I see (or at least understand) how to draw a map on top of a current figure with set bounds in data space... > > Cheers, > > Brian > > > On Aug 27, 2010, at 11:24 AM, Benjamin Root wrote: > >> On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen wrote: >> Hello all, >> >> I am plotting satellite orbit files and it looks really nice to plot an Earth in the center with the continents on it to orient people to where the spacecraft is. Does anyway know how to do this? All I seem to be able to do is create a whole globe as the figure. >> >> In this simple example: >> >> from pylab import * >> r = ndarray(40) >> r[:] = 3.3 >> rad = linspace(0, 2*pi, 40) >> figure() >> subplot(111, polar=True) >> plot(rad, r, lw=3) >> draw() >> >> >> wouldn't it look great to have the earth plotted in the space up to 1.0 (as measured in earth radii)? >> >> Thanks much, >> >> Brian >> >> >> >> Have you checked out the basemap tool? >> >> http://matplotlib.sourceforge.net/basemap/doc/html/ >> >> Ben Root >> > > > > > > -- > > Brian A. Larsen > Space Science and Applications > Group ISR-1 > Los Alamos National Laboratory > PO Box 1663, MS-D466 > Los Alamos, NM 87545 > USA > > (For overnight add: > SM-30, Bikini Atoll Road) > > Phone: 505-665-7691 > Fax: 505-665-7395 > email: balarsen@... > > Correspondence / > Technical data or Software Publicly Available > > > > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > -- > Aman Thakral > B.Eng & Biosci, M.Eng Design -- Brian A. Larsen Space Science and Applications Group ISR-1 Los Alamos National Laboratory PO Box 1663, MS-D466 Los Alamos, NM 87545 USA (For overnight add: SM-30, Bikini Atoll Road) Phone: 505-665-7691 Fax: 505-665-7395 email: balarsen@... Correspondence / Technical data or Software Publicly Available ```
 Re: [Matplotlib-users] Map displayed on a plot From: Jeff Whitaker - 2010-08-27 17:55:35 Attachments: Message as HTML ``` On 8/27/10 11:39 AM, Brian Larsen wrote: > Ben, > > I have but no where in there do I see (or at least understand) how to > draw a map on top of a current figure with set bounds in data space... > > Cheers, > > Brian > Brian: Something like this perhaps? from pylab import * from mpl_toolkits.basemap import Basemap lons = linspace(0, 360, 361) lats = 40.*ones(len(lons)) map = Basemap(projection='ortho',lon_0=270,lat_0=90.) x,y = map(lons,lats) map.plot(x,y,color='y') map.bluemarble(scale=0.5) show() -Jeff > > On Aug 27, 2010, at 11:24 AM, Benjamin Root wrote: > >> On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen > > wrote: >> >> Hello all, >> >> I am plotting satellite orbit files and it looks really nice to >> plot an Earth in the center with the continents on it to orient >> people to where the spacecraft is. Does anyway know how to do >> this? All I seem to be able to do is create a whole globe as the >> figure. >> >> In this simple example: >> >> from pylab import * >> r = ndarray(40) >> r[:] = 3.3 >> rad = linspace(0, 2*pi, 40) >> figure() >> subplot(111, polar=True) >> plot(rad, r, lw=3) >> draw() >> >> >> wouldn't it look great to have the earth plotted in the space up >> to 1.0 (as measured in earth radii)? >> >> Thanks much, >> >> Brian >> >> >> >> Have you checked out the basemap tool? >> >> http://matplotlib.sourceforge.net/basemap/doc/html/ >> >> Ben Root >> > > > > > > -- > > Brian A. Larsen > Space Science and Applications > Group ISR-1 > Los Alamos National Laboratory > PO Box 1663, MS-D466 > Los Alamos, NM 87545 > USA > > (For overnight add: > SM-30, Bikini Atoll Road) > > Phone: 505-665-7691 > Fax: 505-665-7395 > email: balarsen@... > > Correspondence / > Technical data or Software Publicly Available > > > > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ```
 Re: [Matplotlib-users] Map displayed on a plot From: Jeff Whitaker - 2010-08-27 19:30:39 Attachments: Message as HTML ``` On 8/27/10 12:05 PM, Brian Larsen wrote: > Thanks, that a step, but how do I tell matplotlib where to then put > this map? It needs to be on the current figure with the current axes > but between 0 and 1 in radius. > > Imagine this plot but the black circle instead contains a map of the > earth as seen from space in the right viewing geometry. > http://plasmasphere.nasa.gov/models/gcpm_v22_eq_kp1.jpg > > I can work out the geometry and all but putting the map in that black > region has me baffled. > > Brian Brian: You can make the basemap axes sit inside your other figure by setting the axes limits manually. Even if you could figure out exactly where to put it though - it will cover more than the black region (the basemap axes will be square). Perhaps the axes background can be set to be transparent - I don't know for sure. -Jeff > > > > > On Aug 27, 2010, at 11:52 AM, Aman Thakral wrote: > >> Here is an example of the general usage for an orthographic projection. >> >> def genMap(fig, ax, llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat): >> fig.sca(ax) >> m = >> Basemap(resolution='i',projection='ortho',lon_0=(urcrnrlon+llcrnrlon)/2,lat_0=(urcrnrlat+llcrnrlat)/2) >> m.drawcoastlines() >> m.drawmapboundary(fill_color='aqua') >> m.drawstates(linewidth=3) >> m.fillcontinents(color='coral',lake_color='aqua') >> m.drawcountries(linewidth=3) >> >> where: >> llcrnlon = lower left corner longitude >> llcrnlat = lower left corner latitude >> urcrnlon =upper right corner longitude >> urcrnlat = upper right corner latitude >> >> >> On Fri, Aug 27, 2010 at 1:39 PM, Brian Larsen > > wrote: >> >> Ben, >> >> I have but no where in there do I see (or at least understand) >> how to draw a map on top of a current figure with set bounds in >> data space... >> >> Cheers, >> >> Brian >> >> >> On Aug 27, 2010, at 11:24 AM, Benjamin Root wrote: >> >>> On Fri, Aug 27, 2010 at 12:11 PM, Brian Larsen >>> > wrote: >>> >>> Hello all, >>> >>> I am plotting satellite orbit files and it looks really nice >>> to plot an Earth in the center with the continents on it to >>> orient people to where the spacecraft is. Does anyway know >>> how to do this? All I seem to be able to do is create a >>> whole globe as the figure. >>> >>> In this simple example: >>> >>> from pylab import * >>> r = ndarray(40) >>> r[:] = 3.3 >>> rad = linspace(0, 2*pi, 40) >>> figure() >>> subplot(111, polar=True) >>> plot(rad, r, lw=3) >>> draw() >>> >>> >>> wouldn't it look great to have the earth plotted in the >>> space up to 1.0 (as measured in earth radii)? >>> >>> Thanks much, >>> >>> Brian >>> >>> >>> >>> Have you checked out the basemap tool? >>> >>> http://matplotlib.sourceforge.net/basemap/doc/html/ >>> >>> Ben Root >>> >> >> >> >> >> >> -- >> >> Brian A. Larsen >> Space Science and Applications >> Group ISR-1 >> Los Alamos National Laboratory >> PO Box 1663, MS-D466 >> Los Alamos, NM 87545 >> USA >> >> (For overnight add: >> SM-30, Bikini Atoll Road) >> >> Phone: 505-665-7691 >> Fax: 505-665-7395 >> email: balarsen@... >> >> Correspondence / >> Technical data or Software Publicly Available >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program >> Be part of this innovative community and reach millions of >> netbook users >> worldwide. Take advantage of special opportunities to increase >> revenue and >> speed time-to-market. Join now, and jumpstart your future. >> http://p.sf.net/sfu/intel-atom-d2d >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@... >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> >> -- >> Aman Thakral >> B.Eng & Biosci, M.Eng Design > > > > > > -- > > Brian A. Larsen > Space Science and Applications > Group ISR-1 > Los Alamos National Laboratory > PO Box 1663, MS-D466 > Los Alamos, NM 87545 > USA > > (For overnight add: > SM-30, Bikini Atoll Road) > > Phone: 505-665-7691 > Fax: 505-665-7395 > email: balarsen@... > > Correspondence / > Technical data or Software Publicly Available > > > > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ```