Re: [Matplotlib-users] Problem saving open symbols in PDF
On 2012/10/16 4:27 PM, Gökhan Sever wrote: > Hello, > > I see that a few days old clone of mpl, cannot save open symbols > correctly in a pdf file. > > Here is a simple test case (in ipython --pylab): > > I6 xx = np.random.random(1000) > > I7 plt.plot(xx, 'D', mfc='none') > > On screen open symbols are fine, as expected transparency works fine, > however when saved in pdf transparency disappears, symbols cover each > other. (Saving to png is also fine) > > Could you confirm if this is a case in another installation? Confirmed with 1.2.x. The problem is only on pdf; ps and svg are correct. Eric > > Thanks. > > -- > Gökhan > > > -- > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > > > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Problem saving open symbols in PDF
Hello, I see that a few days old clone of mpl, cannot save open symbols correctly in a pdf file. Here is a simple test case (in ipython --pylab): I6 xx = np.random.random(1000) I7 plt.plot(xx, 'D', mfc='none') On screen open symbols are fine, as expected transparency works fine, however when saved in pdf transparency disappears, symbols cover each other. (Saving to png is also fine) Could you confirm if this is a case in another installation? Thanks. -- Gökhan -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 11:20 AM, Rich Signell wrote: > Jeff, > Yep, that worked! So here is a working example of OWSlib with > Basemap: http://nbviewer.ipython.org/3900648/ > > I switched the Basemap projection to 'cyl' because we need to ensure > that Basemap and WMS are using the same projection, right? (and since > I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). > > Thanks! > Rich Rich: I took your code and made it into a new example. https://github.com/matplotlib/basemap/pull/84 I think it may be better not to try to create a wmsimage method, since OWSlib.wms.WebMapService is quite a complicated beast to wrap. -Jeff > > On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker wrote: >> On 10/16/12 8:48 AM, Rich Signell wrote: >>> Klo & Jeff, >>> >>> I tried making a concrete example of using OWSlib with Basemap, but >>> althought the WMS image looks good, the warpimage does not. >>> >>> http://nbviewer.ipython.org/3899690/ >>> >>> Do you see where I went wrong? >>> >>> Thanks, >>> Rich >> >> Rich: warpimage assumes the image is of global extent. In your example, I >> think you can just pass the image to the basemap imshow method with >> >> from matplotlib.image import imread >> import urllib2 >> m.imshow(imread(urllib2.urlopen(url)),origin='upper') >> >> Klo previously mentioned there might be a problem with the png data from the >> WMS server being 'chunked', s you might have to use klo's imshow_chunked >> function >> >> http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html >> >> >> -Jeff >> >>> On Sat, Oct 13, 2012 at 7:26 PM, klo uo wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell wrote: > WMS services are required to respond to "GetCapabiltiies" request, > reporting what layers, styles, times, elevations, and projections they > have available. So for example, using the Unidata WMS example below, > if we do: > > > > http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities > > we can see from the XML response that the Coordinate Reference Systems > supported are: > > EPSG:4326 > CRS:84 > EPSG:41001 > EPSG:3857 > EPSG:27700 > EPSG:3408 > EPSG:3409 > EPSG:32661 > EPSG:32761 > > And for this server, the supported response types are: > image/jpeg > image/png > application/vnd.google-earth.kmz > image/gif > > So I guess one way to proceed if you wanted to use WMS in Matplotlib > and avoid reprojection in python would be to: > 1. do the WMS GetCapabilities request to find the available supported > Coordinate Reference Systems (which will vary with WMS server) > 2. setup Basemap to use one of these CRS > 3. use the bounding box of your current axis (in projection units) as > part of a GetMap request to the WMS. > > -Rich > > On Thu, Oct 11, 2012 at 12:16 AM, klo uo wrote: >> I guess that's it? >> >> warpimage() as it is now, checks if passed image is url, so we can add >> additional check if image is url, with urlparse to deduce image >> coordinates >> and projection if present, then overlay it over already created Basemap >> object. >> >> >> >> -- >> Don't let slow site performance ruin your business. Deploy New Relic >> APM >> Deploy New Relic app performance management and know exactly >> what is happening inside your Ruby, Python, PHP, Java, and .NET app >> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> http://p.sf.net/sfu/newrelic-dev2dev >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > -- > Dr. Richard P. Signell (508) 457-2229 > USGS, 384 Woods Hole Rd. > Woods Hole, MA 02543-1598 >>> > > -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Clipping Contours
On Tue, Oct 16, 2012 at 2:34 AM, Damon McDougall wrote: > On Tue, Oct 16, 2012 at 8:04 AM, T J wrote: >> I'm interested in clipping the result of plt.contour (and >> plt.contourf) to a patch. However, QuadContourSet does not have a >> set_clip_path() method. Is there a way to do this? >> >> Here is an example plot that I have generated. >> >>http://imgur.com/pybIf >> >> For the curious, it plots contours of a function on the 2-simplex. >> The way I've gone about computing this is, unfortunately, convoluted. >> I generate a regular grid in 2D and treat each point as a projection >> of a 3D probability vector into 2D. Then, I invert the projection so >> that I have "distributions" and then compute the Z value for each >> point. The contours are then calculated, but now, I need to clip >> everything outside the triangle, as only points within the triangle >> correspond to actual distributions. >> >> Is there a more direct way to calculate contours on a restricted set? >> >> Thanks. > > The contour functions support masked regions. I think that might be > what you're looking for. Since the region you want to mask is a > triangle, maybe even use a masked triangulated contour plot? Here's > the call signature: > http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.tricontour > > Does that help? > Yes, that looks to be exactly what I am looking for. Note, the mask kwarg is barely mentioned in that docstring, but I think I get it. However, I am having some trouble. tricontour seems to fail when computing the Triangulation() object. Here is my code: http://codepad.org/cVB7YP9r This is a set of 152 points on a triangle. delaunay is mentioned to have problems for some pathological cases. Is a complete triangular grid considered as such a case? Code is shown below as well. import numpy as np import matplotlib.pyplot as plt points = np.array([ [0.8660254037844384, -0.5004], [0.7577722283113836, -0.5004], [0.6495190528383288, -0.5003], [0.5412658773652739, -0.5003], [0.4330127018922191, -0.5002], [0.3247595264191642, -0.5002], [0.21650635094610943, -0.5002], [0.10825317547305463, -0.5001], [-2.220446049250313e-16, -0.5001], [-0.10825317547305507, -0.5], [-0.21650635094610993, -0.5], [-0.32475952641916467, -0.5], [-0.4330127018922195, -0.4999], [-0.5412658773652743, -0.4999], [-0.6495190528383291, -0.49983], [-0.7577722283113839, -0.4998], [-0.8660254037844388, -0.4997], [0.811898816047911, -0.406250044], [0.7036456405748561, -0.40625004], [0.5953924651018013, -0.406250033], [0.48713928962874653, -0.40625003], [0.3788861141556917, -0.40625002], [0.2706329386826369, -0.40625002], [0.16237976320958203, -0.40625001], [0.05412658773652723, -0.40625001], [-0.05412658773652762, -0.406250006], [-0.16237976320958242, -0.40625], [-0.2706329386826372, -0.40625], [-0.37888611415569207, -0.406249994], [-0.4871392896287469, -0.40624999], [-0.5953924651018018, -0.406249983], [-0.7036456405748566, -0.40624998], [-0.8118988160479114, -0.40624997], [0.7577722283113836, -0.31250004], [0.6495190528383288, -0.312500033], [0.541265877365274, -0.312500033], [0.4330127018922191, -0.31250002], [0.3247595264191643, -0.31250002], [0.21650635094610948, -0.312500017], [0.10825317547305463, -0.31250001], [-1.6653345369377348e-16, -0.31256], [-0.10825317547305502, -0.3125], [-0.21650635094610982, -0.3125], [-0.3247595264191646, -0.31244], [-0.43301270189221946, -0.3124], [-0.5412658773652743, -0.312499983], [-0.6495190528383292, -0.31249998], [-0.7577722283113839, -0.31249998], [0.7036456405748562, -0.218750036], [0.5953924651018013, -0.21875003], [0.48713928962874653, -0.218750028], [0.37888611415569173, -0.218750022], [0.2706329386826369, -0.218750017], [0.16237976320958208, -0.218750014], [0.05412658773652723, -0.218750008], [-0.054126587736527565, -0.218750006], [-0.16237976320958242, -0.21875], [-0.2706329386826372, -0.218749994], [-0.378886114155692, -0.218749992], [-0.48713928962874686, -0.218749986], [-0.5953924651018017, -0.21874998], [-0.7036456405748566, -0.218749978], [0.6495190528383288, -0.12533], [0.541265877365274, -0.12528], [0.43301270189221913, -0.12525], [0.32475952641916433, -0.1252], [0.2165063509461095, -0.12517], [0.10825317547305469, -0.1251], [-1.6653345369377348e-16, -0.12506], [-0.10825317547305496, -0.125], [-0.21650635094610982, -0.12499
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 11:20 AM, Rich Signell wrote: > Jeff, > Yep, that worked! So here is a working example of OWSlib with > Basemap: http://nbviewer.ipython.org/3900648/ > > I switched the Basemap projection to 'cyl' because we need to ensure > that Basemap and WMS are using the same projection, right? (and since > I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). > > Thanks! > Rich Rich: That's right. I'll go ahead and create a wmsimage method, similar to Klo's, but that uses OWSlib. You will then have to specify the projection using the epsg keyword when creating the Basemap instance. -Jeff > > On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker wrote: >> On 10/16/12 8:48 AM, Rich Signell wrote: >>> Klo & Jeff, >>> >>> I tried making a concrete example of using OWSlib with Basemap, but >>> althought the WMS image looks good, the warpimage does not. >>> >>> http://nbviewer.ipython.org/3899690/ >>> >>> Do you see where I went wrong? >>> >>> Thanks, >>> Rich >> >> Rich: warpimage assumes the image is of global extent. In your example, I >> think you can just pass the image to the basemap imshow method with >> >> from matplotlib.image import imread >> import urllib2 >> m.imshow(imread(urllib2.urlopen(url)),origin='upper') >> >> Klo previously mentioned there might be a problem with the png data from the >> WMS server being 'chunked', s you might have to use klo's imshow_chunked >> function >> >> http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html >> >> >> -Jeff >> >>> On Sat, Oct 13, 2012 at 7:26 PM, klo uo wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell wrote: > WMS services are required to respond to "GetCapabiltiies" request, > reporting what layers, styles, times, elevations, and projections they > have available. So for example, using the Unidata WMS example below, > if we do: > > > > http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities > > we can see from the XML response that the Coordinate Reference Systems > supported are: > > EPSG:4326 > CRS:84 > EPSG:41001 > EPSG:3857 > EPSG:27700 > EPSG:3408 > EPSG:3409 > EPSG:32661 > EPSG:32761 > > And for this server, the supported response types are: > image/jpeg > image/png > application/vnd.google-earth.kmz > image/gif > > So I guess one way to proceed if you wanted to use WMS in Matplotlib > and avoid reprojection in python would be to: > 1. do the WMS GetCapabilities request to find the available supported > Coordinate Reference Systems (which will vary with WMS server) > 2. setup Basemap to use one of these CRS > 3. use the bounding box of your current axis (in projection units) as > part of a GetMap request to the WMS. > > -Rich > > On Thu, Oct 11, 2012 at 12:16 AM, klo uo wrote: >> I guess that's it? >> >> warpimage() as it is now, checks if passed image is url, so we can add >> additional check if image is url, with urlparse to deduce image >> coordinates >> and projection if present, then overlay it over already created Basemap >> object. >> >> >> >> -- >> Don't let slow site performance ruin your business. Deploy New Relic >> APM >> Deploy New Relic app performance management and know exactly >> what is happening inside your Ruby, Python, PHP, Java, and .NET app >> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> http://p.sf.net/sfu/newrelic-dev2dev >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > -- > Dr. Richard P. Signell (508) 457-2229 > USGS, 384 Woods Hole Rd. > Woods Hole, MA 02543-1598 >>> > > -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
Jeff, Yep, that worked! So here is a working example of OWSlib with Basemap: http://nbviewer.ipython.org/3900648/ I switched the Basemap projection to 'cyl' because we need to ensure that Basemap and WMS are using the same projection, right? (and since I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). Thanks! Rich On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker wrote: > On 10/16/12 8:48 AM, Rich Signell wrote: >> >> Klo & Jeff, >> >> I tried making a concrete example of using OWSlib with Basemap, but >> althought the WMS image looks good, the warpimage does not. >> >> http://nbviewer.ipython.org/3899690/ >> >> Do you see where I went wrong? >> >> Thanks, >> Rich > > > Rich: warpimage assumes the image is of global extent. In your example, I > think you can just pass the image to the basemap imshow method with > > from matplotlib.image import imread > import urllib2 > m.imshow(imread(urllib2.urlopen(url)),origin='upper') > > Klo previously mentioned there might be a problem with the png data from the > WMS server being 'chunked', s you might have to use klo's imshow_chunked > function > > http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html > > > -Jeff > >> >> On Sat, Oct 13, 2012 at 7:26 PM, klo uo wrote: >>> >>> That's also what that snippet I linked does. You can add it to to Basemap >>> and it should work. >>> >>> However Jeff suggested we use this tiny package OWSlib and handle WMS >>> that >>> way, which is better IMHO, but for some reason we did not got further >>> reply. >>> >>> >>> >>> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell wrote: WMS services are required to respond to "GetCapabiltiies" request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: EPSG:4326 CRS:84 EPSG:41001 EPSG:3857 EPSG:27700 EPSG:3408 EPSG:3409 EPSG:32661 EPSG:32761 And for this server, the supported response types are: image/jpeg image/png application/vnd.google-earth.kmz image/gif So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo wrote: > > I guess that's it? > > warpimage() as it is now, checks if passed image is url, so we can add > additional check if image is url, with urlparse to deduce image > coordinates > and projection if present, then overlay it over already created Basemap > object. > > > > -- > Don't let slow site performance ruin your business. Deploy New Relic > APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 >>> >>> >> >> > -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] close a figure after show , when plotting many figures from script- using matplotlib.pyplot.figure
On Tue, Oct 16, 2012 at 11:25 AM, hari jayaram wrote: > Hi > I am a relative newbie to matplotlib. > > I have a python script that handles a dataset that comprises 384 sets of > data. > > At the present moment , I read in a set of data - process it - and the > create a figure using code shown below. > I am using windows with the default backend ( I think I set it to wx). > > When I run the program, figure after figure shows up..the program > continues from well to well plotting the figure. I can close the figure > window using the X on the right -hand side..while the program chugs along. > > Is there a way to just recycle the figure object , so that the plot shows > up for a brief second and refreshes when the next calculation is complete. > Each process_data function , takes a few minutes. > > Alternatively I just want to close the figure object I show after a brief > lag. I am OK if that happens instantaneously..but I dont know how > to achieve this. > Do I have to use the matplotlib.Figure object to achieve this functionality > > Thanks > Hari > > > Hari, To recycle the figure, try the following: import matplotlib.pyplot as plt def do_my_plot(par1, par2, well_id): processed_data_object = processed_dict[well_id] # Plot all the data par1.plot(processed_data_object.raw_x,processed_data_object.raw_y). par2.plot( # finally plt.show() # I tried fig.clf() def plot_and_process_data(): plt.ion() # Turn on interactive mode fig = plt.figure(figsize=(7,7) ax = fig.add_subplot(1,1,1) par1 =ax.twinx() par2 = ax.twinx() for well_id in list_of_384_well_ids: par1.cla() par2.cla() process_data(well_id) do_my_plot(par1, par2, well_id) Note, this is completely untested, but it would be how I would go about it at first. The "plt.ion()" turns on interactive mode to allow your code to continue running even after the plot window appears (but does not end until the last window is closed.). Of course, another approach would simply be to do "fig.savefig()" after every update to the figure and never use show() and ion() (essentially, a non-interactive head-less script). Hopefully, this helps. Ben Root -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] close a figure after show , when plotting many figures from script- using matplotlib.pyplot.figure
On Tue, Oct 16, 2012 at 5:09 PM, Sterling Smith wrote: > Hari, > > You can give a number to figure(), as in figure(1), and it will reuse figure > 1. Also, you can close figure 1 with pyplot.close(1). > > -Sterling > > On Oct 16, 2012, at 8:25AM, hari jayaram wrote: > >> Hi >> I am a relative newbie to matplotlib. >> >> I have a python script that handles a dataset that comprises 384 sets of >> data. >> >> At the present moment , I read in a set of data - process it - and the >> create a figure using code shown below. >> I am using windows with the default backend ( I think I set it to wx). >> >> When I run the program, figure after figure shows up..the program continues >> from well to well plotting the figure. I can close the figure window using >> the X on the right -hand side..while the program chugs along. >> >> Is there a way to just recycle the figure object , so that the plot shows up >> for a brief second and refreshes when the next calculation is complete. Each >> process_data function , takes a few minutes. >> >> Alternatively I just want to close the figure object I show after a brief >> lag. I am OK if that happens instantaneously..but I dont know how to >> achieve this. >> Do I have to use the matplotlib.Figure object to achieve this functionality >> >> Thanks >> Hari >> >> >> >> >> >> from matplotlib.pyplot import figure >> >> def do_my_plot(well_id): >> processed_data_object = processed_dict[well_id] >> fig = figure(figsize=(7,7) >> ax = fig.add_subplot(1,1,1) >> par1 =ax.twinx() >> par2 = ax.twinx() >> # Plot all the data >> par1.plot(processed_data_object.raw_x,processed_data_object.raw_y). >> par2.plot( >> # finally >> fig.show() >> # I tried fig.clf() >> >> >> def plot_and_process_data(): >> for well_id in list_of_384_well_ids: >> process_data(well_id) >> do_my_plot(well_id) Or you can call ax.cla() to clear the axes before plotting the next data set. Then subsequent calls to plot don't need 300+ figure objects. -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] close a figure after show , when plotting many figures from script- using matplotlib.pyplot.figure
Hari, You can give a number to figure(), as in figure(1), and it will reuse figure 1. Also, you can close figure 1 with pyplot.close(1). -Sterling On Oct 16, 2012, at 8:25AM, hari jayaram wrote: > Hi > I am a relative newbie to matplotlib. > > I have a python script that handles a dataset that comprises 384 sets of data. > > At the present moment , I read in a set of data - process it - and the create > a figure using code shown below. > I am using windows with the default backend ( I think I set it to wx). > > When I run the program, figure after figure shows up..the program continues > from well to well plotting the figure. I can close the figure window using > the X on the right -hand side..while the program chugs along. > > Is there a way to just recycle the figure object , so that the plot shows up > for a brief second and refreshes when the next calculation is complete. Each > process_data function , takes a few minutes. > > Alternatively I just want to close the figure object I show after a brief > lag. I am OK if that happens instantaneously..but I dont know how to achieve > this. > Do I have to use the matplotlib.Figure object to achieve this functionality > > Thanks > Hari > > > > > > from matplotlib.pyplot import figure > > def do_my_plot(well_id): > processed_data_object = processed_dict[well_id] > fig = figure(figsize=(7,7) > ax = fig.add_subplot(1,1,1) > par1 =ax.twinx() > par2 = ax.twinx() > # Plot all the data > par1.plot(processed_data_object.raw_x,processed_data_object.raw_y). > par2.plot( > # finally > fig.show() > # I tried fig.clf() > > > def plot_and_process_data(): > for well_id in list_of_384_well_ids: > process_data(well_id) > do_my_plot(well_id) > > > > > > > > > > > > -- > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 8:48 AM, Rich Signell wrote: > Klo & Jeff, > > I tried making a concrete example of using OWSlib with Basemap, but > althought the WMS image looks good, the warpimage does not. > > http://nbviewer.ipython.org/3899690/ > > Do you see where I went wrong? > > Thanks, > Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html -Jeff > > On Sat, Oct 13, 2012 at 7:26 PM, klo uo wrote: >> That's also what that snippet I linked does. You can add it to to Basemap >> and it should work. >> >> However Jeff suggested we use this tiny package OWSlib and handle WMS that >> way, which is better IMHO, but for some reason we did not got further reply. >> >> >> >> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell wrote: >>> WMS services are required to respond to "GetCapabiltiies" request, >>> reporting what layers, styles, times, elevations, and projections they >>> have available. So for example, using the Unidata WMS example below, >>> if we do: >>> >>> >>> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >>> >>> we can see from the XML response that the Coordinate Reference Systems >>> supported are: >>> >>> EPSG:4326 >>> CRS:84 >>> EPSG:41001 >>> EPSG:3857 >>> EPSG:27700 >>> EPSG:3408 >>> EPSG:3409 >>> EPSG:32661 >>> EPSG:32761 >>> >>> And for this server, the supported response types are: >>> image/jpeg >>> image/png >>> application/vnd.google-earth.kmz >>> image/gif >>> >>> So I guess one way to proceed if you wanted to use WMS in Matplotlib >>> and avoid reprojection in python would be to: >>> 1. do the WMS GetCapabilities request to find the available supported >>> Coordinate Reference Systems (which will vary with WMS server) >>> 2. setup Basemap to use one of these CRS >>> 3. use the bounding box of your current axis (in projection units) as >>> part of a GetMap request to the WMS. >>> >>> -Rich >>> >>> On Thu, Oct 11, 2012 at 12:16 AM, klo uo wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >>> -- >>> Dr. Richard P. Signell (508) 457-2229 >>> USGS, 384 Woods Hole Rd. >>> Woods Hole, MA 02543-1598 >> > > -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] close a figure after show , when plotting many figures from script- using matplotlib.pyplot.figure
Hi I am a relative newbie to matplotlib. I have a python script that handles a dataset that comprises 384 sets of data. At the present moment , I read in a set of data - process it - and the create a figure using code shown below. I am using windows with the default backend ( I think I set it to wx). When I run the program, figure after figure shows up..the program continues from well to well plotting the figure. I can close the figure window using the X on the right -hand side..while the program chugs along. Is there a way to just recycle the figure object , so that the plot shows up for a brief second and refreshes when the next calculation is complete. Each process_data function , takes a few minutes. Alternatively I just want to close the figure object I show after a brief lag. I am OK if that happens instantaneously..but I dont know how to achieve this. Do I have to use the matplotlib.Figure object to achieve this functionality Thanks Hari from matplotlib.pyplot import figure def do_my_plot(well_id): processed_data_object = processed_dict[well_id] fig = figure(figsize=(7,7) ax = fig.add_subplot(1,1,1) par1 =ax.twinx() par2 = ax.twinx() # Plot all the data par1.plot(processed_data_object.raw_x,processed_data_object.raw_y). par2.plot( # finally fig.show() # I tried fig.clf() def plot_and_process_data(): for well_id in list_of_384_well_ids: process_data(well_id) do_my_plot(well_id) -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
Klo & Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich On Sat, Oct 13, 2012 at 7:26 PM, klo uo wrote: > That's also what that snippet I linked does. You can add it to to Basemap > and it should work. > > However Jeff suggested we use this tiny package OWSlib and handle WMS that > way, which is better IMHO, but for some reason we did not got further reply. > > > > On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell wrote: >> >> WMS services are required to respond to "GetCapabiltiies" request, >> reporting what layers, styles, times, elevations, and projections they >> have available. So for example, using the Unidata WMS example below, >> if we do: >> >> >> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >> >> we can see from the XML response that the Coordinate Reference Systems >> supported are: >> >> EPSG:4326 >> CRS:84 >> EPSG:41001 >> EPSG:3857 >> EPSG:27700 >> EPSG:3408 >> EPSG:3409 >> EPSG:32661 >> EPSG:32761 >> >> And for this server, the supported response types are: >> image/jpeg >> image/png >> application/vnd.google-earth.kmz >> image/gif >> >> So I guess one way to proceed if you wanted to use WMS in Matplotlib >> and avoid reprojection in python would be to: >> 1. do the WMS GetCapabilities request to find the available supported >> Coordinate Reference Systems (which will vary with WMS server) >> 2. setup Basemap to use one of these CRS >> 3. use the bounding box of your current axis (in projection units) as >> part of a GetMap request to the WMS. >> >> -Rich >> >> On Thu, Oct 11, 2012 at 12:16 AM, klo uo wrote: >> > I guess that's it? >> > >> > warpimage() as it is now, checks if passed image is url, so we can add >> > additional check if image is url, with urlparse to deduce image >> > coordinates >> > and projection if present, then overlay it over already created Basemap >> > object. >> > >> > >> > -- >> > Don't let slow site performance ruin your business. Deploy New Relic APM >> > Deploy New Relic app performance management and know exactly >> > what is happening inside your Ruby, Python, PHP, Java, and .NET app >> > Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> > http://p.sf.net/sfu/newrelic-dev2dev >> > ___ >> > Matplotlib-users mailing list >> > Matplotlib-users@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > >> >> >> >> -- >> Dr. Richard P. Signell (508) 457-2229 >> USGS, 384 Woods Hole Rd. >> Woods Hole, MA 02543-1598 > > -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Filling area with a color like in an integral
> I have a coordination system with some plotted dots connected with a > line. Now I'd like to fill up the whole space between the line and the > x-axis. It is the same as in a integral calculation: > http://www.definicionabc.com/wp-content/uploads/Integral.png > What I want to do is the same as the green color in the linked picture. You can find an example in the matplotlib gallery (http://matplotlib.org/gallery.html): http://matplotlib.org/examples/pylab_examples/fill_between_demo.html The function you're looking for is ``fill_between``. Cheers, Andreas. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot() question
To plot a line using pyplot.plot you need an array/list of x coordinates and an array/list of y coordinates. So if you have: data = [[64, 13], [66, 22], [68, 9], [70, 11], [72, 8], [74, 10], [76, 11], [78, 8], [80, 9], [82, 9], [84, 15], [86, 13], [88, 5], [90, 9], [92, 13], [94, 12], [96, 7]] You can get a list of xs and a list of ys with: xs, ys = zip(*data) >From that point, it is as simple as doing: import matplotlib.pyplot as plt plt.plot(xs, ys) Hope that helps, Phil On 16 October 2012 09:39, ran...@0x06.net wrote: > [[64, 13], [66, 22], [68, 9], [70, 11], [72, 8], [74, 10], [76, 11], > [78, 8], [80, 9], [82, 9], [84, 15], [86, 13], [88, 5], [90, 9], [92, > 13], [94, 12], [96, 7]] > -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plot() question
Hi, I have a 2d array like: [[64, 13], [66, 22], [68, 9], [70, 11], [72, 8], [74, 10], [76, 11], [78, 8], [80, 9], [82, 9], [84, 15], [86, 13], [88, 5], [90, 9], [92, 13], [94, 12], [96, 7]] I'd like to plot a line/graph that goes through all those coordinates specified in the array. What I do: for point in array: plot(point[0], point[1], 'bo-') This draws the dots on the graph as desired - but it does not draw the line between them. Is the data format wrong? thanks -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Clipping Contours
On Tue, Oct 16, 2012 at 8:04 AM, T J wrote: > I'm interested in clipping the result of plt.contour (and > plt.contourf) to a patch. However, QuadContourSet does not have a > set_clip_path() method. Is there a way to do this? > > Here is an example plot that I have generated. > >http://imgur.com/pybIf > > For the curious, it plots contours of a function on the 2-simplex. > The way I've gone about computing this is, unfortunately, convoluted. > I generate a regular grid in 2D and treat each point as a projection > of a 3D probability vector into 2D. Then, I invert the projection so > that I have "distributions" and then compute the Z value for each > point. The contours are then calculated, but now, I need to clip > everything outside the triangle, as only points within the triangle > correspond to actual distributions. > > Is there a more direct way to calculate contours on a restricted set? > > Thanks. The contour functions support masked regions. I think that might be what you're looking for. Since the region you want to mask is a triangle, maybe even use a masked triangulated contour plot? Here's the call signature: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.tricontour Does that help? -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Clipping Contours
I'm interested in clipping the result of plt.contour (and plt.contourf) to a patch. However, QuadContourSet does not have a set_clip_path() method. Is there a way to do this? Here is an example plot that I have generated. http://imgur.com/pybIf For the curious, it plots contours of a function on the 2-simplex. The way I've gone about computing this is, unfortunately, convoluted. I generate a regular grid in 2D and treat each point as a projection of a 3D probability vector into 2D. Then, I invert the projection so that I have "distributions" and then compute the Z value for each point. The contours are then calculated, but now, I need to clip everything outside the triangle, as only points within the triangle correspond to actual distributions. Is there a more direct way to calculate contours on a restricted set? Thanks. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users