本文整理汇总了Python中matplotlib.colors.Normalize.autoscale方法的典型用法代码示例。如果您正苦于以下问题:Python Normalize.autoscale方法的具体用法?Python Normalize.autoscale怎么用?Python Normalize.autoscale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.colors.Normalize
的用法示例。
在下文中一共展示了Normalize.autoscale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: model_to_pc2
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def model_to_pc2(model, x_start, y_start, resolution, width, height):
"""
Creates a PointCloud2 by sampling a regular grid of points from the given model.
"""
pc = PointCloud2()
pc.header.stamp = rospy.get_rostime()
pc.header.frame_id = 'map'
xy_points = []
for x in map_range(x_start, x_start + width, resolution):
for y in map_range(y_start, y_start + height, resolution):
xy_points.append([x, y])
probs = model.score_samples(xy_points)
# and normalise to range to make the visualisation prettier
normaliser = Normalize()
normaliser.autoscale(probs)
probs = normaliser(probs)
colour_map = plt.get_cmap('jet')
colours = colour_map(probs, bytes=True)
cloud = []
for i in range(len(probs)):
cloud.append([xy_points[i][0], xy_points[i][1], 2*probs[i], pack_rgb(colours[i][0], colours[i][1], colours[i][2])])
return create_cloud_xyzrgb(pc.header, cloud)
示例2: residual_map_special_deltapsi_add_on
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def residual_map_special_deltapsi_add_on( reflections,experiments,matches,hkllist, predicted,plot,eta_deg,deff ):
detector = experiments[0].detector
crystal = experiments[0].crystal
unit_cell = crystal.get_unit_cell()
pxlsz = detector[0].get_pixel_size()
model_millers = reflections["miller_index"]
dpsi = flex.double()
for match in matches:
obs_miller = hkllist[match["pred"]]
model_index= model_millers.first_index(obs_miller)
raw_delta_psi = reflections["delpsical.rad"][model_index]
deltapsi_envelope = (unit_cell.d(obs_miller)/deff) + math.pi*eta_deg/180.
normalized_delta_psi = raw_delta_psi/deltapsi_envelope
dpsi.append( normalized_delta_psi )
from matplotlib.colors import Normalize
dnorm = Normalize()
dnorm.autoscale(dpsi.as_numpy_array())
CMAP = plot.get_cmap("bwr")
for match,dcolor in zip(matches,dpsi):
#print dcolor, dnorm(dcolor), CMAP(dnorm(dcolor))
#blue represents negative delta psi: outside Ewald sphere; red, positive, inside Ewald sphere
plot.plot([predicted[match["pred"]][1]/pxlsz[1]],[-predicted[match["pred"]][0]/pxlsz[0]],color=CMAP(dnorm(dcolor)),
marker=".", markersize=5)
示例3: plot
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def plot(d, sphere=False):
"""
Plot directivity `d`.
:param d: Directivity
:type d: :class:`Directivity`
:returns: Figure
"""
#phi = np.linspace(-np.pi, +np.pi, 50)
#theta = np.linspace(0.0, np.pi, 50)
phi = np.linspace(0.0, +2.0*np.pi, 50)
theta = np.linspace(0.0, np.pi, 50)
THETA, PHI = np.meshgrid(theta, phi)
# Directivity strength. Real-valued. Can be positive and negative.
dr = d.using_spherical(THETA, PHI)
if sphere:
x, y, z = spherical_to_cartesian(1.0, THETA, PHI)
else:
x, y, z = spherical_to_cartesian( np.abs(dr), THETA, PHI )
#R, THETA, PHI = cartesian_to_spherical(x, y, z)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#p = ax.plot_surface(x, y, z, cmap=plt.cm.jet, rstride=1, cstride=1, linewidth=0)
norm = Normalize()
norm.autoscale(dr)
colors = cm.jet(norm(dr))
m = cm.ScalarMappable(cmap=cm.jet, norm=norm)
m.set_array(dr)
p = ax.plot_surface(x, y, z, facecolors=colors, rstride=1, cstride=1, linewidth=0)
plt.colorbar(m, ax=ax)
ax.set_xlabel('$x$')
ax.set_ylabel('$y$')
ax.set_zlabel('$z$')
return fig
示例4: auto_scale_cross_plot
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def auto_scale_cross_plot(self, event):
norm = Normalize()
for hl in self.h_cross_slice_plot.get_lines():
d = hl.get_ydata()
norm.autoscale(d)
hl.set_ydata(norm(d))
for vl in self.v_cross_slice_plot.get_lines():
d = vl.get_ydata()
norm.autoscale(d)
vl.set_ydata(norm(d))
self.v_cross_slice_plot.relim()
self.h_cross_slice_plot.relim()
self.v_cross_slice_plot.autoscale_view(True,True,True)
self.h_cross_slice_plot.autoscale_view(True,True,True)
self.cross_slice_canvas.draw()
示例5: plot
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def plot(self,dano_summation):
from matplotlib import pyplot as plt
if self.params.use_weights:
wt = 1./(self.diffs.sigmas()*self.diffs.sigmas())
order = flex.sort_permutation(wt)
wt = wt.select(order)
df = self.diffs.data().select(order)
dano = dano_summation.select(self.sel0).select(order)
from matplotlib.colors import Normalize
dnorm = Normalize()
dnorm.autoscale(wt.as_numpy_array())
CMAP = plt.get_cmap("rainbow")
for ij in xrange(len(self.diffs.data())):
#blue represents zero weight: red, large weight
plt.plot([df[ij]],[dano[ij]],color=CMAP(dnorm(wt[ij])),marker=".", markersize=4)
else:
plt.plot(self.diffs.data(),dano_summation.select(self.sel0),"r,")
plt.axes().set_aspect("equal")
plt.axes().set_xlabel("Observed Dano")
plt.axes().set_ylabel("Model Dano")
plt.show()
示例6: plot2D
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def plot2D(X, filename=None, last_column_color=False):
x1 = X[:, 0]
x2 = X[:, 1]
m = X.shape[0]
if last_column_color:
c = X[:, -1]
c_map = get_cmap('jet')
c_norm = Normalize()
c_norm.autoscale(c)
scalar_map = ScalarMappable(norm=c_norm, cmap=c_map)
color_val = scalar_map.to_rgba(c)
else:
color_val = 'b' * m
fig = figure()
ax = fig.add_subplot(111)
for i in range(m):
ax.plot(x1[i], x2[i], 'o', color=color_val[i])
if filename is None:
fig.show()
else:
fig.savefig(filename + ".png")
fig.clf()
close()
示例7: ImagePlot
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def ImagePlot(image):
if str(image.colorscale)=='n':
remap = Normalize()
remap.autoscale(image.data)
ax.imshow(image.data, cmap='gray', norm=remap, origin='lower')
elif str(image.colorscale) == 'yg':
remap = LogNorm()
remap.autoscale(image.data)
ax.imshow(image.data, cmap='gray', norm=remap, origin='lower')
elif str(image.colorscale) == 'ys':
remap = LogNorm()
remap.autoscale(image.data)
ax.imshow(image.data, cmap='seismic', norm=remap, origin='lower')
示例8: plot_one_model
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import autoscale [as 别名]
def plot_one_model(self,nrow,out):
fig = plt.subplot(self.gs[nrow*self.ncols])
two_thetas = self.reduction.get_two_theta_deg()
degrees = self.reduction.get_delta_psi_deg()
if self.color_encoding=="conventional":
positive = (self.reduction.i_sigi>=0.)
fig.plot(two_thetas.select(positive), degrees.select(positive), "bo")
fig.plot(two_thetas.select(~positive), degrees.select(~positive), "r+")
elif self.color_encoding=="I/sigma":
positive = (self.reduction.i_sigi>=0.)
tt_selected = two_thetas.select(positive)
dp_selected = degrees.select(positive)
i_sigi_select = self.reduction.i_sigi.select(positive)
order = flex.sort_permutation(i_sigi_select)
tt_selected = tt_selected.select(order)
dp_selected = dp_selected.select(order)
i_sigi_selected = i_sigi_select.select(order)
from matplotlib.colors import Normalize
dnorm = Normalize()
dcolors = i_sigi_selected.as_numpy_array()
dnorm.autoscale(dcolors)
N = len(dcolors)
CMAP = plt.get_cmap("rainbow")
if self.refined.get("partiality_array",None) is None:
for n in xrange(N):
fig.plot([tt_selected[n]],[dp_selected[n]],
color=CMAP(dnorm(dcolors[n])),marker=".", markersize=10)
else:
partials = self.refined.get("partiality_array")
partials_select = partials.select(positive)
partials_selected = partials_select.select(order)
assert len(partials)==len(positive)
for n in xrange(N):
fig.plot([tt_selected[n]],[dp_selected[n]],
color=CMAP(dnorm(dcolors[n])),marker=".", markersize=20*partials_selected[n])
# change the markersize to indicate partiality.
negative = (self.reduction.i_sigi<0.)
fig.plot(two_thetas.select(negative), degrees.select(negative), "r+", linewidth=1)
else:
strong = (self.reduction.i_sigi>=10.)
positive = ((~strong) & (self.reduction.i_sigi>=0.))
negative = (self.reduction.i_sigi<0.)
assert (strong.count(True)+positive.count(True)+negative.count(True) ==
len(self.reduction.i_sigi))
fig.plot(two_thetas.select(positive), degrees.select(positive), "bo")
fig.plot(two_thetas.select(strong), degrees.select(strong), marker='.',linestyle='None',
markerfacecolor='#00ee00', markersize=10)
fig.plot(two_thetas.select(negative), degrees.select(negative), "r+")
# indicate the imposed resolution filter
wavelength = self.reduction.experiment.beam.get_wavelength()
imposed_res_filter = self.reduction.get_imposed_res_filter(out)
resolution_markers = [
a for a in [imposed_res_filter,self.reduction.measurements.d_min()] if a is not None]
for RM in resolution_markers:
two_th = (180./math.pi)*2.*math.asin(wavelength/(2.*RM))
plt.plot([two_th, two_th],[self.AD1TF7B_MAXDP*-0.8,self.AD1TF7B_MAXDP*0.8],'k-')
plt.text(two_th,self.AD1TF7B_MAXDP*-0.9,"%4.2f"%RM)
#indicate the linefit
mean = flex.mean(degrees)
minplot = flex.min(two_thetas)
plt.plot([0,minplot],[mean,mean],"k-")
LR = flex.linear_regression(two_thetas, degrees)
model_y = LR.slope()*two_thetas + LR.y_intercept()
plt.plot(two_thetas, model_y, "k-")
#Now let's take care of the red and green lines.
half_mosaic_rotation_deg = self.refined["half_mosaic_rotation_deg"]
mosaic_domain_size_ang = self.refined["mosaic_domain_size_ang"]
red_curve_domain_size_ang = self.refined.get("red_curve_domain_size_ang",mosaic_domain_size_ang)
a_step = self.AD1TF7B_MAX2T / 50.
a_range = flex.double([a_step*x for x in xrange(1,50)]) # domain two-theta array
#Bragg law [d=L/2sinTH]
d_spacing = (wavelength/(2.*flex.sin(math.pi*a_range/360.)))
# convert two_theta to a delta-psi. Formula for Deffective [Dpsi=d/2Deff]
inner_phi_deg = flex.asin((d_spacing / (2.*red_curve_domain_size_ang)) )*(180./math.pi)
outer_phi_deg = flex.asin((d_spacing / (2.*mosaic_domain_size_ang)) + \
half_mosaic_rotation_deg*math.pi/180. )*(180./math.pi)
plt.title("ML: mosaicity FW=%4.2f deg, Dsize=%5.0fA on %d spots\n%s"%(
2.*half_mosaic_rotation_deg, mosaic_domain_size_ang, len(two_thetas),
os.path.basename(self.reduction.filename)))
plt.plot(a_range, inner_phi_deg, "r-")
plt.plot(a_range,-inner_phi_deg, "r-")
plt.plot(a_range, outer_phi_deg, "g-")
plt.plot(a_range, -outer_phi_deg, "g-")
plt.xlim([0,self.AD1TF7B_MAX2T])
plt.ylim([-self.AD1TF7B_MAXDP,self.AD1TF7B_MAXDP])
#second plot shows histogram
fig = plt.subplot(self.gs[1+nrow*self.ncols])
plt.xlim([-self.AD1TF7B_MAXDP,self.AD1TF7B_MAXDP])
nbins = 50
n,bins,patches = plt.hist(dp_selected, nbins,
range=(-self.AD1TF7B_MAXDP,self.AD1TF7B_MAXDP),
weights=self.reduction.i_sigi.select(positive),
normed=0, facecolor="orange", alpha=0.75)
#ersatz determine the median i_sigi point:
isi_positive = self.reduction.i_sigi.select(positive)
#.........这里部分代码省略.........