Skip to content

Instantly share code, notes, and snippets.

@yohhoy yohhoy/so45180.py
Created Jun 30, 2018

Embed
What would you like to do?
#!/usr/bin/env python3
# https://ja.stackoverflow.com/questions/45180/
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.colors as colors
n = 10
x_list = np.array(list(range(n*2)))
t_list = np.array(list(range(n*2)))
pp_map = np.ones((n*2)**2)
#----
fig = plt.figure()
ax = Axes3D(fig, rect=(0.1,0.1,0.8,0.8)) #rect=(x0,y0,width,height)
X,Y = np.meshgrid(x_list, t_list)
ax.set_xlabel("Position",labelpad=10,fontsize=24)
ax.set_ylabel("Time",labelpad=20,fontsize=24)
ax.set_zlabel("|φ|^2",fontsize=18)
ax.set_xlim(2*n,0)
ax.set_ylim(2*n,0)
ax.set_zlim(0,1)
offset = pp_map.ravel() + np.abs(pp_map.min())
fracs = offset.astype(float)/offset.max()
norm = colors.Normalize(fracs.min(), fracs.max())
clrs = plt.cm.cool(norm(fracs))
ax.bar3d(X.ravel(), Y.ravel(), pp_map.ravel() ,0.5, 0.5, -pp_map.ravel(),color =clrs)
ax.w_xaxis.set_pane_color((0, 0, 0, 0))
ax.w_yaxis.set_pane_color((0, 0, 0, 0))
ax.w_zaxis.set_pane_color((0, 0, 0, 0))
ax.grid(color="white")
ax.grid(False)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.