Closed
Description
matplotlib version 1.5.1; Py 2.7.11; OSX
The code below can run smoothly without any errors, but it returns no figure when I run it as a script.
If I run it in ipython command, it's fine.
Wired!!
For other script, my python is also fine.
No ideas.
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib as mpl
def colorMapper(data):
#_this helper function returns mapper that will normalize
#_the colors in your dataset for plotting
minima = min(data)
maxima = max(data)
norm = mpl.colors.Normalize(vmin = minima,
vmax = maxima,
clip = True)
mapper = mpl.cm.ScalarMappable(norm = norm)
return norm, mapper
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
xs = [1, 1, 1, 1, 1, 1, 1, 1]
ys = [1, 1, 1, 1, 2, 2, 2, 2]
zs = [1, 2, 3, 4, 1, 2, 3, 4]
data = [1, 2, 3, 4, 1, 2, 3, 4]
norm, mapper = colorMapper(data)
for x, y, z, dat in zip(xs, ys, zs, data):
ax.scatter(x, y, z, color = mapper.to_rgba(dat),s = dat * 10)
plt.savefig('foo.png')
fig.show()
Metadata
Metadata
Assignees
Labels
No labels