[Matplotlib-users] How to plot heatmap with matplotlib?
Dear all, Heatmap (like those on the page http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/) is a frequently used type of image in microarray data analysis. However, it seems there are no convenient functions in matplotlib to plot heatmap (please correct me if I was wrong), so I'm planning to write my own. Let me take the heatmap by the link http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/scaled_color_key.png as an example, which is produced by R. With my limited knowledge and expertise of matplotlib, I have the following questions and I hope you guys could help me. 1) I tend to use pcolor to draw the colormap in the central area. However, I've seen a lot of examples draw colormap with imshow. What's the difference between pcolor and imshow? Shall I use pcolor or imshow to produce the heatmap in the link above? 2) How to draw the dendrograms on the top and left of the colormap? I got hints from http://matplotlib.sourceforge.net/examples/axes_grid/scatter_hist.html on how to append axes to current plot, but I still have now idea how to draw the dengrograms. 3) How to draw the column side colormap (the smaller one) between the top dendrogram and the big colormap? 4) I can use colorbar to draw a colorbar, but how to place the colorbar on the topleft of the image just as the R heatmap does? 5) Any other suggestions on how to draw the heatmap? Thanks and any help will be greatly appreciated. Regards, Jianfeng -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to plot heatmap with matplotlib?
Dear all, Heatmap (like those on the page http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/) is a frequently used type of image in microarray data analysis. However, it seems there are no convenient functions in matplotlib to plot heatmap (please correct me if I was wrong), so I'm planning to write my own. Let me take the heatmap by the link http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/scaled_color_key.png as an example, which is produced by R. With my limited knowledge and expertise of matplotlib, I have the following questions and I hope you guys could help me. 1) I tend to use pcolor to draw the colormap in the central area. However, I've seen a lot of examples draw colormap with imshow. What's the difference between pcolor and imshow? Shall I use pcolor or imshow to produce the heatmap in the link above? 2) How to draw the dendrograms on the top and left of the colormap? I got hints from http://matplotlib.sourceforge.net/examples/axes_grid/scatter_hist.html on how to append axes to current plot, but I still have now idea how to draw the dengrograms. 3) How to draw the column side colormap (the smaller one) between the top dendrogram and the big colormap? 4) I can use colorbar to draw a colorbar, but how to place the colorbar on the topleft of the image just as the R heatmap does? 5) Any other suggestions on how to draw the heatmap? Thanks and any help will be greatly appreciated. Regards, Jianfeng -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot heatmap with matplotlib?
On 2011-9-26 16:02, Angus McMorland wrote: On 25 September 2011 06:59, [email protected] wrote: Dear all, Heatmap (like those on the page http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/) is a frequently used type of image in microarray data analysis. However, it seems there are no convenient functions in matplotlib to plot heatmap (please correct me if I was wrong), so I'm planning to write my own. Let me take the heatmap by the link http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/scaled_color_key.png as an example, which is produced by R. With my limited knowledge and expertise of matplotlib, I have the following questions and I hope you guys could help me. 1) I tend to use pcolor to draw the colormap in the central area. However, I've seen a lot of examples draw colormap with imshow. What's the difference between pcolor and imshow? Shall I use pcolor or imshow to produce the heatmap in the link above? One difference between pcolor and imshow is that pcolor lines up the bottom-left corner of each square with the co-ordinates given, whereas imshow puts the grid center at those co-ordinates. My guess would be (not having implemented a heatmap) that pcolor would be the more useful to you to try first for this reason. 2) How to draw the dendrograms on the top and left of the colormap? I got hints from http://matplotlib.sourceforge.net/examples/axes_grid/scatter_hist.html on how to append axes to current plot, but I still have now idea how to draw the dengrograms. A quick google search suggests that scipy-cluster might help you out with the dendrogram drawing. I think I would try using separate axes objects for the heatmap and the dendrograms, and switch off the frames of the dendrogram axes. 3) How to draw the column side colormap (the smaller one) between the top dendrogram and the big colormap? This could another axes object too. You can use the sharex keyword to add_axes to get it to have the same x scale as the big axes. 4) I can use colorbar to draw a colorbar, but how to place the colorbar on the topleft of the image just as the R heatmap does? Again, the answer is to manually create the axes for your colorbar, and then specify those axes in the call to colorbar using the `cax` keyword. 5) Any other suggestions on how to draw the heatmap? I suggest that you give it a try and post your efforts here if there are any problems. We'll also be keen to see the final result, if you'd like to share it. I hope that helps at least a little. Happy coding, Angus Hi all, Thanks to Angus, and thanks to those guys who contributed to the internet. I wrote a prototype of a heatmap function with their help. Could some one help to review my code? Any comments will be greatly appreciated. I would like to continue to refine the code, and hope it can be of any help to the community someday. I still have some questions: 1) The number of rows and columns could vary significantly and the heatmap may look ugly if the parameters are not set right. How to set the appropriate positions of all axes and the spaces between those axes? And how to set up appropriate font size? 2) If there are too many rows or columns, it may not be efficient to draw the labels of each row or column one bye one with the text() function. Is there a better way to draw many text at once at different locations? Thanks a lot. Regards, Jianfeng # -*- coding: utf-8 -*- """ Created on Mon Sep 26 20:42:25 2011 http://stackoverflow.com/questions/5089030/how-do-i-create-a-radial-cluster-like-the-following-code-example-in-python colorbar: http://matplotlib.sourceforge.net/api/colorbar_api.html http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.colorbar http://matplotlib.sourceforge.net/examples/api/colorbar_only.html @author: Xiao Jianfeng """ import scipy import pylab import scipy.cluster.hierarchy as sch import scipy.spatial.distance as dist from matplotlib import mpl #def heatmap(x, colside_colors=None, rowside_colors=None): def heatmap(): """ x is a m by n ndarray, m observations, n genes """ x = scipy.rand(20, 30) #x = scipy.loadtxt("f:/learn/heatmap/tst.data") x = x*10 cmap=pylab.cm.YlGnBu norm = mpl.colors.Normalize(vmin=x.min(), vmax=x.max()) fig = pylab.figure(figsize=(8,8)) ## calculate positions for all elements # ax1, dendrogram 1, on the left of the heatmap [ax1_x, ax1_y, ax1_w, ax1_h] = [0.05,0.1,0.2,0.6] width_between_ax1_axr = 0.01 height_between_ax1_axc = 0.01 # axr, row side colorbar [axr_x, axr_y, axr_w, axr_h] = [0.31,0.1,0.02,0.6] axr_x = ax1_x + ax1_w + width_between_ax1_axr axr_y = ax1_y; axr_h = ax1_h width_between_axr_axm = 0.01 # axc, column side colorbar [axc_x, axc_y, axc_w, axc_h] =
[Matplotlib-users] a venn diagram function written in python
Dear all, I couldn't find a function to plot venn diagram with python, so I written one for my daily use (with a lot inspirations from the internet and R). Hope it could be of any help to someone else, so I put it on github. The path to it is https://github.com/icetime/pyinfor/blob/master/venn.py . I'm wondering if there is any chance that the function be included in matplotlib. I think matplotlib need a function for venn diagram. Also, could someone kindly help to review the code, so I can make it better? Any suggestions or comments will be greatly appreciated. Thanks a lot. Best Regards, Jianfeng -- Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] a venn diagram function written in python
Dear Ben Root, I have made a pull request of matplotlib on github, and I put my venn function on https://github.com/icetime/matplotlib/blob/master/lib/matplotlib/venn.py. However, I'm not sure it is the right place venn.py should go. This is my first time try to contribute to an open source project. Could someone please help review the code? Any comments will be greatly appreciated.Thanks. Regards, Jianfeng On 2012-2-23 9:22, Benjamin Root wrote: > No need to ask permission. Just make a pull request on github. It may > take some time, but we will get to evaluating your patch. A pull request is > your best bet. > > Ben Root > > On Wednesday, February 22, 2012, Mic wrote: > >> Dear Jianfeng, >> >> Probably, you have to join developer mailing list ( >> http://lists.sourceforge.net/mailman/listinfo/matplotlib-devel ) and ask >> there for permission to submit your code on githup. >> >> Cheers, >> >> >> >> On Tue, Feb 21, 2012 at 10:10 PM, [email protected]> 'cvml', '[email protected]');> > 'cvml', '[email protected]');> >>> wrote: >>> Dear Mic, >>> >>> Thanks for your reply. >>> >>> I have never submitted code to matplotlib, and I am not very much >>> familiar with github. However, I guess I don't have the right to submit >>> code to matplotlib. Could you please tell me what I need to do to get my >>> code reviewed by the matplotlib team and perhaps get into matplotlib after >>> the review? I use venn diagram quite often in my daily data analysis, and I >>> think such a function could be useful to others . Thanks a lot. >>> >>> Regards, >>> Jianfeng >>> >>> >>> >>> >>> >>> >>> On 2012-2-18 15:39, Mic wrote: >>> >>>> would be great! Maybe you could submit it to matplotlib's github. >>>> >>>> On Sat, Dec 31, 2011 at 2:23 AM, [email protected]>>> 'cvml', '[email protected]');> >>>> >>> '[email protected]');>>wrote: >>>> >> Dear all, >>>>> I couldn't find a function to plot venn diagram with python, so I >>>>> written one for my daily use (with a lot inspirations from the internet >>>>> and R). Hope it could be of any help to someone else, so I put it on >>>>> github. The path to it is >>>>> https://github.com/icetime/**pyinfor/blob/master/venn.py<https://github.com/icetime/pyinfor/blob/master/venn.py>. >>>>> >>>>> I'm wondering if there is any chance that the function be included in >>>>> matplotlib. I think matplotlib need a function for venn diagram. >>>>> >>>>> Also, could someone kindly help to review the code, so I can make it >>>>> better? >>>>> >>>>> Any suggestions or comments will be greatly appreciated. Thanks a lot. >>>>> >>>>> Best Regards, >>>>> Jianfeng >>>>> >>>>> >>>>> >>>>> --**--** >>>>> -- >>>>> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a >>>>> complex >>>>> infrastructure or vast IT resources to deliver seamless, secure access >>>>> to >>>>> virtual desktops. With this all-in-one solution, easily deploy virtual >>>>> desktops for less than the cost of PCs and save 60% on VDI >>>>> infrastructure >>>>> costs. Try it free! >>>>> http://p.sf.net/sfu/Citrix-**VDIinabox<http://p.sf.net/sfu/Citrix-VDIinabox> >>>>> __**_ >>>>> Matplotlib-users mailing list >>>>> Matplotlib-users@lists.**sourceforge.net>>>> '[email protected]');> >>>>> https://lists.sourceforge.net/**lists/listinfo/matplotlib-**users<https://lists.sourceforge.net/lists/listinfo/matplotlib-users> >>>> -- Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] a venn diagram function written in python
On 2012-2-26 4:02, Benjamin Root wrote: > On Friday, February 24, 2012, [email protected] wrote: > >> Dear Ben Root, >> >> I have made a pull request of matplotlib on github, and I put my venn >> function on https://github.com/icetime/**matplotlib/blob/master/lib/** >> matplotlib/venn.py<https://github.com/icetime/matplotlib/blob/master/lib/matplotlib/venn.py>. >> However, I'm not sure it is the right place venn.py should go. >> >> This is my first time try to contribute to an open source project. Could >> someone please help review the code? Any comments will be greatly >> appreciated.Thanks. >> >> Regards, >> Jianfeng >> >> >> > Jianfeng, > > A common mistake new contributors make is that they make a pull request > against their own mpl fork rather than the official one. We have not > received your request yet. You might want to try again. > > Git is confusing at first, but once you try it out a bit more, it becomes > much easier to use. > > Ben Root > Dear Ben Root, Thanks for letting me know. I tried again, and finally made a pull request. Please let me know if it works this time. Thanks. If there is something I can do to improve the code, please just let me know, and I will be happy to do it. Regards, Jianfeng -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
