• R/O
  • SSH

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

ファイル情報

Rev. ddbcb35c0e58c94c906858239f858d5817d9aad1
サイズ 1,851 バイト
日時 2010-10-22 02:03:04
作者 lorenzo
ログメッセージ

I am generating the plot of a scalar on a circle by clipping a plot on a rectangle + I am using some features of matplotlib.

内容

#!/usr/bin/env python
"""
See pcolor_demo2 for a much faster way of generating pcolor plots
"""
from __future__ import division
from pylab import *



# make these smaller to increase the resolution
dx, dy = 0.005, 0.005

x = arange(-1.0, 1.0, dx)
y = arange(-1.0, 1.0, dy)
X,Y = meshgrid(x, y)


# just look at the following lines for a way of creating images

# ax = subplot(111)
# im = imshow(Z, cmap=cm.jet)
# #im.set_interpolation('nearest')
# #im.set_interpolation('bicubic')
# im.set_interpolation('bilinear')
# #ax.set_image_extent(-3, 3, -3, 3)

# show()



# function defined in polar coordinate
def func5(theta, r):
   y = r*np.sin(theta)
   theta=np.arcsin(y)
   return np.cos(theta)


def func6(theta, r):
   y = r*np.sin(theta)
   theta=np.arcsin(y)
   return np.abs(sin(theta))

def func7(theta, r):
   y = r*np.sin(theta)
   theta=np.arcsin(y)
   return np.abs(cos(theta))




R=1.
n_theta, n_r = 36,20    # 360, 100

# coordinates of the mesh
theta = np.linspace(0, 2*np.pi, n_theta+1)
r = np.linspace(0., R, n_r + 1)

dr, dtheta = r[1]-r[0], theta[1]-theta[0]

# cooridnate for the data point
theta_d = np.arange(dtheta/2., 2*np.pi, dtheta)
r_d = np.arange(dr/2., R, dr)


TT, RR = meshgrid(theta_d, r_d)
# Z = func6(TT, RR)

Z = func7(TT, RR)




ax=subplot(1,1,1, projection="polar", aspect=1.)
ax.pcolormesh(theta, r, Z)

# ax.set_xlabel('Model complexity --->')

ax.set_yticklabels([])
ax.set_xticklabels([])


ax.grid(False)
# show()



# arr = Arrow(0, 0, .3, .3, edgecolor='white')

# # Get the subplot that we are currently working on
# ax = gca()

# # Now add the arrow
# ax.add_patch(arr)

# # We should be able to make modifications to the arrow.
# # Lets make it green.
# arr.set_facecolor('g')


annotate("", xy=(0, 0), xytext=(-1, 0), arrowprops=dict(fc="g"))


savefig("test.pdf")
 
clf()    


print "So far so good"