Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: New Julia
Views: 239
Kernel: Python 2 (SageMath)
from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import matplotlib.pyplot as plt import numpy as np import cPickle as pickle with open('../data/10^2.pkl') as f: data=pickle.load(f)["iterations"] h =1.0 data = data.astype(float)*h/data.max() X,Y = np.meshgrid( np.linspace(-3,3,data.shape[0]), np.linspace(-3,3,data.shape[1]) ) X = X.flatten() Y = Y.flatten() data = data.flatten() print(X.shape) print(Y.shape) print(data.shape) X = np.hstack( (X,X) ) Y = np.hstack( (Y,Y) ) data = np.hstack( (data, (data+1)) ) fig = plt.figure() ax = fig.gca(projection='3d') ax.set_axis_off() ax.plot_trisurf(X, Y, data, cmap=cm.copper, linewidth=0.2) plt.savefig('test.png') plt.show()
(10000,) (10000,) (10000,)
Image in a Jupyter notebook
a = np.array( [[1,2,3],[4,5,6]]) b = np.array([1,2,3,4,5,45,-6,7,8,9]) b[a]
array([[ 2, 3, 4], [ 5, 45, -6]])
c = cm.jet(a) d = c.reshape( (c.shape[0]*c.shape[1],c.shape[2]) ) d = (0xFF*d).astype(int) # + (d[:,1]<<8) + (d[:,2]<<16) + (d[:,3]<<24) out = sum( d[:,i]<<(8*i) for i in range(4) ) out.reshape(a.shape)
array([[4286840832, 4287102976, 4287430656], [4287692800, 4288020480, 4288282624]])
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-57-049c230fd693> in <module>() 1 a = 'copper' ----> 2 cm.a AttributeError: 'module' object has no attribute 'a'
0xff*d
array([[ 0. , 0. , 132.04545455, 255. ], [ 0. , 0. , 136.59090909, 255. ], [ 0. , 0. , 141.13636364, 255. ], [ 0. , 0. , 145.68181818, 255. ], [ 0. , 0. , 150.22727273, 255. ], [ 0. , 0. , 154.77272727, 255. ]])