本文整理汇总了Python中matplotlib.cm.RdYlGn方法的典型用法代码示例。如果您正苦于以下问题:Python cm.RdYlGn方法的具体用法?Python cm.RdYlGn怎么用?Python cm.RdYlGn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.cm
的用法示例。
在下文中一共展示了cm.RdYlGn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: psf
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def psf(self,r=1,lambda_1=632*10**(-9),z=0.1):
"""
------------------------------------------------
psf()
Return the point spread function of a wavefront described by
Zernike Polynomials
------------------------------------------------
Input:
r: exit pupil radius(mm)
lambda_1: wavelength(m)
z: exit pupil to image plane distance(m)
"""
print(r,lambda_1,z)
PSF = self.__psfcaculator__(r=r,lambda_1=lambda_1,z=z)
fig = __plt__.figure(figsize=(9, 6), dpi=80)
__plt__.imshow(abs(PSF),cmap=__cm__.RdYlGn)
__plt__.colorbar()
__plt__.show()
return 0
示例2: aspheresurface
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def aspheresurface(self):
"""
Show the surface of an asphere.
=============================================================
Try:
A = opticspy.asphere.Coefficient(R=50,a2=0.18*10**(-8),a3 = 0.392629*10**(-13))
"""
R = self.__coefficients__[0]
theta = __np__.linspace(0, 2*__np__.pi, 100)
rho = __np__.linspace(0, R, 100)
[u,r] = __np__.meshgrid(theta,rho)
X = r*__cos__(u)
Y = r*__sin__(u)
Z = __aspherepolar__(self.__coefficients__,r)
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
linewidth=0, antialiased=False, alpha = 0.6)
__plt__.show()
return 0
示例3: aspherematrix
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def aspherematrix(self):
l = 100
R = self.__coefficients__[0]
x1 = __np__.linspace(-R, R, l)
[X,Y] = __np__.meshgrid(x1,x1)
r = __sqrt__(X**2+Y**2)
Z = __aspherepolar__(self.__coefficients__,r)
for i in range(l):
for j in range(l):
if x1[i]**2+x1[j]**2 > R**2:
Z[i][j] = 0
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
linewidth=0, antialiased=False, alpha = 0.6)
__plt__.show()
return Z
示例4: psf
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def psf(self,lambda_1=632*10**(-9),z=0.1):
"""
------------------------------------------------
psf()
Return the point spread function of a wavefront described by
Orthonormal Rectangular Polynomials
------------------------------------------------
Input:
r: exit pupil radius(mm)
lambda_1: wavelength(m)
z: exit pupil to image plane distance(m)
"""
PSF = self.__psfcaculator__(lambda_1=lambda_1,z=z)
fig = __plt__.figure(figsize=(9, 6), dpi=80)
__plt__.imshow(abs(PSF),cmap=__cm__.RdYlGn)
__plt__.colorbar()
__plt__.show()
return 0
示例5: seidelsurface
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def seidelsurface(self, label = True, zlim=[], matrix = False):
r1 = __np__.linspace(0, 1, 100)
u1 = __np__.linspace(0, 2*__np__.pi, 100)
[u,r] = __np__.meshgrid(u1,r1)
X = r*__cos__(u)
Y = r*__sin__(u)
W = __seidelpolar__(self.__coefficients__,r,u)
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, W, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
linewidth=0, antialiased=False, alpha = 0.6)
fig.colorbar(surf, shrink=1, aspect=30)
__plt__.show()
示例6: zernikesurface
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def zernikesurface(self):
"""
------------------------------------------------
zernikesurface(self, label_1 = True):
Return a 3D Zernike Polynomials surface figure
label_1: default show label
------------------------------------------------
"""
a = self.__a__
b = __sqrt__(1-a**2)
x1 = __np__.linspace(-a, a, 50)
y1 = __np__.linspace(-b, b, 50)
[X,Y] = __np__.meshgrid(x1,y1)
Z = __zernikecartesian__(self.__coefficients__,a,X,Y)
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
linewidth=0, antialiased=False, alpha = 0.6)
ax.auto_scale_xyz([-1, 1], [-1, 1], [Z.max(), Z.min()])
# ax.set_xlim(-a, a)
# ax.set_ylim(-b, b)
# v = max(abs(Z.max()),abs(Z.min()))
# ax.set_zlim(-v*5, v*5)
# cset = ax.contourf(X, Y, Z, zdir='z', offset=-v*5, cmap=__cm__.RdYlGn)
# ax.zaxis.set_major_locator(__LinearLocator__(10))
# ax.zaxis.set_major_formatter(__FormatStrFormatter__('%.02f'))
fig.colorbar(surf, shrink=1, aspect=30)
# p2v = round(__tools__.peak2valley(Z),5)
# rms1 = round(__tools__.rms(Z),5)
__plt__.show()
示例7: zernikemap
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def zernikemap(self, label = True):
"""
------------------------------------------------
zernikemap(self, label_1 = True):
Return a 2D Zernike Polynomials map figure
label: default show label
------------------------------------------------
"""
theta = __np__.linspace(0, 2*__np__.pi, 400)
rho = __np__.linspace(0, 1, 400)
[u,r] = __np__.meshgrid(theta,rho)
X = r*__cos__(u)
Y = r*__sin__(u)
Z = __interferometer__.__zernikepolar__(self.__coefficients__,r,u)
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca()
im = __plt__.pcolormesh(X, Y, Z, cmap=__cm__.RdYlGn)
if label == True:
__plt__.title('Zernike Polynomials Surface Heat Map',fontsize=18)
ax.set_xlabel(self.listcoefficient()[1],fontsize=18)
__plt__.colorbar()
ax.set_aspect('equal', 'datalim')
__plt__.show()
示例8: __psfcaculator__
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def __psfcaculator__(self,r=1,lambda_1=632*10**(-9),z=0.1):
"""
pupil: Exit pupil diameter
z: Distance from exit pupil to image plane
r: pupil radius, in unit of lambda
"""
pupil = l1 = 200 # exit pupil sample points
x = __np__.linspace(-r, r, l1)
[X,Y] = __np__.meshgrid(x,x)
Z = __interferometer__.__zernikecartesian__(self.__coefficients__,X,Y)
for i in range(len(Z)):
for j in range(len(Z)):
if x[i]**2+x[j]**2>r**2:
Z[i][j] = 0
d = 400 # background
A = __np__.zeros([d,d])
A[d//2-l1//2+1:d//2+l1//2+1,d//2-l1//2+1:d//2+l1//2+1] = Z
axis_1 = d//pupil*r
fig = __plt__.figure()
# ax = fig.gca()
# __plt__.imshow(A,extent=[-axis_1,axis_1,-axis_1,axis_1],cmap=__cm__.RdYlGn)
# ax.set_xlabel('mm',fontsize=14)
# __plt__.colorbar()
# __plt__.show()
abbe = __np__.exp(-1j*2*__np__.pi*A)
for i in range(len(abbe)):
for j in range(len(abbe)):
if abbe[i][j]==1:
abbe[i][j]=0
PSF = __fftshift__(__fft2__(__fftshift__(abbe)))**2
PSF = PSF/PSF.max()
return PSF
示例9: spherical_surf
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def spherical_surf(l1):
R = 1.02
l1 = l1 #surface matrix length
theta = __np__.linspace(0, 2*__np__.pi, l1)
rho = __np__.linspace(0, 1, l1)
[u,r] = __np__.meshgrid(theta,rho)
X = r*__cos__(u)
Y = r*__sin__(u)
Z = __sqrt__(R**2-r**2)-__sqrt__(R**2-1)
v_1 = max(abs(Z.max()),abs(Z.min()))
noise = (__np__.random.rand(len(Z),len(Z))*2-1)*0.05*v_1
Z = Z+noise
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,\
linewidth=0, antialiased=False, alpha = 0.6)
v = max(abs(Z.max()),abs(Z.min()))
ax.set_zlim(-1, 2)
ax.zaxis.set_major_locator(__LinearLocator__(10))
ax.zaxis.set_major_formatter(__FormatStrFormatter__('%.02f'))
cset = ax.contourf(X, Y, Z, zdir='z', offset=-1, cmap=__cm__.RdYlGn)
fig.colorbar(surf, shrink=1, aspect=30)
__plt__.title('Test Surface: Spherical surface with some noise',fontsize=16)
__plt__.show()
#Generate test surface matrix from a detector
x = __np__.linspace(-1, 1, l1)
y = __np__.linspace(-1, 1, l1)
[X,Y] = __np__.meshgrid(x,y)
Z = __sqrt__(R**2-(X**2+Y**2))-__sqrt__(R**2-1)+noise
for i in range(len(Z)):
for j in range(len(Z)):
if x[i]**2+y[j]**2>1:
Z[i][j]=0
return Z
示例10: hartmann_rebuild
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def hartmann_rebuild(M,r):
s = len(M)
w = __np__.zeros([s,s])
d = 2
for n in range(s):
label = 0
for m in range(s):
if M[n][m][0] == 0:
pass
elif (M[n][m][0] != 0 and label == 0):
w[n,m] = 0
label = 1
elif (M[n][m][0] != 0 and label == 1):
w[n,m] = w[n][m-1] + d/2/r*(M[n][m-1][2][0] + M[n][m][2][0])
else:
print('wrong')
fig = __plt__.figure(2,figsize=(6, 6))
__plt__.imshow(w)
__plt__.show()
# x = __np__.linspace(-1,1,s)
# [X,Y] = __np__.meshgrid(x,x)
# fig = __plt__.figure(figsize=(8, 8), dpi=80)
# ax = fig.gca(projection='3d')
# surf = ax.plot_surface(w, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
# linewidth=0, antialiased=False, alpha = 0.6)
# __plt__.show()
return w
#Depth first search algorithm, use to find wavefrontase map(where)
示例11: monthly_returns
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def monthly_returns(self, fund, ax=None):
if ax is None:
ax = plt.gca()
# Compute the returns on a month-over-month basis.
history = fund.history
monthly_ret = self.__aggregate_returns(history, 'monthly')
monthly_ret = monthly_ret.unstack()
monthly_ret = np.round(monthly_ret, 3)
monthly_ret.rename(
columns={1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr',
5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug',
9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'},
inplace=True
)
# Create a heatmap showing the month-over-month returns of the portfolio
# or the fund.
sns.heatmap(
monthly_ret.fillna(0) * 100.0, annot=True, fmt="0.1f",
annot_kws={"size": 12}, alpha=1.0, center=0.0, cbar=False,
cmap=cm.RdYlGn, ax=ax
)
ax.set_title('Monthly Returns (%)', fontweight='bold')
ax.set_ylabel('')
ax.set_yticklabels(ax.get_yticklabels(), rotation=0)
ax.set_xlabel('')
return ax
示例12: _plot_monthly_returns
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def _plot_monthly_returns(self, stats, ax=None, **kwargs):
"""
Plots a heatmap of the monthly returns.
"""
returns = stats['returns']
if ax is None:
ax = plt.gca()
monthly_ret = perf.aggregate_returns(returns, 'monthly')
monthly_ret = monthly_ret.unstack()
monthly_ret = np.round(monthly_ret, 3)
monthly_ret.rename(
columns={1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr',
5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug',
9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'},
inplace=True
)
sns.heatmap(
monthly_ret.fillna(0) * 100.0,
annot=True,
fmt="0.1f",
annot_kws={"size": 8},
alpha=1.0,
center=0.0,
cbar=False,
cmap=cm.RdYlGn,
ax=ax, **kwargs)
ax.set_title('Monthly Returns (%)', fontweight='bold')
ax.set_ylabel('')
ax.set_yticklabels(ax.get_yticklabels(), rotation=0)
ax.set_xlabel('')
return ax
示例13: rebuild_surface
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def rebuild_surface(data, shifttype = "4-step", unwraptype = "unwrap2D", noise = True):
"""
Rebuild surface function
============================================
input
--------------------------------------------
data: Interferogram data from PSI
shifttype: PSI type, default 4-step PSI
unwraptype: phaseunwrap type, default "simple"
output
--------------------------------------------
rebuild surface matrix
"""
if shifttype == "4-step" and unwraptype == "simple" and noise == False:
I = data[0]
PR = data[1]
ph = __np__.arctan2((I[3]-I[1]),(I[0]-I[2]))
fig = __plt__.figure(figsize=(9, 6), dpi=80)
im = __plt__.imshow(ph,extent=[-PR,PR,-PR,PR],cmap=__cm__.RdYlGn)
__plt__.title('Wrapped phase',fontsize=16)
__plt__.colorbar()
__plt__.show()
#-----------------------Phase unwrap-------------------------
rebuild_ph = __unwrap2D__(ph,type = "simple")
rebuild_surface = rebuild_ph/2/__np__.pi*PR/2
#------------------------------------------------------------
fig = __plt__.figure(figsize=(9, 6), dpi=80)
im = __plt__.imshow(rebuild_surface,extent=[-PR,PR,-PR,PR],cmap=__cm__.RdYlGn)
__plt__.title('Rebuild Surface',fontsize=16)
__plt__.colorbar()
__plt__.show()
return rebuild_surface
elif shifttype == "4-step" and unwraptype == "unwrap2D" and noise == True:
I = data[0]
PR = data[1]
M = data[2]
s = data[3]
r = __np__.linspace(-PR, PR, s)
ph = __np__.arctan2((I[3]-I[1]),(I[0]-I[2]))
fig = __plt__.figure(figsize=(9, 6), dpi=80)
im = __plt__.imshow(ph,extent=[-PR,PR,-PR,PR],cmap=__cm__.RdYlGn)
__plt__.title('Wrapped phase',fontsize=16)
__plt__.colorbar()
__plt__.show()
#-----------------------Phase unwrap-------------------------
ph1 = [ph,M,s]
rebuild_ph = __unwrap2D__(ph1,noise = True)
rebuild_surface = rebuild_ph/2/__np__.pi*PR/2
__tools__.makecircle_boundary(rebuild_surface, r, PR, 0)
fig = __plt__.figure(figsize=(9, 6), dpi=80)
im = __plt__.imshow(rebuild_surface,extent=[-PR,PR,-PR,PR],cmap=__cm__.RdYlGn)
__plt__.title('Rebuild Surface',fontsize=16)
__plt__.colorbar()
__plt__.show()
return rebuild_surface
else:
print("No this kind of phase shift type")
return 0
示例14: zernikesurface
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def zernikesurface(self, label = True, zlim=[], matrix = False):
"""
------------------------------------------------
zernikesurface(self, label_1 = True):
Return a 3D Zernike Polynomials surface figure
label_1: default show label
------------------------------------------------
"""
theta = __np__.linspace(0, 2*__np__.pi, 100)
rho = __np__.linspace(0, 1, 100)
[u,r] = __np__.meshgrid(theta,rho)
X = r*__cos__(u)
Y = r*__sin__(u)
Z = __interferometer__.__zernikepolar__(self.__coefficients__,r,u)
fig = __plt__.figure(figsize=(12, 8), dpi=80)
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=__cm__.RdYlGn,
linewidth=0, antialiased=False, alpha = 0.6)
if zlim == []:
v = max(abs(Z.max()),abs(Z.min()))
ax.set_zlim(-v*5, v*5)
cset = ax.contourf(X, Y, Z, zdir='z', offset=-v*5, cmap=__cm__.RdYlGn)
else:
ax.set_zlim(zlim[0], zlim[1])
cset = ax.contourf(X, Y, Z, zdir='z', offset=zlim[0], cmap=__cm__.RdYlGn)
ax.zaxis.set_major_locator(__LinearLocator__(10))
ax.zaxis.set_major_formatter(__FormatStrFormatter__('%.02f'))
fig.colorbar(surf, shrink=1, aspect=30)
p2v = round(__tools__.peak2valley(Z),5)
rms1 = round(__tools__.rms(Z),5)
label_1 = self.listcoefficient()[0]+"P-V: "+str(p2v)+"\n"+"RMS: "+str(rms1)
if label == True:
__plt__.title('Zernike Polynomials Surface',fontsize=18)
ax.text2D(0.02, 0.1, label_1, transform=ax.transAxes,fontsize=14)
else:
pass
__plt__.show()
if matrix == True:
return Z
else:
pass
示例15: plot_monthly_ic_heatmap
# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import RdYlGn [as 别名]
def plot_monthly_ic_heatmap(mean_monthly_ic, ax=None):
mean_monthly_ic = mean_monthly_ic.copy()
num_plots = len(mean_monthly_ic.columns)
v_spaces = ((num_plots - 1) // 3) + 1
if ax is None:
f, ax = plt.subplots(v_spaces, 3, figsize=(18, v_spaces * 6))
ax = ax.flatten()
new_index_year = []
new_index_month = []
for date in mean_monthly_ic.index:
new_index_year.append(date.year)
new_index_month.append(date.month)
mean_monthly_ic.index = pd.MultiIndex.from_arrays(
[new_index_year, new_index_month], names=["year", "month"]
)
for a, (period, ic) in zip(ax, mean_monthly_ic.iteritems()):
periods_num = period.replace('period_', '')
sns.heatmap(
ic.unstack(),
annot=True,
alpha=1.0,
center=0.0,
annot_kws={"size": 15},
linewidths=0.01,
linecolor='white',
cmap=cm.RdYlGn,
cbar=False,
ax=a
)
a.set(ylabel='', xlabel='')
a.set_title(ICHEATMAP.get("TITLE").format(periods_num))
if num_plots < len(ax):
for a in ax[num_plots:]:
a.set_visible(False)
return ax