[Matplotlib-users] Adjusting sub plot sizes
Hi, I have generated a heat map along side a tree with gridspec. The issue is that I want the tree with smaller dimensions and heat map should be in a square dimension, adjusting height ratios and width ration only helps reduce tree and the heat map dimensions increase. Here is my code: gs=gridspec.GridSpec(1, 2,height_ratios=[1,1,-2,2] ,width_ratios=[0.5,1,-2,2],hspace=0,wspace=0) phyl_ax=plt.subplot(gs[0,0]) Phylo.draw(tree, axes=phyl_ax, do_show=False,show_confidence=False) ht_ax=plt.subplot(gs[0,1]) Hence I decided to use add_subplots instead: from mpl_toolkits.axes_grid1 import make_axes_locatable,Size from Bio import Phylo fig= plt.figure() phyl_ax=fig.add_subplot(1,2,1) ht_ax=fig.add_subplot(1,2,2) fig.subplots_adjust(hspace=0,wspace=0) divider1 = make_axes_locatable(phyl_ax) divider1.get_horizontal()[0] = Size.Fixed(5.0) # 10 inch divider1.get_vertical()[0] = Size.Fixed(10.0) # 4 inch Phylo.draw(tree, axes=phyl_ax, do_show=False,show_confidence=False) divider2 = make_axes_locatable(ht_ax) divider2.get_horizontal()[0] = Size.Fixed(10.0) # 5 inch divider2.get_vertical()[0] = Size.Fixed(10.0) # 5 inch divider = make_axes_locatable(ht_ax) cbax = divider.append_axes("right", size="5%", pad=0.10) Note:The width of the subplots is what I am trying to make different and height should be the same. With the above code the tree subplot is appearing in the background and heat map on top of it, rather than adjacent. Could anyone help me out with this? Thanks Asma -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap: draw parallels/meridians based on rotated pole
Hi Maik, Not entirely sure what you're after (a picture may have helped), but I know Basemap has relatively recently added rotated pole coordinate system support which may be of use. I'm not sure how well that goes with the meridian/parallel drawing within Basemap though. Alternatively, if I've understood you correctly, I've put together an example using cartopy which first produces a map in "Geomagnetic" space (with traditional latitude and longitude meridians/parallels) and then by drawing a north polar stereographic map first with the geomagnetic latitudes and longitudes (for 2010) next to the WGS84 latitudes and longitudes. Notebook can be found http://nbviewer.ipython.org/gist/pelson/7b461a798e454533d4ef The key is that you can make a map of any projection, and later add data from any source coordinate system (transform) and they should play nicely in Cartopy. Is this the kind of thing you're after? Cheers, Phil On 12 May 2014 13:18, Maik Riechert wrote: > Hi, > > I'm drawing a stereographic map, my data is in geographic latitude, > longitude coordinates. But instead of drawing parallels/meridians based > on the geographic poles I need to draw them based on the geomagnetic > poles, that is, the poles are rotated. E.g. in 2010 the north > geomagnetic pole was at 80.08°N 72.21°W > (https://en.wikipedia.org/wiki/Geomagnetic_pole). In my case it's for > aurora research, and many existing maps are drawn in this way, so > naturally it becomes easier to compare them if they are based on the > same coordinate system. > > Is this somehow achievable with basemap? Note that I'd like to draw > country borders etc. as well. (Otherwise I could just transform my > geographic coordinates to magnetic coordinates and use standard basemap.) > > Thanks > Maik > > > -- > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. > Get unparalleled scalability from the best Selenium testing platform > available > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Re-combine different axes to make new figure in matplotlib
I usually get around this by writing my plotting routines as functions that take Axes objects as input. That way, they don't need to know about the layout of the figure, and I can use the same code for figures with one or more axes. I am working on a project involving a sample of galaxies, and sometimes I need a plot parameter A for one of the galaxies only, in a figure together with plots of parameters B and C for the same galaxy. Other times, I need a figure with plots of parameter A only, but with an Axes for each galaxy in the sample. This approach allows me to use the same code for both cases. /Emil On 2014-05-12 17:06, Yuxiang Wang wrote: > Hi Eric, > > Thank you for your very clear explanation. > > -Shawn > > On Mon, May 12, 2014 at 3:23 AM, Eric Firing wrote: >> On 2014/05/11 7:56 PM, Yuxiang Wang wrote: >>> Dear all, >>> >>> I am curious that whether this is possible in matplotlib: >>> >>> I first create some figures, with subplots. >>> >>> import matplotlib.pyplot as plt >>> fig1, axs1 = plt.subplots(2, 2) >>> fig2, axs2 = plt.subplots(2, 2) >>> >>> And then, could I recombine them, so fig3 is composed of the first row >>> in fig1 (i.e., axs1[0, 0] and axs1[0, 1]) and second row in fig2 >>> (i.e., axs2[1, 0] and axs2[1, 1])? >>> >>> Currently, all I could do is to re-plot them. I am curious about >>> whether there is a way that I can just move axes around and re-combine >>> them to make new figures. Thanks! >> No, there is no facility for doing this. The Axes class is always >> initialized with a Figure instance. The Axes and Figure are quite >> tightly tied together via transforms. >> >> Eric >> >>> -Shawn >>> >>> >> >> -- >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. >> Get unparalleled scalability from the best Selenium testing platform >> available >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Re-combine different axes to make new figure in matplotlib
Hi Eric, Thank you for your very clear explanation. -Shawn On Mon, May 12, 2014 at 3:23 AM, Eric Firing wrote: > On 2014/05/11 7:56 PM, Yuxiang Wang wrote: >> Dear all, >> >> I am curious that whether this is possible in matplotlib: >> >> I first create some figures, with subplots. >> >> import matplotlib.pyplot as plt >> fig1, axs1 = plt.subplots(2, 2) >> fig2, axs2 = plt.subplots(2, 2) >> >> And then, could I recombine them, so fig3 is composed of the first row >> in fig1 (i.e., axs1[0, 0] and axs1[0, 1]) and second row in fig2 >> (i.e., axs2[1, 0] and axs2[1, 1])? >> >> Currently, all I could do is to re-plot them. I am curious about >> whether there is a way that I can just move axes around and re-combine >> them to make new figures. Thanks! > > No, there is no facility for doing this. The Axes class is always > initialized with a Figure instance. The Axes and Figure are quite > tightly tied together via transforms. > > Eric > >> >> -Shawn >> >> > > > -- > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. > Get unparalleled scalability from the best Selenium testing platform available > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Yuxiang "Shawn" Wang Gerling Research Lab University of Virginia yw...@virginia.edu +1 (434) 284-0836 https://sites.google.com/a/virginia.edu/yw5aj/ -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Basemap: draw parallels/meridians based on rotated pole
Hi, I'm drawing a stereographic map, my data is in geographic latitude, longitude coordinates. But instead of drawing parallels/meridians based on the geographic poles I need to draw them based on the geomagnetic poles, that is, the poles are rotated. E.g. in 2010 the north geomagnetic pole was at 80.08°N 72.21°W (https://en.wikipedia.org/wiki/Geomagnetic_pole). In my case it's for aurora research, and many existing maps are drawn in this way, so naturally it becomes easier to compare them if they are based on the same coordinate system. Is this somehow achievable with basemap? Note that I'd like to draw country borders etc. as well. (Otherwise I could just transform my geographic coordinates to magnetic coordinates and use standard basemap.) Thanks Maik -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Re-combine different axes to make new figure in matplotlib
On 2014/05/11 7:56 PM, Yuxiang Wang wrote: > Dear all, > > I am curious that whether this is possible in matplotlib: > > I first create some figures, with subplots. > > import matplotlib.pyplot as plt > fig1, axs1 = plt.subplots(2, 2) > fig2, axs2 = plt.subplots(2, 2) > > And then, could I recombine them, so fig3 is composed of the first row > in fig1 (i.e., axs1[0, 0] and axs1[0, 1]) and second row in fig2 > (i.e., axs2[1, 0] and axs2[1, 1])? > > Currently, all I could do is to re-plot them. I am curious about > whether there is a way that I can just move axes around and re-combine > them to make new figures. Thanks! No, there is no facility for doing this. The Axes class is always initialized with a Figure instance. The Axes and Figure are quite tightly tied together via transforms. Eric > > -Shawn > > -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users