Skip to content

Instantly share code, notes, and snippets.

@bluepost59
Last active October 10, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluepost59/1f844f0aa9914b2b622c192e5c969edc to your computer and use it in GitHub Desktop.
Save bluepost59/1f844f0aa9914b2b622c192e5c969edc to your computer and use it in GitHub Desktop.
資料作りのためのmatplotlib入門(2) 2次元contour図 ref: https://qiita.com/Bluepost59/items/a0869aee34db3f450162
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
nx = 100
ny = 200
mydata = np.loadtxt('mydata.txt')
xx = np.linspace(0,nx,nx)
yy = np.linspace(0,ny,ny)
xx,yy = np.meshgrid(xx,yy)
zz = mydata[:,2].reshape(nx,ny).T
myfig = plt.figure()
myax = myfig.add_subplot(1,1,1)
myim = myax.pcolor(xx,yy,zz)
myfig.colorbar(myim)
myfig.savefig('contour.png')
do i = 1,Nx
do j = 1,Ny
write(UNITNUM,*) i,j,A(i,j)
end do
end do
1 1 0.000
1 2 1.000
...
1 10 0.424
2 1 0.242
...
10 10 0.551
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment