Skip to content

Instantly share code, notes, and snippets.

@hyounggyu
Last active December 15, 2015 15:19
Show Gist options
  • Select an option

  • Save hyounggyu/5281415 to your computer and use it in GitHub Desktop.

Select an option

Save hyounggyu/5281415 to your computer and use it in GitHub Desktop.
#
# Data type.
#
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def getAll(fstr, ncol):
return [ [ float(val.split()[ncol]) for val in d.strip().split('\n') ] for d in fstr.strip().split('\n\n') ]
def getFirstRows(fstr, ncol):
return [ float(d.strip().split('\n')[0].strip().split()[ncol]) for d in fstr.strip().split('\n\n') ]
def PlotSurpace(X, Y, Z):
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
plt.show()
def linePlot(X):
plt.plot(X)
plt.show()
def main():
fstr = open('field_23000', 'r').read()
Z = np.array(getAll(fstr, 2))
#linePlot(Z[0])
X = np.arange(Z.shape[1])
Y = np.array(getFirstRows(fstr, 0))
X, Y = np.meshgrid(X, Y)
PlotSurface(X, Y, Z)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment