Re: [Matplotlib-users] Analog of processing map() or protovis scale?
For convenience of use, I implemented three simple scales. I have not yet tested it rigorously, but the usage is similar to protovis scales. https://github.com/laserson/pytools/blob/master/scale.py Uri ... Uri Laserson Graduate Student, Biomedical Engineering Harvard-MIT Division of Health Sciences and Technology M +1 917 742 8019 laser...@mit.edu On Sun, Jan 16, 2011 at 21:23, Paul Ivanov wrote: > Uri Laserson, on 2011-01-16 17:41, wrote: > > Hi all, > > > > Does there already exist some python implementation (in MPL or other) of > an > > easy-to-use 1D scale transformation? This is something analogous to > > processing's map function or protovis's scale functionality. It would > work > > something like: > > > > s = linear().domain(5,100).range(13000,15000) > > > > or > > > > s = root(p=5).domain(0.1,0.6).range(0,1) > > > > There could be multiple versions, including linear, log, symlog, root > > (power), discrete, etc. > > Hi Uri, > > I think that the closest we have matplotlib is > matplotlib.colors.Normalize[1] and matplotlib.colors.LogNorm[2], but > both of these have a fixed range of the 0-1 (which is the reason > they are in colors). Both of these do end up with an inverse > method that you could leverage to get an arbitrary range, though. > > 1. > http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.Normalize > 2. > http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.LogNorm > > -- > Paul Ivanov > 314 address only used for lists, off-list direct email at: > http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.10 (GNU/Linux) > > iEYEARECAAYFAk0zqBAACgkQe+cmRQ8+KPcfSwCdGJp3J4uENsx11VMKAJdxkLEG > SEMAn1qqBYY8G6M1bcsfl7+7yc3doKiw > =x2vj > -END PGP SIGNATURE- > > > -- > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Font not carrying through Py2Exe
Thank you very much for the help, I'm sorry I didn't reply to you. I ended up doing what you recommend against, which is I took my fontlist.cache and copied it to the other computers C:\Documents and Settings\username\.matplotlib folder. This worked, maybe because all the computers here have the same font that for some reason didn't get included in the fontlist for everyone else. I know it's not perfect and that if I tried to get the program to work for anyone outside of work it would probably crash horribly, but it works now so I think I'll just leave it. Thank you very much Mike, you might not remember but you were the one that taught me how to get it into New Century Schoolbook in the first place. http://old.nabble.com/Changing-the-font-td28111472.html#a28118916 Here it is , for old times sake. Michael Droettboom-3 wrote: > > On 01/13/2011 11:38 AM, Alex S wrote: >> Hi there, >> I've made a program that makes plots using New Century Schoolbook Lt Std >> font. I did this by inserting this into the matplotlibrc file: >> >> font.family : New Century Schoolbook LT Std # serif #sans-serif >> >> There's also a "fontlist.cache" file that I think points to it when it >> says: >> >> . >> . >> . >> (dp283 >> g12 >> g45 >> sg14 >> S'New Century Schoolbook LT Std' >> p284 >> sg16 >> I400 >> sg17 >> g13 >> sg18 >> . >> . >> . >> >> This all works fine on my computer. But I'm trying to make it run on >> other >> people's computers (off a network drive) but when I do the plots all go >> back >> into Ariel font and all the spacing and stuff gets screwed up. Running >> the >> exact same exe from the same place, my computer continues to make them >> with >> the correct font. I have copied the matplotlibrc file and the >> fontlist.cache file from my hard drive (C:...Matplotlib) to the mpl-data >> folder in the dist folder (from py2exe) but that didn't work. >> >> Does anyone have any ideas for fixing this stuff? I think it might just >> be >> a matter of including the right files in the Py2Exe setup file but I >> don't >> know which ones. Or maybe changing how I select the font, which was a >> roundabout way of doing it from the start. > The fontList.cache file maps from the properties (names, weights, > slants) etc. of the fonts available on a particular system to their file > path. You should definitely not ship this file with the exe, but rather > allow it to be regenerated from scratch on each system, since the > selection and locations of fonts is very likely to be different. > > I think "New Century Schoolbook" is one of the fonts that ships with > Windows, so you can probably count on it being there. If not, you need > to ship the font as part of the exe by adding it to mpl-data/fonts/ttf > and then following the instructions to include the fonts given here: > > http://www.py2exe.org/index.cgi/MatPlotLib >>When I run the plots >> (successfully on my computer) it says this at one point: >> >> c:\Python26\lib\site-packages\matplotlib\backends\backend_pdf.py:982: >> UserWarning: 'newcenturyschlbkltstd-roman.otf' can not be subsetted into >> a >> Type 3 font. The entire font will be embedded in the output. >> >> Maybe that has somethign to do with what's going on? >> > I don't think that's related. All this means is that when it embeds the > font into the PDF file, it has to embed the entire thing rather than > only the characters that are being used. (Resulting in a larger PDF > file, but otherwise fine.) To avoid this message, you can set the > rcParam "pdf.fonttype" to 42. > > Cheers, > Mike >> >> >> Thanks a lot, >> Alex >> > > > -- > Michael Droettboom > Science Software Branch > Space Telescope Science Institute > Baltimore, Maryland, USA > > > -- > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/Font-not-carrying-through-Py2Exe-tp30663871p30676209.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users
[Matplotlib-users] ColorbarBase usage
Friends, I have created a figure (with two rows and two columns) and i drew four contourf plots (A,B,C,D etc). All the four contourf has the same coloring and bounds. I do not want to draw a colorbar() for each of the plots separately but only one colorbar at the bottom of the four plots.Something like the following scheme. plot1plot2 plot3plot4 colorbar I tried using mpl.colorbar.ColorbarBase as given in http://matplotlib.sourceforge.net/examples/api/colorbar_only.html example to draw the colorbar. However i find the colorbar that is created is overlapping over the plots. Kindly let me know what is the correct way of adjuting its location and size or any other way to create this colorbar. My code is attached with this mail. Thanks, Bala #!/usr/bin/env python import matplotlib.pyplot as plt import numpy as np import matplotlib as mpl # Creating input file list flist=open('lstcor').read().split() # Assignments FIG=plt.figure(dpi=300) FIG.subplots_adjust(hspace=0.20,wspace=0.15) NROW=2;NCOL=2 # two rows, two columns TXT=['A','B','C','D'] mpl.rcParams['font.size']=10 mpl.rcParams['lines.linewidth']=0.8 mpl.rcParams['axes.linewidth']=1.5 mpl.rcParams['legend.handletextpad']=0.01 mpl.rcParams['legend.fontsize']=10 mpl.rcParams['legend.labelspacing']=0.005 lev=[-1,-0.75,-.50,-0.25,0,0.25,0.5,0.75,1] col=['#ff','#696969','#a9a9a9','#d3d3d3','#ff','#2e8b57','#00','#ff'] # Loading all the matrices M1=np.loadtxt(flist[0]) M2=np.loadtxt(flist[1]) M3=np.loadtxt(flist[2]) M4=np.loadtxt(flist[3]) # Block 1 ax1=FIG.add_subplot(NROW,NCOL,1) CNF1=ax1.contourf(M1,levels=lev,colors=col,origin='lower') # Block 2 ax2=FIG.add_subplot(NROW,NCOL,2) CNF2=ax2.contourf(M2,levels=lev,colors=col,origin='lower') # Block 3 ax3=FIG.add_subplot(NROW,NCOL,3) CNF3=ax3.contourf(M3,levels=lev,colors=col,origin='lower') # Block 4 ax4=FIG.add_subplot(NROW,NCOL,4) CNF4=ax4.contourf(M4,levels=lev,colors=col,origin='lower') for index,name in enumerate(FIG.axes): name.set_xlim(auto=True) name.set_ylim(auto=True) name.set_xticks(range(0,342,50)) name.set_yticks(range(0,342,50)) name.axvspan(149,183,facecolor='#a9a9a9',alpha=0.2) name.axhspan(149,183,facecolor='#a9a9a9',alpha=0.2) name.text(5,350,TXT[index],fontsize=12) cmap=mpl.colors.ListedColormap(col) norm = mpl.colors.BoundaryNorm(lev,cmap.N) ax5=FIG.add_axes(([0.05, 0.65, 0.9, 0.15]) mpl.colorbar.ColorbarBase(ax5,cmap=cmap,norm=norm,spacing='proportional',ticks=[-1,-0.75,0.25,0.5,0.75,1.0]) -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ColorbarBase usage
Hi Bala, Bala subramanian, on 2011-01-17 16:42, wrote: > I have created a figure (with two rows and two columns) and i drew four > contourf plots (A,B,C,D etc). All the four contourf has the same coloring > and bounds. I do not want to draw a colorbar() for each of the plots > separately but only one colorbar at the bottom of the four plots.Something > like the following scheme. > > plot1plot2 > plot3plot4 > colorbar Here's one way of getting the type of plot you want. I just incremented NROW by one, and for the colorbar axes creation, changed it to be: ax5=FIG.add_subplot(NROW,1,NROW) which is a quick way to get the last row to span both columns. (I had to comment some things out to get the plot to run without needing the data). > I tried using mpl.colorbar.ColorbarBase as given in > http://matplotlib.sourceforge.net/examples/api/colorbar_only.html example to > draw the colorbar. However i find the colorbar that is created is > overlapping over the plots. Kindly let me know what is the correct way of > adjuting its location and size or any other way to create this colorbar. There, the axes are created to not overlap by hand tuning the rectangle parameters passed (left, bottom, width, top). You can get the same using the trick I used above, or get more sophisticated combinations using GridSpec [1], or if you want to get even fancier, with the AxesGrid toolkit [2] 1. http://matplotlib.sourceforge.net/users/gridspec.html 2. http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html#toolkit-axes best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ColorbarBase usage
On 01/17/2011 05:42 AM, Bala subramanian wrote: > Friends, > I have created a figure (with two rows and two columns) and i drew four > contourf plots (A,B,C,D etc). All the four contourf has the same > coloring and bounds. I do not want to draw a colorbar() for each of the > plots separately but only one colorbar at the bottom of the four > plots.Something like the following scheme. > > plot1plot2 > plot3plot4 >colorbar > > I tried using mpl.colorbar.ColorbarBase as given in > http://matplotlib.sourceforge.net/examples/api/colorbar_only.html > example to draw the colorbar. However i find the colorbar that is > created is overlapping over the plots. Kindly let me know what is the > correct way of adjuting its location and size or any other way to create > this colorbar. You should not ordinarily need to use ColorbarBase. For something like what you are describing, see http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html Eric > > My code is attached with this mail. > > Thanks, > Bala > > > > -- > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > > > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ColorbarBase usage
On Mon, Jan 17, 2011 at 11:35 AM, Eric Firing wrote: > On 01/17/2011 05:42 AM, Bala subramanian wrote: >> Friends, >> I have created a figure (with two rows and two columns) and i drew four >> contourf plots (A,B,C,D etc). All the four contourf has the same >> coloring and bounds. I do not want to draw a colorbar() for each of the >> plots separately but only one colorbar at the bottom of the four >> plots.Something like the following scheme. >> >> plot1 plot2 >> plot3 plot4 >> colorbar >> >> I tried using mpl.colorbar.ColorbarBase as given in >> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html >> example to draw the colorbar. However i find the colorbar that is >> created is overlapping over the plots. Kindly let me know what is the >> correct way of adjuting its location and size or any other way to create >> this colorbar. > > You should not ordinarily need to use ColorbarBase. For something like > what you are describing, see > > http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html Well, I learned something today. I had always been turning to ColorbarBase for cases like this. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Alpha not working from imshow?
I'm generating images that I want to use as overlays in Google Earth. Thus, I would like the masked portion of the numpy arrays I am using to appear as transparent. However, I seem to consistently get white instead of a transparent point. To clarify the issue, I wrote this short piece of code. I am setting both the figure background to transaprent and the masked value to transparent but I get white. I have pulled the current svn code and built matplotlib. I get the same issue. from numpy import ma import matplotlib.pyplot as plt from pylab import colorbar, imshow, show, cm def main(): a = ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]]) fig = plt.figure() fig.patch.set_alpha(0.0) cmap = cm.jet cmap.set_bad(alpha=0.0) imshow(a, interpolation='nearest', cmap=cmap) colorbar() show() Any thoughts? Tim B -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Alpha not working from imshow?
Tim Burgess, on 2011-01-18 13:32, wrote: > I'm generating images that I want to use as overlays in Google > Earth. Thus, I would like the masked portion of the numpy > arrays I am using to appear as transparent. However, I seem to > consistently get white instead of a transparent point. > > To clarify the issue, I wrote this short piece of code. I am > setting both the figure background to transaprent and the > masked value to transparent but I get white. > > I have pulled the current svn code and built matplotlib. I get > the same issue. > > from numpy import ma > import matplotlib.pyplot as plt > from pylab import colorbar, imshow, show, cm > > > def main(): > a = ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]]) > fig = plt.figure() > fig.patch.set_alpha(0.0) > cmap = cm.jet > cmap.set_bad(alpha=0.0) > imshow(a, interpolation='nearest', cmap=cmap) > colorbar() > show() Hi Tim, sorry to hear of your troubles - add these two lines to get your desired effect: ax = plt.gca() ax.patch.set_alpha(0.0) The figure has a patch associated with it, but so does each axes subplot, which is what you were seeing through the transparent portion of your masked array image. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Alpha not working from imshow?
Thanks, Paul! A bit of tweaking in my actual app but it now works beautifully! On 18/01/2011, at 4:08 PM, Paul Ivanov wrote: > Tim Burgess, on 2011-01-18 13:32, wrote: >> I'm generating images that I want to use as overlays in Google >> Earth. Thus, I would like the masked portion of the numpy >> arrays I am using to appear as transparent. However, I seem to >> consistently get white instead of a transparent point. >> >> To clarify the issue, I wrote this short piece of code. I am >> setting both the figure background to transaprent and the >> masked value to transparent but I get white. >> >> I have pulled the current svn code and built matplotlib. I get >> the same issue. >> >> from numpy import ma >> import matplotlib.pyplot as plt >> from pylab import colorbar, imshow, show, cm >> >> >> def main(): >> a = ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]]) >> fig = plt.figure() >> fig.patch.set_alpha(0.0) >> cmap = cm.jet >> cmap.set_bad(alpha=0.0) >> imshow(a, interpolation='nearest', cmap=cmap) >> colorbar() >> show() > > Hi Tim, > > sorry to hear of your troubles - add these two lines to get your > desired effect: > > ax = plt.gca() > ax.patch.set_alpha(0.0) > > The figure has a patch associated with it, but so does each axes > subplot, which is what you were seeing through the transparent > portion of your masked array image. > > best, > -- > Paul Ivanov > 314 address only used for lists, off-list direct email at: > http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 > -- > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users