[mplot3d] change axis background color

This is set in axis3d module (class Axis), by _AXINFO.
So far, I haven't found a way to modify colors/transparency but to edit
the latter file. Is this hard-coded or is there a way to modify this a
posteriori ?

Cheers,

    Denis

···

Le 02-06-2010, Benjamin Root <ben.root@...1304...> a écrit :

Huh, how about that? I never noticed that before. I wonder if that
is a bug or if it is intentional?

Ben Root

On Tue, Jun 1, 2010 at 5:28 PM, Denis Laxalde > <dlaxalde@...287...> wrote:

Hi Ben,

Thanks for your answer. Actually, options for savefig seem to only
operate on 2D axes whereas I'm trying to change the color of 3D axes
(x,y,z) which, by default, have a grid with a gray background. I
manage to remove the grid lines but not the background color. (My
initial question was not very clear perhaps...)

   Denis

Le mardi 01 juin 2010 =E0 16:57 -0500, Benjamin Root a =E9crit :
> Denis,
>
> There are probably other ways, but the one that I know off the top
> of m=

y

> head is done at the savefig() function. If you want to remove the
> background entirely, you can specify the keyword argument
transparent=3DTrue.
> You can change the color using the facecolor keyword argument. You
> can specify any color in that argument like you would elsewhere in
matplotlib.
>
> Ben Root
>
> On Tue, Jun 1, 2010 at 4:42 PM, Denis Laxalde >> > <dlaxalde@...287...> >> wrote:
>
> > Hi,
> >
> > Is there a way to change (and maybe remove) the background color
> > (gra=

y

> > by default) of axis in mplot3d graphics ?
> >
> > Thanks,
> >
> > Denis
> >

You can simply modify that dictionary.
To have different colors for different axes, define _AXINFO in the
instance level as below.

from mpl_toolkits.mplot3d import axes3d, axis3d
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = axes3d.Axes3D(fig)

myAXINFO = {
    'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2),
          'color': (0.55, 0.95, 0.95, 0.5, 0.2)},
    'y': {'i': 1, 'tickdir': 0, 'juggled': (0, 1, 2),
          'color': (0.50, 0.90, 0.90, 0.5, 0.8)},
    'z': {'i': 2, 'tickdir': 0, 'juggled': (0, 2, 1),
          'color': (0.525, 0.925, 0.925, 0.5, 0.5)},
    }

ax.w_xaxis._AXINFO = myAXINFO
ax.w_yaxis._AXINFO = myAXINFO
ax.w_zaxis._AXINFO = myAXINFO

# to change the global behavior
# axis3d.Axis._AXINFO.update(myAXINFO)

plt.show()

···

On Wed, Jun 2, 2010 at 10:42 AM, Denis Laxalde <dlaxalde@...287...> wrote:

This is set in axis3d module (class Axis), by _AXINFO.
So far, I haven't found a way to modify colors/transparency but to edit
the latter file. Is this hard-coded or is there a way to modify this a
posteriori ?

Cheers,

Denis

This is set in axis3d module (class Axis), by _AXINFO.
So far, I haven't found a way to modify colors/transparency but to edit
the latter file. Is this hard-coded or is there a way to modify this a
posteriori ?

Cheers,

    Denis

You can simply modify that dictionary.

...with the caution that you are modifying a private implementation-dependent variable, so your code is more likely to break with future versions of mplot3d, and with no deprecation or other warning, than if you could stick to methods and attributes without the leading underscore.

Eric

···

On 06/02/2010 05:53 AM, Jae-Joon Lee wrote:

On Wed, Jun 2, 2010 at 10:42 AM, Denis Laxalde<dlaxalde@...287...> wrote:

To have different colors for different axes, define _AXINFO in the
instance level as below.

from mpl_toolkits.mplot3d import axes3d, axis3d
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = axes3d.Axes3D(fig)

myAXINFO = {
     'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2),
           'color': (0.55, 0.95, 0.95, 0.5, 0.2)},
     'y': {'i': 1, 'tickdir': 0, 'juggled': (0, 1, 2),
           'color': (0.50, 0.90, 0.90, 0.5, 0.8)},
     'z': {'i': 2, 'tickdir': 0, 'juggled': (0, 2, 1),
           'color': (0.525, 0.925, 0.925, 0.5, 0.5)},
     }

ax.w_xaxis._AXINFO = myAXINFO
ax.w_yaxis._AXINFO = myAXINFO
ax.w_zaxis._AXINFO = myAXINFO

# to change the global behavior
# axis3d.Axis._AXINFO.update(myAXINFO)

plt.show()

------------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users