## [Matplotlib-users] Subplots, multiple bar3d plots + titling

 [Matplotlib-users] Subplots, multiple bar3d plots + titling From: - 2009-09-28 22:23:14 ```Greetings, I would like to plot to make a figure with 3 subplots of the form (221) to (223): - each subplot should show a bar3d plot of a matrix - each subplot should have it's own title The problems: a) I don't see (nor did i find something) how i can use subplots combined with bar3d (from the mpl_toolkits.mplot3d) package. b) I don't manage to give the 3d bar plot a title. In the attached code you will see that a title is set, but it does not show up in the figure Could someone please help me out with these problems? Thanks, q --------------------- The code for the basic plot of the matrix: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator from numpy import * psi=1/sqrt(2)*array([1, 0, 0, 1]) rho=outer(psi,psi) fig = plt.figure() ax = Axes3D(fig) elements = (len(rho) * len(rho)) xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) xpos = xpos.flatten() ypos = ypos.flatten() zpos = zeros(elements) dx = 0.5 * ones_like(zpos) dy = dx.copy() dz = absolute(rho.flatten()) ax.set_title('absolute') ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') plt.show() ```

 [Matplotlib-users] Subplots, multiple bar3d plots + titling From: - 2009-09-28 22:23:14 ```Greetings, I would like to plot to make a figure with 3 subplots of the form (221) to (223): - each subplot should show a bar3d plot of a matrix - each subplot should have it's own title The problems: a) I don't see (nor did i find something) how i can use subplots combined with bar3d (from the mpl_toolkits.mplot3d) package. b) I don't manage to give the 3d bar plot a title. In the attached code you will see that a title is set, but it does not show up in the figure Could someone please help me out with these problems? Thanks, q --------------------- The code for the basic plot of the matrix: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator from numpy import * psi=1/sqrt(2)*array([1, 0, 0, 1]) rho=outer(psi,psi) fig = plt.figure() ax = Axes3D(fig) elements = (len(rho) * len(rho)) xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) xpos = xpos.flatten() ypos = ypos.flatten() zpos = zeros(elements) dx = 0.5 * ones_like(zpos) dy = dx.copy() dz = absolute(rho.flatten()) ax.set_title('absolute') ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') plt.show() ```
 Re: [Matplotlib-users] Subplots, multiple bar3d plots + titling From: Nicolas Bigaouette - 2009-09-29 02:11:10 Attachments: Message as HTML ```I'm not sure its possible right now to do subplots with 3D. As for the title, I cannot either put titles on any 3D graphs... 2009/9/28 > Greetings, > > I would like to plot to make a figure with 3 subplots > of the form (221) to (223): > - each subplot should show a bar3d plot of a matrix > - each subplot should have it's own title > > The problems: > a) I don't see (nor did i find something) how i can > use subplots combined with bar3d (from the mpl_toolkits.mplot3d) > package. > > b) I don't manage to give the 3d bar plot a title. In the attached > code you will see that a title is set, but it does not show > up in the figure > > Could someone please help me out with these problems? > > Thanks, > q > > --------------------- > > The code for the basic plot of the matrix: > > > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator > from numpy import * > > psi=1/sqrt(2)*array([1, 0, 0, 1]) > rho=outer(psi,psi) > > fig = plt.figure() > > ax = Axes3D(fig) > > elements = (len(rho) * len(rho)) > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, > array(range(len(rho)))+0.25) > > xpos = xpos.flatten() > ypos = ypos.flatten() > zpos = zeros(elements) > > dx = 0.5 * ones_like(zpos) > dy = dx.copy() > dz = absolute(rho.flatten()) > > ax.set_title('absolute') > > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') > > plt.show() > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```
 Re: [Matplotlib-users] Subplots, multiple bar3d plots + titling From: Jae-Joon Lee - 2009-09-29 03:52:42 ```Try below instead of Axes3D. Obviously, "131" is the geometry parameter for subplot command. You don't need to add "ax" to "fig" since Axes3D do that by itself. from matplotlib.axes import subplot_class_factory Subplot3D = subplot_class_factory(Axes3D) ax = Subplot3D(fig, 131) This will show you the title also. However, the 3d axes will occupy smaller area than the area of the subplot. Regards, -JJ On Mon, Sep 28, 2009 at 6:23 PM, wrote: > Greetings, > > I would like to plot to make a figure with 3 subplots > of the form (221) to (223): >  - each subplot should show a bar3d plot of a matrix >  - each subplot should have it's own title > > The problems: >  a) I don't see (nor did i find something) how i can >    use subplots combined with bar3d (from the mpl_toolkits.mplot3d) >    package. > >  b) I don't manage to give the 3d bar plot a title. In the attached >    code you will see that a title is set, but it does not show >    up in the figure > > Could someone please help me out with these problems? > > Thanks, > q > > --------------------- > > The code for the basic plot of the matrix: > > > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator > from numpy import * > > psi=1/sqrt(2)*array([1, 0, 0, 1]) > rho=outer(psi,psi) > > fig = plt.figure() > > ax = Axes3D(fig) > > elements = (len(rho) * len(rho)) > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) > > xpos = xpos.flatten() > ypos = ypos.flatten() > zpos = zeros(elements) > > dx = 0.5 * ones_like(zpos) > dy = dx.copy() > dz = absolute(rho.flatten()) > > ax.set_title('absolute') > > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') > > plt.show() > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```
 Re: [Matplotlib-users] Subplots, multiple bar3d plots + titling From: - 2009-09-29 10:22:37 ```Thanks, that works like a charm. final bonus question: How can i individually set the point of view/zoom level for the different 3d subplots? Currently, when i rotate/zoom (with the mouse) in one subplot, the changes are applied on all 3d subplots. Thanks again, q On Mon, Sep 28, 2009 at 11:52:08PM -0400, Jae-Joon Lee wrote: > Try below instead of Axes3D. Obviously, "131" is the geometry > parameter for subplot command. You don't need to add "ax" to "fig" > since Axes3D do that by itself. > > from matplotlib.axes import subplot_class_factory > Subplot3D = subplot_class_factory(Axes3D) > > ax = Subplot3D(fig, 131) > > This will show you the title also. However, the 3d axes will occupy > smaller area than the area of the subplot. > > Regards, > > -JJ > > > On Mon, Sep 28, 2009 at 6:23 PM, wrote: > > Greetings, > > > > I would like to plot to make a figure with 3 subplots > > of the form (221) to (223): > >  - each subplot should show a bar3d plot of a matrix > >  - each subplot should have it's own title > > > > The problems: > >  a) I don't see (nor did i find something) how i can > >    use subplots combined with bar3d (from the mpl_toolkits.mplot3d) > >    package. > > > >  b) I don't manage to give the 3d bar plot a title. In the attached > >    code you will see that a title is set, but it does not show > >    up in the figure > > > > Could someone please help me out with these problems? > > > > Thanks, > > q > > > > --------------------- > > > > The code for the basic plot of the matrix: > > > > > > from mpl_toolkits.mplot3d import Axes3D > > import matplotlib.pyplot as plt > > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator > > from numpy import * > > > > psi=1/sqrt(2)*array([1, 0, 0, 1]) > > rho=outer(psi,psi) > > > > fig = plt.figure() > > > > ax = Axes3D(fig) > > > > elements = (len(rho) * len(rho)) > > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) > > > > xpos = xpos.flatten() > > ypos = ypos.flatten() > > zpos = zeros(elements) > > > > dx = 0.5 * ones_like(zpos) > > dy = dx.copy() > > dz = absolute(rho.flatten()) > > > > ax.set_title('absolute') > > > > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') > > > > plt.show() > > > > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry® Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9-12, 2009. Register now! > > http://p.sf.net/sfu/devconf > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users@... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- The king who needs to remind his people of his rank, is no king. To gain that which is worth having, it may be necessary to lose everything else. ```
 Re: [Matplotlib-users] Subplots, multiple bar3d plots + titling From: Jae-Joon Lee - 2009-09-29 15:06:18 ```Hmm, axes3d does not seem to support it currently. I hope Reinier or others confirm this. Anyhow, here is a quick workaround you may try. from matplotlib.axes import subplot_class_factory class MyAxes3D(Axes3D): def _button_press(self, event): if event.inaxes == self: Axes3D._button_press(self, event) Subplot3D = subplot_class_factory(MyAxes3D) This makes rotate/zoom is effective only in the axes where the initial button-press event occurred. While I think it is reasonable to have Subplot3D and above fix in place, I'll defer this to Reinier or others who better know how Axes3D works. Regards, -JJ On Tue, Sep 29, 2009 at 6:22 AM, wrote: > Thanks, > > that works like a charm. > > final bonus question: How can i individually set the point of view/zoom level > for the different 3d subplots? > > Currently, when i rotate/zoom (with the mouse) in one subplot, the changes > are applied on all 3d subplots. > > Thanks again, > q > > On Mon, Sep 28, 2009 at 11:52:08PM -0400, Jae-Joon Lee wrote: >> Try below instead of Axes3D. Obviously, "131" is the geometry >> parameter for subplot command. You don't need to add  "ax" to "fig" >> since Axes3D do that by itself. >> >> from matplotlib.axes import subplot_class_factory >> Subplot3D = subplot_class_factory(Axes3D) >> >> ax = Subplot3D(fig, 131) >> >> This will show you the title also. However, the 3d axes will occupy >> smaller area than the area of the subplot. >> >> Regards, >> >> -JJ >> >> >> On Mon, Sep 28, 2009 at 6:23 PM,   wrote: >> > Greetings, >> > >> > I would like to plot to make a figure with 3 subplots >> > of the form (221) to (223): >> >  - each subplot should show a bar3d plot of a matrix >> >  - each subplot should have it's own title >> > >> > The problems: >> >  a) I don't see (nor did i find something) how i can >> >    use subplots combined with bar3d (from the mpl_toolkits.mplot3d) >> >    package. >> > >> >  b) I don't manage to give the 3d bar plot a title. In the attached >> >    code you will see that a title is set, but it does not show >> >    up in the figure >> > >> > Could someone please help me out with these problems? >> > >> > Thanks, >> > q >> > >> > --------------------- >> > >> > The code for the basic plot of the matrix: >> > >> > >> > from mpl_toolkits.mplot3d import Axes3D >> > import matplotlib.pyplot as plt >> > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator >> > from numpy import * >> > >> > psi=1/sqrt(2)*array([1, 0, 0, 1]) >> > rho=outer(psi,psi) >> > >> > fig = plt.figure() >> > >> > ax = Axes3D(fig) >> > >> > elements = (len(rho) * len(rho)) >> > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) >> > >> > xpos = xpos.flatten() >> > ypos = ypos.flatten() >> > zpos = zeros(elements) >> > >> > dx = 0.5 * ones_like(zpos) >> > dy = dx.copy() >> > dz = absolute(rho.flatten()) >> > >> > ax.set_title('absolute') >> > >> > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') >> > >> > plt.show() >> > >> > >> > >> > ------------------------------------------------------------------------------ >> > Come build with us! The BlackBerry® Developer Conference in SF, CA >> > is the only developer event you need to attend this year. Jumpstart your >> > developing skills, take BlackBerry mobile applications to market and stay >> > ahead of the curve. Join us from November 9-12, 2009. Register now! >> > http://p.sf.net/sfu/devconf >> > _______________________________________________ >> > Matplotlib-users mailing list >> > Matplotlib-users@... >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > -- > The king who needs to remind his people of his rank, is no king. > > To gain that which is worth having, it may be necessary to lose everything else. > ```
 Re: [Matplotlib-users] Subplots, multiple bar3d plots + titling From: Reinier Heeres - 2009-09-30 08:32:06 ```Hi, I will have a look at mplot3d sub-plots next weekend and try to fix issues like this. I'll also add a working example. Cheers, Reinier On Tue, Sep 29, 2009 at 5:05 PM, Jae-Joon Lee wrote: > Hmm, axes3d does not seem to support it currently. I hope Reinier or > others confirm this. > Anyhow, here is a quick workaround you may try. > > > from matplotlib.axes import subplot_class_factory > > class MyAxes3D(Axes3D): >    def _button_press(self, event): >        if event.inaxes == self: >            Axes3D._button_press(self, event) > > > Subplot3D = subplot_class_factory(MyAxes3D) > > This makes rotate/zoom is effective only in the axes where the initial > button-press event occurred. > > While I think it is reasonable to have Subplot3D and above fix in > place, I'll defer this to Reinier or others who better know how Axes3D > works. > > Regards, > > -JJ > > > On Tue, Sep 29, 2009 at 6:22 AM,   wrote: >> Thanks, >> >> that works like a charm. >> >> final bonus question: How can i individually set the point of view/zoom level >> for the different 3d subplots? >> >> Currently, when i rotate/zoom (with the mouse) in one subplot, the changes >> are applied on all 3d subplots. >> >> Thanks again, >> q >> >> On Mon, Sep 28, 2009 at 11:52:08PM -0400, Jae-Joon Lee wrote: >>> Try below instead of Axes3D. Obviously, "131" is the geometry >>> parameter for subplot command. You don't need to add  "ax" to "fig" >>> since Axes3D do that by itself. >>> >>> from matplotlib.axes import subplot_class_factory >>> Subplot3D = subplot_class_factory(Axes3D) >>> >>> ax = Subplot3D(fig, 131) >>> >>> This will show you the title also. However, the 3d axes will occupy >>> smaller area than the area of the subplot. >>> >>> Regards, >>> >>> -JJ >>> >>> >>> On Mon, Sep 28, 2009 at 6:23 PM,   wrote: >>> > Greetings, >>> > >>> > I would like to plot to make a figure with 3 subplots >>> > of the form (221) to (223): >>> >  - each subplot should show a bar3d plot of a matrix >>> >  - each subplot should have it's own title >>> > >>> > The problems: >>> >  a) I don't see (nor did i find something) how i can >>> >    use subplots combined with bar3d (from the mpl_toolkits.mplot3d) >>> >    package. >>> > >>> >  b) I don't manage to give the 3d bar plot a title. In the attached >>> >    code you will see that a title is set, but it does not show >>> >    up in the figure >>> > >>> > Could someone please help me out with these problems? >>> > >>> > Thanks, >>> > q >>> > >>> > --------------------- >>> > >>> > The code for the basic plot of the matrix: >>> > >>> > >>> > from mpl_toolkits.mplot3d import Axes3D >>> > import matplotlib.pyplot as plt >>> > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator >>> > from numpy import * >>> > >>> > psi=1/sqrt(2)*array([1, 0, 0, 1]) >>> > rho=outer(psi,psi) >>> > >>> > fig = plt.figure() >>> > >>> > ax = Axes3D(fig) >>> > >>> > elements = (len(rho) * len(rho)) >>> > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25) >>> > >>> > xpos = xpos.flatten() >>> > ypos = ypos.flatten() >>> > zpos = zeros(elements) >>> > >>> > dx = 0.5 * ones_like(zpos) >>> > dy = dx.copy() >>> > dz = absolute(rho.flatten()) >>> > >>> > ax.set_title('absolute') >>> > >>> > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800') >>> > >>> > plt.show() >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ >>> > Come build with us! The BlackBerry® Developer Conference in SF, CA >>> > is the only developer event you need to attend this year. Jumpstart your >>> > developing skills, take BlackBerry mobile applications to market and stay >>> > ahead of the curve. Join us from November 9-12, 2009. Register now! >>> > http://p.sf.net/sfu/devconf >>> > _______________________________________________ >>> > Matplotlib-users mailing list >>> > Matplotlib-users@... >>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> > >> >> -- >> The king who needs to remind his people of his rank, is no king. >> >> To gain that which is worth having, it may be necessary to lose everything else. >> > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Reinier Heeres Tel: +31 6 10852639 ```