Re: [Matplotlib-users] windrose 0.5
Lionel I have encountered a problem with windrose. In some cases, one or more of the wind direction values are null [''] - the program then fails on line 200: values = select( [greater_equal( direction, wind_classes[i] )],[speed], default=-1.e20 ) Is it possible for you to upgrade the program to perform error trapping and simply skip (i.e. not process) any values that are null (and handle the exceptional case that all of them might, in fact, be null). Thanks! Derek >>> Lionel Roubeyrie <[EMAIL PROTECTED]> 2006/10/18 05:57:55 PM >>> Hi Derek, happy to see you use it, here is windrose0.5 with some improvments :-) > * do not outline the colors in black; its hard to see smaller/shorter > lines Done > * the % labels need either to go along a vector NOT used to draw data, > or > be drawn last (on top of data); or a combination of both Now "%" is set with the external label. I don't find how to set labels (and grids) above patches, ax.set_axisbelow(False) doesn't work :-( But for the moment you can use labangle parameter to move the labels. > * the 0.0% label can probably be omitted from the centre > * drawing a title("") on the plot is still problematic (it overwrites > the "N" in some cases) 0.0 is not longer draw > * default background color should be white Hum, everybody can set it directly from matplotlibrc or creating an polar axis before. > * a legend title will *very* useful Waiting for polar axes legend improvments :-) > > And a question - is it possible to restrict the plot to a portion of > the area; > say to the left, with a "rectangle" of the space available to the > right; or > up to the top, with a "rectangle" of the space available to the > bottom. > Plots often have to annotated and its useful to have some working > space > to do this. Don't know if I really understand what you want, but why don't you use subplot to split your figures? > > Thanks for all the good work! > Derek >PS Does anyone else using this program get the strange "[" and "]" >signs around the data ranges in the legend - how can this be turned off? You're the first saying you use it :-) Maybe differents progs versions. I use: |datas|[42]>matplotlib.__version__ Out [42]:'0.87.5' |datas|[43]>scipy.__version__ Out [43]:'0.5.1' |datas|[44]>numpy.__version__ Out [44]:'1.0b5' Lionel -- Lionel Roubeyrie - [EMAIL PROTECTED] LIMAIR http://www.limair.asso.fr -- This message is subject to the CSIR's copyright, terms and conditions and e-mail legal notice. Views expressed herein do not necessarily represent the views of the CSIR. CSIR E-mail Legal Notice http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html CSIR Copyright, Terms and Conditions http://mail.csir.co.za/CSIR_Copyright.html For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR Legal Notice send a blank message with REQUEST LEGAL in the subject line to [EMAIL PROTECTED] This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] windrose 0.5
Hi Derek, I forgot to mention: you can pass throught your problem by using a masked array instead of a simple array, and it should work fine, the 'default' parameter is here to fill missing value by -1.e20, then these directions will be dropped if your speed_classes not include that missing value (generally we compute on positives speeds). Le Jeudi 01 Février 2007 13:17, Derek Hohls a écrit : > Lionel > > I have encountered a problem with windrose. In some cases, one or more > of the > wind direction values are null [''] - the program then fails on line > 200: >values = select( [greater_equal( direction, wind_classes[i] > )],[speed], default=-1.e20 ) > Is it possible for you to upgrade the program to perform error > trapping > and simply skip (i.e. not process) any values that are null (and handle > the > exceptional case that all of them might, in fact, be null). > > Thanks! > Derek -- Lionel Roubeyrie - [EMAIL PROTECTED] LIMAIR http://www.limair.asso.fr - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Wrong colorbar-ticks in imshow-colorbar with 10 colors
Hi all, I want to use imshow to plot an array of floats using interpolation='nearest' so that every gridbox has a distinct color. Also I want to limit the number of colors to a rather small number, e.g. 10. The problem is that the tick labels are not at the edge of each color in the colorbar, but somewhere in between. An example is the trunk/matplotlib/examples/poormans_contour.py which does not work in my case. from pylab import * delta = 0.01 x = arange(-3.0, 3.0, delta) y = arange(-3.0, 3.0, delta) X,Y = meshgrid(x, y) Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = Z2 - Z1 # difference of Gaussians cmap = cm.get_cmap('jet', 10)# 10 discrete colors im = imshow(Z, cmap=cmap, interpolation='bilinear') axis('off') colorbar() #savefig('test') show() Is there a solution? Ciao Claas - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bug: Image transparency varies periodically for imshow(img, aspect='auto') at high magnification
Hi! I believe I've found a bug in matplotlib which manifests after imshow(img, aspect='auto') when only a small portion of the image is displayed, e.g: when (xmax-xmin) << img.shape[1]. The effect of the bug is that the transparency for the entire image seems to vary, seemingly as a periodic funtion of (xmax-xmin). Explicitly setting the alpha channel for each pixel has no effect. The attached script generates a random image of a certain size, and plots it in four different subplots. The only thing that differs between the subplots are slight variations in x_max. The four subplots are labeled: 1) The background image is visible. 2) The background image is not visible! 3) The background image is faded! 4) The background image is again visible! which reflects the actual result on my system. As the subplots are scaled (for example by resizing the window), the intensity then varies in a periodic manner in each of the subplots. The expected result is of course that the background should be fully visible in all subplots. Additional details: $ python test.py --verbose-helpful matplotlib data path /usr/lib/python2.4/site-packages/matplotlib/mpl-data $HOME=/home/bioinfo/yohell CONFIGDIR=/home/bioinfo/yohell/.matplotlib loaded rc file /usr/lib/python2.4/site-packages/matplotlib/mpl-data/matplotlibrc matplotlib version 0.87.7 verbose.level helpful interactive is False platform is linux2 numerix numpy 1.0 font search path ['/usr/lib/python2.4/site-packages/matplotlib/mpl-data'] loaded ttfcache file /home/bioinfo/yohell/.matplotlib/ttffont.cache backend WXAgg version 2.6.1.2pre In this example I used the WXAgg backend, but GTKAgg shows the same results. I've also reproduced this bug on a WinXP machine. Thanks for an excellent plotting package! /Joel Hedlund Linköping University import numpy, pylab image = numpy.random.randint(0, 255, 309 * 1230 * 3) image.shape = (309, 1230, 3) pylab.subplot(221) pylab.text(72.5, 200, 'The background image\nis visible.') pylab.imshow(image, aspect='auto') pylab.axis((72, 75, 0, 309)) pylab.subplot(222) pylab.imshow(image, aspect='auto') pylab.text(72.5, 200, 'The background image\nis not visible!') pylab.axis((72, 76, 0, 309)) pylab.subplot(223) pylab.imshow(image, aspect='auto') pylab.text(72.5, 200, 'The background image\nis faded!') pylab.axis((72, 77, 0, 309)) pylab.subplot(224) pylab.imshow(image, aspect='auto') pylab.text(72.5, 200, 'The background image\nis again visible!') pylab.axis((72, 78, 0, 309)) pylab.show() - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bug: Image transparency varies periodically for imshow(img, aspect='auto') at high magnification
Hi Joel, On Thursday 01 February 2007 11:09:11 am Joel Hedlund wrote: > I believe I've found a bug in matplotlib which manifests after > imshow(img, aspect='auto') when only a small portion of the image is > displayed, e.g: when (xmax-xmin) << img.shape[1]. The effect of the bug > is that the transparency for the entire image seems to vary, seemingly > as a periodic funtion of (xmax-xmin). Explicitly setting the alpha > channel for each pixel has no effect. > > The attached script generates a random image of a certain size, and > plots it in four different subplots. The only thing that differs between > the subplots are slight variations in x_max. The four subplots are labeled: > > 1) The background image is visible. > 2) The background image is not visible! > 3) The background image is faded! > 4) The background image is again visible! > > which reflects the actual result on my system. As the subplots are > scaled (for example by resizing the window), the intensity then varies > in a periodic manner in each of the subplots. > > The expected result is of course that the background should be fully > visible in all subplots. I can verify this behavior, more or less. I observe that the figure.dpi rc setting influences the results (I tried 86.23 and 200). - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] imshow(), set_data() and sequential update problem with two figures
Hi, I am having some difficulties understanding the following matplotlib behavior. The script below draws two plots and then updates each one with new data. The imshow() command is used to set the initial data. The data is then updated with the set_data() method of the return object from imshow(). The second plot works fine, however, the first plot does not update itself after the set_data() command and subsequent draw() command. I am baffled as to the reason for this and was wondering what the correct behavior should be. I am using matplotlib version '0.87.7', numpy version '1.0' and python version '2.4.2'. Cheers The script. import pylab, numpy pylab.ion() ## make figure 0, works fine fig0 = pylab.figure() pylab.title('data0') image0 = pylab.imshow(numpy.zeros((2,2), 'd')) pylab.colorbar() pylab.draw() raw_input('fig 0') ## make figure 1, works fine fig1 = pylab.figure() pylab.title('data1') image1 = pylab.imshow(numpy.zeros((2,2), 'd')) pylab.colorbar() pylab.draw() raw_input('fig 1') ## redraw figure 0 with new data, this figure does not update itself newdata = numpy.array(((0.,1.),(2.,3.))) pylab.figure(fig0.number) image0.set_data(newdata) pylab.clim(vmax=3, vmin=0) pylab.draw() raw_input('fig 0') ## redraw figure 1 with new data, works fine pylab.figure(fig1.number) image1.set_data(newdata) pylab.clim(vmax=3, vmin=0) pylab.draw() raw_input('fig 1') -- Daniel Wheeler - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bug: Image transparency varies periodically for imshow(img, aspect='auto') at high magnification
Darren Dale wrote: > Hi Joel, > > On Thursday 01 February 2007 11:09:11 am Joel Hedlund wrote: >> I believe I've found a bug in matplotlib which manifests after >> imshow(img, aspect='auto') when only a small portion of the image is >> displayed, e.g: when (xmax-xmin) << img.shape[1]. The effect of the bug >> is that the transparency for the entire image seems to vary, seemingly >> as a periodic funtion of (xmax-xmin). Explicitly setting the alpha >> channel for each pixel has no effect. >> >> The attached script generates a random image of a certain size, and >> plots it in four different subplots. The only thing that differs between >> the subplots are slight variations in x_max. The four subplots are labeled: >> >> 1) The background image is visible. >> 2) The background image is not visible! >> 3) The background image is faded! >> 4) The background image is again visible! >> >> which reflects the actual result on my system. As the subplots are >> scaled (for example by resizing the window), the intensity then varies >> in a periodic manner in each of the subplots. >> >> The expected result is of course that the background should be fully >> visible in all subplots. > > I can verify this behavior, more or less. I observe that the figure.dpi rc > setting influences the results (I tried 86.23 and 200). This sounds like the same bug that was noted a few months ago, in which repeated zooming to a very small part of the image ends up washing out the color entirely. I think that it was also connected with very slow rendering. Eric - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bug: Image transparency varies periodically for imshow(img, aspect='auto') at high magnification
> I think that it was also connected with very slow rendering. I second that. Rendering is very slow when this occurs. A workaround is to slice the image and just plot the visible pixels, and then to use the 'extent' keyword argument to position the slice on the axis, e.g: imagesc(img[a:b,ymin:ymax,:], extent=(a,b,ymin,ymax), aspect='auto') /Joel - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] freezing matplotlib
Le lundi 25 décembre 2006 16:00, Allan Noriel Estrella a écrit : > Has anyone tried freezing matplotlib embedded in a wx app (using py2ece, > cx_freeze or pyinstaller)? The setup.py in the FAQ seems to be outdated. I > want to freeze the embedding_in_wx.py in the examples. Do you have any > suggestions or cookbook steps that I can follow? it looks there were no answer to your question! I tried too the FAQ http://matplotlib.sourceforge.net/faq.html#PY2EXE and it does not work at least with my enthough installation directories seems to be very different from the one suggested. I also tried http://www.py2exe.org/index.cgi/MatPlotLib without success I tried the simpelst thing from pylab import * plot([1,2,3]) show() no chance! I don't know if someone could help, is there a better backend for freezing, maybe wxpython? Someone already succeded with a recent matplotlib ? I'm using 0.87.3 (on windows) - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Help needed: Rendering of multiple text labels is very slow.
Hi! I'm using matplotlib and pygtk to write a viewer for multiple sequence alignments. (Big matrices (~100x1000) of characters, usually colored by cell according to chemical properties). Now I've run into trouble since the rendering of the actual characters is very slow. I have included a small example that illustrates this. Set SHOW_LETTERS = False to see the change in rendering speed. The difference is even greater when using real data, so I would very much appreciate suggestions as to how I could improve it. My strategy: I create an image with the same dimension as the msa, and where each pixel is colored according to properties of the corresponding character in the msa. I plot this in the background of the figure using imshow(). At each redraw (refresh, resize, zoom...) I determine the size that each image pixel occupies at the current canvas size, and pick a font where one letter will fit inside this square. Then I put the corresponding msa letter into this square using text()/add_artist(). Would it be possible to use only one Text instance that would hold all letters, and somehow stretch that to the desired size? If so, could I expect better performance? Does anyone have a better idea? Thanks for an awesome plotting package! /Joel Hedlund # Change this to see change in rendering speed: SHOW_LETTERS = False import matplotlib matplotlib.use('GTKAgg') import pylab from numpy import array, uint8 RED = array([229, 51, 25], uint8) BLUE = array([25, 127, 229], uint8) GREEN = array([25, 204, 25], uint8) CYAN = array([25, 178, 178], uint8) PINK = array([229, 127, 127], uint8) MAGENTA = array([204, 76, 204], uint8) YELLOW = array([204, 204, 0], uint8) ORANGE = array([229, 153, 76], uint8) WHITE = array([255, 255, 255], uint8) colors = {'G': ORANGE, 'P': YELLOW, 'T': GREEN, 'S': GREEN, 'N': GREEN, 'Q': GREEN, 'W': BLUE, 'L': BLUE, 'V': BLUE, 'I': BLUE, 'M': BLUE, 'A': BLUE, 'F': BLUE, 'C': BLUE, 'H': CYAN, 'Y': CYAN, 'E': MAGENTA, 'D': MAGENTA, 'K': RED, 'R': RED} msa = """\ KYFALQ--- KYFALQPDDVYYCGIKYIKDDVILNEPSAD---APAALY--QTIEENIKIFVEFISVPVPE KYFALQPDDVYYCGIKYIKDDVLLNEPSAD---APAARY--QTIEENIKIFEEDEVEFISVPVPE KYFAFQPDDVYYCGIKYIKDDVVLNEPSAD---APASRY--QTIEENIKIFEEDEVEFISVPVPE KYFAFQQDDVYYCGIKYIKDDLILNEPSAN---APAARF--QTIEENIKILEEDNVEFISVPVPE KYFAMQ-RGVYFCGIRYLEDDAALTEPYAETPVRY--HSFRESIQILVELINVPVPE KYFAMQ-RGVYFCGIRYLEDDAALTEPYAETPVRY--HSFKESIQILEEEDVELINVPVPE KYFAMQ-RGVYFCGIRYLEDDAALTEPYAETPVRY--HSFKESIQILEEEDVELINVPVPE KYFAFQ-GGVYFCGIKYIEDGLSLPESGAE---AQSARY--HTIEQNIQILEEEDVEFISVPVPE KYFAFQQGGVYFCGIKYIEDGLSLPESGAQ---LKSARY--HTIEQNIQILEEEDVEFISVPVPE RYYVLERDQVFICGLKYYEEDYELNEEVDP-EIGAPLRLIEENVSFFEDDEVELISVPVPE HHYYNPEVSYQHHGGWED-EVELPNQFPLRQMEERIRVLEREQVELISVPVPE RYYFIEEERMYFCGVNYREENYKMQDSQEDTDMDLPAAY--KRIEEKVRVLEDEGVELINIPVPK """.splitlines(False) tmp = [] for s in msa: tmp.extend(colors.get(t, WHITE) for t in s) bg = array(tmp) bg.shape = (len(msa), len(msa[0]), 3) class CharSize(object): def __init__(self, width=None, height=None, fontprops=None): self.width = width self.height = height self.fontprops = fontprops def __lt__(self, other): if not isinstance(other, tuple): raise TypeError("can only be compared to (x, y) tuple") return (self.width < other[0] * 0.5) and (self.height < other[1] * 0.5) class FontSelector(object): def __init__(self, charsizes=None): if charsizes is None: charsizes = [] self.charsizes = charsizes @classmethod def from_sizes(cls, renderer, *fontsizes, **fontprops): if not fontsizes: raise TypeError("need a font size range") o = cls() for i in sorted(range(*fontsizes), reverse=True): fontprops['size'] = i oFontProps = matplotlib.font_manager.FontProperties(**fontprops) nWidth, nHeight = renderer.get_text_width_height('M', oFontProps, False) o.charsizes.append(CharSize(nWidth, nHeight, oFontProps)) return o def by_cell_size(self, width, height): tnAvailableSize = (width, height) for oCharSize in self.charsizes: if oCharSize < tnAvailableSize: return oCharSize.fontprops return None figure = pylab.figure() renderer = figure.canvas.get_renderer() font_selector = FontSelector.from_sizes(renderer, 4, 18, family='monospace') def replot(widget): pylab.cla() pylab.imshow(bg, origin='lower', interpolation='nearest', aspect='auto') pylab.ylim(len(msa), 0) iWidth, iHeight = figure.canvas.get_width_height() nCharWidth = iWidth / float(len(msa[0])) nCharHeight = iHeight / float(len(msa)) o
[Matplotlib-users] How to build mpl with MinGW for Python 2.4?
Hello, I'm trying to build matplotlib from SVN, with MinGW (current version), for Python 2.4 (the binary comes from ActiveState) under Windows XP. I've tried to follow instructions in setupext.py but I always get the same error when trying to import mpl: The procedure entry point _ctype could not be located in the dynamic link libary msvcr71.dll I'm using static dependencies from http://matplotlib.sourceforge.net/win32_static.tar.gz. Thanks for your help, Nicolas -- Garden - Conseil et analyse de données marketing Nicolas Grilly Tel +33 1 45 72 48 78 Mob +33 6 03 00 25 34 www.garden-paris.com - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users