Matplotlib-users Digest, Vol 62, Issue 3

Hello, Angus!

For this method, if I want to draw a colorbar to indicate the specific values
for the colors, what should I do? the colorbar() in pylab is not waorking for
this case.

  Thanks,
Wang Jun

于 2011/7/3 8:48, matplotlib-users-request@lists.sourceforge.net 写道:

···

On 1 July 2011 14:35, Francois Lemery<francois.lemery@...287...> wrote:

> Hello,
>
> I am interested in producing a 4 dimensional plot to represent some data.
>
> I picture this as looking like a normal 3d scatter plot with datapoints
> varying in a color scale which depends on a fourth column of data.
>
> Could anyone help me with this- I have searched google and the matplotlib
> website and have only found some documentation for a MatLab solution bywhich
> I am not interested.
>
> Thank you kindly!
> -Francois

How about this?

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x = np.random.standard_normal(100)
y = np.random.standard_normal(100)
z = np.random.standard_normal(100)
c = np.random.standard_normal(100)

ax.scatter(x, y, z, c=c, cmap=plt.hot())
plt.show()

Angus.
-- AJC McMorland Post-doctoral research fellow Neurobiology, University of Pittsburgh

Hello, Angus!

For this method, if I want to draw a colorbar to indicate the specific
values
for the colors, what should I do? the colorbar() in pylab is not waorking
for
this case.

Use:

plt.colorbar(ax.collections[0])

after the call to scatter, to get the correct mappable handle.

I hope that helps,

Angus.

···

On 3 July 2011 10:33, Wang Jun <daxiawj@...287...> wrote:

Thanks,
Wang Jun

于 2011/7/3 8:48, matplotlib-users-request@lists.sourceforge.net 写道:

On 1 July 2011 14:35, Francois Lemery<francois.lemery@...287...> wrote:

> Hello,
>
> I am interested in producing a 4 dimensional plot to represent some
> data.
>
> I picture this as looking like a normal 3d scatter plot with
> datapoints
> varying in a color scale which depends on a fourth column of data.
>
> Could anyone help me with this- I have searched google and the
> matplotlib
> website and have only found some documentation for a MatLab solution
> bywhich
> I am not interested.
>
> Thank you kindly!
> -Francois

How about this?

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x = np.random.standard_normal(100)
y = np.random.standard_normal(100)
z = np.random.standard_normal(100)
c = np.random.standard_normal(100)

ax.scatter(x, y, z, c=c, cmap=plt.hot())
plt.show()

Angus.
-- AJC McMorland Post-doctoral research fellow Neurobiology, University of
Pittsburgh

--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh