From: Michael H. <mh...@us...> - 2007-12-14 19:26:12
|
I am using Basemap, and trying to create two maps: One large-scale map, and a small-scale inset map of the world centered on the location of the large-scale map. My ultimate goal is to create a figure where the inset map is inserted into a corner of the large-scale map. I can see two ways of doing this: 1) Create both as encapsulated postscript images separately, and put them together in a later "compositing" process. (I'm doing this already). 2) Create both as basemap instances, and then draw the smaller one on top of the large-scale one. I have no idea how to do this. A problem I have encountered with the first method is that my image background is set to white by default. I've tried to make it transparent by doing the following: fig = figure(figsize=(5,5),frameon=False) #turn the frame off completely fig.figurePatch.set_alpha(0.0) #tried setting this to 1.0 and 0.0, neither works Method #2 would be cleaner, if I could do what I wanted to do in terms of transparencies, but if not, I'll take method #1. Does anyone know if it is possible to set the image background transparent for encapsulated postscript output? Thanks, Mike ------------------------------------------------------ Michael Hearne mh...@us... (303) 273-8620 USGS National Earthquake Information Center 1711 Illinois St. Golden CO 80401 Senior Software Engineer Synergetics, Inc. ------------------------------------------------------ |
From: Jeff W. <js...@fa...> - 2007-12-14 19:28:39
|
Michael Hearne wrote: > I am using Basemap, and trying to create two maps: > > One large-scale map, and a small-scale inset map of the world centered > on the location of the large-scale map. My ultimate goal is to create > a figure where the inset map is inserted into a corner of the > large-scale map. I can see two ways of doing this: > > 1) Create both as encapsulated postscript images separately, and put > them together in a later "compositing" process. (I'm doing this already). > 2) Create both as basemap instances, and then draw the smaller one on > top of the large-scale one. I have no idea how to do this. > > A problem I have encountered with the first method is that my image > background is set to white by default. I've tried to make it > transparent by doing the following: > > fig = figure(figsize=(5,5),frameon=False) #turn the frame off completely > fig.figurePatch.set_alpha(0.0) #tried setting this to 1.0 and 0.0, > neither works > > Method #2 would be cleaner, if I could do what I wanted to do in terms > of transparencies, but if not, I'll take method #1. > > Does anyone know if it is possible to set the image background > transparent for encapsulated postscript output? > > Thanks, > > Mike > > Mike: Postscript doesn't support alpha transparency. It might work with PDF though. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: Tom J. <tj...@gm...> - 2007-12-17 08:53:16
|
On Dec 14, 2007 11:28 AM, Jeff Whitaker <js...@fa...> wrote: > Mike: Postscript doesn't support alpha transparency. It might work > with PDF though. pstricks (tex) provides transparency... http://tug.org/PSTricks/main.cgi?file=Examples/Colors/colors#transparency http://tug.org/PSTricks/main.cgi?file=pst-plot/3D/examples#coor Is there any way to get similar hacks into matplotlib? I'm guessing this is a lot of work though. |
From: Alan G I. <ai...@am...> - 2007-12-17 13:03:30
|
On Mon, 17 Dec 2007, Tom Johnson apparently wrote: > pstricks (tex) provides transparency... > http://tug.org/PSTricks/main.cgi?file=Examples/Colors/colors#transparency > http://tug.org/PSTricks/main.cgi?file=pst-plot/3D/examples#coor Impressive. How is it done? Cheers, Alan Isaac |
From: Michael D. <md...@st...> - 2007-12-17 14:51:20
|
Well, I hate to provide the disappointing answer, but it really doesn't work for Postscript. (The name pstricks has perhaps become misleading over time...) It inserts special codes in the Postscript that aren't part of the Ps standard, but that ps2pdf14 is able to convert into the correct Pdf commands to handle alpha-blending. I don't see any advantage to that kind of workflow (with matplotlib) over just going directly to PDF. There are other tricks to "fake" transparency in Postscript, for example, by calculating the polygon intersections, etc., but that is significant work, and hard to do in a general way (i.e. anything overlapping anything), without writing a full-fledged geometry framework. Fortunately, Adobe Reader already has such a thing. You can generate a PDF file with matplotlib, and then run it through "acroread -toPostScript foo.pdf", and get a reasonably well-optimized Postscript file. Unfortunately, ghostscript 7.07 doesn't seem to do this -- it can convert a pdf to a ps file, but the alphablended stuff appears as a raster image. Maybe newer versions (or poppler etc.) are able to do this, but I don't have them on my machine. It would be nice to know of an open source alternative, but Adobe Reader is at least free-as-in-beer. Cheers, Mike Alan G Isaac wrote: > On Mon, 17 Dec 2007, Tom Johnson apparently wrote: >> pstricks (tex) provides transparency... >> http://tug.org/PSTricks/main.cgi?file=Examples/Colors/colors#transparency >> http://tug.org/PSTricks/main.cgi?file=pst-plot/3D/examples#coor > > > Impressive. How is it done? > > Cheers, > Alan Isaac > > > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services > for just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |
From: Alan G I. <ai...@am...> - 2007-12-17 15:54:29
|
On Mon, 17 Dec 2007, Michael Droettboom apparently wrote: > You can generate a PDF file with matplotlib, and then run > it through "acroread -toPostScript foo.pdf", and get > a reasonably well-optimized Postscript file. I did not know that. Thanks! Alan |
From: Jeff W. <js...@fa...> - 2007-12-14 19:50:06
|
Michael Hearne wrote: > Jeff - Darn it. So is there a way to embed an axis _inside_ another, > possibly with a transparent background? > > --Mike Mike: Not quite sure why you need to have it transparent - you definitely can't have that with postscript, but it should be possible with the other backends (png, pdf or svg). There's an example of embedded axes at http://matplotlib.sourceforge.net/screenshots.html (axes_demo.py). The inset axes is just drawn on top of the primary axes in the same figure. Is that what you want? -Jeff > On Dec 14, 2007, at 12:28 PM, Jeff Whitaker wrote: > >> Michael Hearne wrote: >>> I am using Basemap, and trying to create two maps: >>> >>> One large-scale map, and a small-scale inset map of the world >>> centered on the location of the large-scale map. My ultimate goal >>> is to create a figure where the inset map is inserted into a corner >>> of the large-scale map. I can see two ways of doing this: >>> >>> 1) Create both as encapsulated postscript images separately, and put >>> them together in a later "compositing" process. (I'm doing this >>> already). >>> 2) Create both as basemap instances, and then draw the smaller one >>> on top of the large-scale one. I have no idea how to do this. >>> >>> A problem I have encountered with the first method is that my image >>> background is set to white by default. I've tried to make it >>> transparent by doing the following: >>> >>> fig = figure(figsize=(5,5),frameon=False) #turn the frame off completely >>> fig.figurePatch.set_alpha(0.0) #tried setting this to 1.0 and 0.0, >>> neither works >>> >>> Method #2 would be cleaner, if I could do what I wanted to do in >>> terms of transparencies, but if not, I'll take method #1. >>> >>> Does anyone know if it is possible to set the image background >>> transparent for encapsulated postscript output? >>> >>> Thanks, >>> >>> Mike >>> >> >> Mike: Postscript doesn't support alpha transparency. It might work >> with PDF though. >> >> -Jeff >> >> -- >> Jeffrey S. Whitaker Phone : (303)497-6313 >> Meteorologist FAX : (303)497-6449 >> NOAA/OAR/PSD R/PSD1 Email : Jef...@no... >> <mailto:Jef...@no...> >> 325 Broadway Office : Skaggs Research Cntr 1D-124 >> Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg > > > > > ------------------------------------------------------ > Michael Hearne > mh...@us... <mailto:mh...@us...> > (303) 273-8620 > USGS National Earthquake Information Center > 1711 Illinois St. Golden CO 80401 > Senior Software Engineer > Synergetics, Inc. > ------------------------------------------------------ > > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: Michael H. <mh...@us...> - 2007-12-14 20:03:03
|
Jeff - Yes, that's what I want, thanks. I think more explanation is in order - my large-scale map is the default basemap projection. The inset map of the globe is a orthogonal projection, which means it comes out as a little circle. I want to insert this smaller map into the larger one, without having to see the area around the circle. I'm having trouble explaining this... here's an example: http://earthquake.usgs.gov/eqcenter/pager/us/2007kwau/us/1/onePAGER.pdf I want to replicate the little inset globe on the map with the contours. --Mike On Dec 14, 2007, at 12:49 PM, Jeff Whitaker wrote: > Michael Hearne wrote: >> Jeff - Darn it. So is there a way to embed an axis _inside_ >> another, possibly with a transparent background? >> >> --Mike > > > Mike: Not quite sure why you need to have it transparent - you > definitely can't have that with postscript, but it should be > possible with the other backends (png, pdf or svg). There's an > example of embedded axes at http://matplotlib.sourceforge.net/ > screenshots.html (axes_demo.py). The inset axes is just drawn on > top of the primary axes in the same figure. Is that what you want? > > -Jeff > >> On Dec 14, 2007, at 12:28 PM, Jeff Whitaker wrote: >> >>> Michael Hearne wrote: >>>> I am using Basemap, and trying to create two maps: >>>> >>>> One large-scale map, and a small-scale inset map of the world >>>> centered on the location of the large-scale map. My ultimate >>>> goal is to create a figure where the inset map is inserted into >>>> a corner of the large-scale map. I can see two ways of doing this: >>>> >>>> 1) Create both as encapsulated postscript images separately, and >>>> put them together in a later "compositing" process. (I'm doing >>>> this already). >>>> 2) Create both as basemap instances, and then draw the smaller >>>> one on top of the large-scale one. I have no idea how to do this. >>>> >>>> A problem I have encountered with the first method is that my >>>> image background is set to white by default. I've tried to make >>>> it transparent by doing the following: >>>> >>>> fig = figure(figsize=(5,5),frameon=False) #turn the frame off >>>> completely >>>> fig.figurePatch.set_alpha(0.0) #tried setting this to 1.0 and >>>> 0.0, neither works >>>> >>>> Method #2 would be cleaner, if I could do what I wanted to do in >>>> terms of transparencies, but if not, I'll take method #1. >>>> >>>> Does anyone know if it is possible to set the image background >>>> transparent for encapsulated postscript output? >>>> >>>> Thanks, >>>> >>>> Mike >>> >>> Mike: Postscript doesn't support alpha transparency. It might >>> work with PDF though. >>> >>> -Jeff >>> >>> -- >>> Jeffrey S. Whitaker Phone : (303)497-6313 >>> Meteorologist FAX : (303)497-6449 >>> NOAA/OAR/PSD R/PSD1 Email : Jef...@no... >>> <mailto:Jef...@no...> >>> 325 Broadway Office : Skaggs Research Cntr 1D-124 >>> Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg >> >> >> >> >> ------------------------------------------------------ >> Michael Hearne >> mh...@us... <mailto:mh...@us...> >> (303) 273-8620 >> USGS National Earthquake Information Center >> 1711 Illinois St. Golden CO 80401 >> Senior Software Engineer >> Synergetics, Inc. >> ------------------------------------------------------ >> >> > > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > Meteorologist FAX : (303)497-6449 > NOAA/OAR/PSD R/PSD1 Email : Jef...@no... > 325 Broadway Office : Skaggs Research Cntr 1D-124 > Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ------------------------------------------------------ Michael Hearne mh...@us... (303) 273-8620 USGS National Earthquake Information Center 1711 Illinois St. Golden CO 80401 Senior Software Engineer Synergetics, Inc. ------------------------------------------------------ |
From: Jeff W. <js...@fa...> - 2007-12-14 20:31:29
Attachments:
testinset.png
|
Michael Hearne wrote: > Jeff - Yes, that's what I want, thanks. > > I think more explanation is in order - my large-scale map is the > default basemap projection. The inset map of the globe is a > orthogonal projection, which means it comes out as a little circle. I > want to insert this smaller map into the larger one, without having to > see the area around the circle. > > I'm having trouble explaining this... here's an example: > http://earthquake.usgs.gov/eqcenter/pager/us/2007kwau/us/1/onePAGER.pdf > > I want to replicate the little inset globe on the map with the contours. > > --Mike Mike: Something like this? from matplotlib.toolkits.basemap import Basemap import pylab fig = pylab.figure() ax1 = fig.add_axes([0.1,0.1,0.8,0.8]) m = Basemap(ax=ax1) m.drawcoastlines(linewidth=0.5) m.fillcontinents() ax2 = fig.add_axes([0.1,0.425,0.15,0.15]) m2 = Basemap(projection='ortho',lon_0=-105,lat_0=40,ax=ax2) m2.drawmapboundary(fill_color='aqua') m2.drawcoastlines(linewidth=0.1) m2.fillcontinents(color='coral',lake_color='aqua') pylab.show() -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: Michael H. <mh...@us...> - 2007-12-14 20:38:46
|
Jeff - Yes! I'm working on implementing this now for my app... FYI, I got the following error: TypeError: drawmapboundary() got an unexpected keyword argument 'fill_color' and again for 'lake_color' on the fillcontinents() method. I'm using 0.9.7, which I think is the latest released version... --Mike On Dec 14, 2007, at 1:31 PM, Jeff Whitaker wrote: > from matplotlib.toolkits.basemap import Basemap > import pylab > fig = pylab.figure() > ax1 = fig.add_axes([0.1,0.1,0.8,0.8]) > m = Basemap(ax=ax1) > m.drawcoastlines(linewidth=0.5) > m.fillcontinents() > ax2 = fig.add_axes([0.1,0.425,0.15,0.15]) > m2 = Basemap(projection='ortho',lon_0=-105,lat_0=40,ax=ax2) > m2.drawmapboundary(fill_color='aqua') > m2.drawcoastlines(linewidth=0.1) > m2.fillcontinents(color='coral',lake_color='aqua') > pylab.show() ------------------------------------------------------ Michael Hearne mh...@us... (303) 273-8620 USGS National Earthquake Information Center 1711 Illinois St. Golden CO 80401 Senior Software Engineer Synergetics, Inc. ------------------------------------------------------ |
From: Jeff W. <js...@fa...> - 2007-12-14 20:48:11
|
Michael Hearne wrote: > Jeff - Yes! I'm working on implementing this now for my app... > > FYI, I got the following error: > TypeError: drawmapboundary() got an unexpected keyword argument > 'fill_color' > > > and again for 'lake_color' on the fillcontinents() method. > > I'm using 0.9.7, which I think is the latest released version... Mike: Those are new keywords in 0.9.8 (released a few weeks ago). -Jeff > > --Mike > On Dec 14, 2007, at 1:31 PM, Jeff Whitaker wrote: > >> from matplotlib.toolkits.basemap import Basemap >> >> import pylab >> >> fig = pylab.figure() >> >> ax1 = fig.add_axes([0.1,0.1,0.8,0.8]) >> >> m = Basemap(ax=ax1) >> >> m.drawcoastlines(linewidth=0.5) >> >> m.fillcontinents() >> >> ax2 = fig.add_axes([0.1,0.425,0.15,0.15]) >> >> m2 = Basemap(projection='ortho',lon_0=-105,lat_0=40,ax=ax2) >> >> m2.drawmapboundary(fill_color='aqua') >> >> m2.drawcoastlines(linewidth=0.1) >> >> m2.fillcontinents(color='coral',lake_color='aqua') >> >> pylab.show() >> > > > > > ------------------------------------------------------ > Michael Hearne > mh...@us... <mailto:mh...@us...> > (303) 273-8620 > USGS National Earthquake Information Center > 1711 Illinois St. Golden CO 80401 > Senior Software Engineer > Synergetics, Inc. > ------------------------------------------------------ > > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |