本文整理汇总了Python中mpl_toolkits.axes_grid1.host_subplot函数的典型用法代码示例。如果您正苦于以下问题:Python host_subplot函数的具体用法?Python host_subplot怎么用?Python host_subplot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了host_subplot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_twin_axes_empty_and_removed
def test_twin_axes_empty_and_removed():
# Purely cosmetic font changes (avoid overlap)
matplotlib.rcParams.update({"font.size": 8})
matplotlib.rcParams.update({"xtick.labelsize": 8})
matplotlib.rcParams.update({"ytick.labelsize": 8})
generators = [ "twinx", "twiny", "twin" ]
modifiers = [ "", "host invisible", "twin removed", "twin invisible",
"twin removed\nhost invisible" ]
# Unmodified host subplot at the beginning for reference
h = host_subplot(len(modifiers)+1, len(generators), 2)
h.text(0.5, 0.5, "host_subplot", horizontalalignment="center",
verticalalignment="center")
# Host subplots with various modifications (twin*, visibility) applied
for i, (mod, gen) in enumerate(product(modifiers, generators),
len(generators)+1):
h = host_subplot(len(modifiers)+1, len(generators), i)
t = getattr(h, gen)()
if "twin invisible" in mod:
t.axis[:].set_visible(False)
if "twin removed" in mod:
t.remove()
if "host invisible" in mod:
h.axis[:].set_visible(False)
h.text(0.5, 0.5, gen + ("\n" + mod if mod else ""),
horizontalalignment="center", verticalalignment="center")
plt.subplots_adjust(wspace=0.5, hspace=1)
示例2: init_axis_gs
def init_axis_gs (gs, twin=False, sharex=False):
if not sharex:
ax = host_subplot(gs, axes_class=AA.Axes)
else:
ax = host_subplot(gs, axes_class=AA.Axes, sharex=sharex)
if twin:
return ax, ax.twin()
else:
return ax
示例3: plot_classification_confidence_histograms
def plot_classification_confidence_histograms(config, task, model, scaler, X_test, classes, targets_test, excludes_test):
best_confidence_hist = [0 for i in range(101)]
true_confidence_hist = [0 for i in range(101)]
if scaler != None:
X_test = scaler.transform(X_test)
probabs = model.predict(X_test, verbose=0)
for i in range(0, probabs.shape[0]):
classes_sorted = probabs[i].argsort()[::-1]
adjusted_classes_and_probabs_sorted = []
for j in range(0,classes_sorted.shape[0]):
classname = classes[classes_sorted[j]]
probab = probabs[i][classes_sorted[j]]
if classname not in excludes_test[i]:
adjusted_classes_and_probabs_sorted.append((classname, probab))
probab = adjusted_classes_and_probabs_sorted[0][1]
try:
best_confidence_hist[int(round(100*probab))] += 1
except ValueError:
return
best = 0
while best < len(adjusted_classes_and_probabs_sorted):
if adjusted_classes_and_probabs_sorted[best][0] == targets_test[i]:
probab = adjusted_classes_and_probabs_sorted[best][1]
try:
true_confidence_hist[int(round(100*probab))] += 1
except ValueError:
return
break
else:
best += 1
host = host_subplot(111)
host.set_xlabel('Confidence')
host.set_ylabel("Probability")
divisor = sum(true_confidence_hist)
host.plot(np.array(range(101)), np.array([x/divisor for x in true_confidence_hist]), label='Probability')
plt.title('True Confidence Hist')
plt.savefig(config['base_folder'] + 'classification/true_confidence_hist_' + task + '.png')
plt.close()
print("Saving true confidence histogram to " + config['base_folder'] + 'classification/true_confidence_hist_' + task + '.png')
host = host_subplot(111)
host.set_xlabel('Confidence')
host.set_ylabel("Probability")
divisor = sum(best_confidence_hist)
host.plot(np.array(range(101)), np.array([x/divisor for x in best_confidence_hist]), label='Probability')
plt.title('Best Confidence Hist')
plt.savefig(config['base_folder'] + 'classification/best_confidence_hist_' + task + '.png')
print("Saving true confidence histogram to " + config['base_folder'] + 'classification/best_confidence_hist_' + task + '.png')
示例4: plot_distribution
def plot_distribution(val):
theta = np.pi/2*val
sense = ta.lha_sensor()
sigma = sense.get_sigma(100, theta)
s = sense.sample_from(100, theta, 1000)
x=None
layers=160
for n in range(-layers,layers):
y=np.arange((2*n-1)*np.pi/2,(2*n+1)*np.pi/2,np.pi/256)[0:256]
if verbose:
stderr.write("layer %d: shape: %r\n" % (n,y.shape))
if x==None:
x = y
else:
if n != 0:
y = y[::-1]
x = np.vstack((x,y))
ax=x[layers,:]
f=gauss(x,theta,sigma)
host = host_subplot(111)
n=0
plt.plot(ax,f[n+layers,:],linewidth=1, color='r', label='Gaussian assumption')
#plt.plot(ax,f[1,:],linewidth=1, color='r')
plt.plot(ax,f.sum(axis=0),linewidth=1, color='b', linestyle='--', label='effective')
#ax.set_ticks([0., .5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])
plt.axvline(-np.pi/2, color='grey', linestyle='--')
plt.axvline(np.pi/2, color='grey', linestyle='--')
plt.axhline(1/np.pi, color='grey', linestyle=':', label='Uniform')
plt.legend(loc=10)
return plt
示例5: mass_plot
def mass_plot(self):
sources = self.sources
host = host_subplot(111, axes_class = AA.Axes)
plt.subplots_adjust(right = 0.75)
host.set_yscale("log")
hist = sources.data["top"]
bin_edges = sources.data["edges"]
host.set_xlabel(sources.data["x_unit"], fontsize = 25)
y_unit = sources.data["y_unit"]
host.set_ylabel(y_unit, fontsize = 25)
host.bar(bin_edges[:-1], hist, width = 1)
host.set_xlim(min(bin_edges), max(bin_edges))
plt.xticks(fontsize = 16)
plt.yticks(fontsize = 16)
plt.show()
"""
示例6: plot
def plot(self):
host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.75)
par1 = host.twinx()
par2 = host.twinx()
offset = 60
new_fixed_axis = par2.get_grid_helper().new_fixed_axis
par2.axis["right"] = new_fixed_axis(loc="right", axes=par2, offset=(offset, 0))
par2.axis["right"].toggle(all=True)
host.set_xlim(0, 40000)
host.set_ylim(-180, 400)
host.set_xlabel("altitude [feet]")
host.set_ylabel("direction [deg]")
par1.set_ylabel("velocity [kts]")
par2.set_ylabel("temperature [F]")
p1, = host.plot(self.alt_markers, self.i_direction, label="Direction", color="black")
p2, = host.plot(self.alt_markers, self.i_speed, label="Velocity", color="blue")
p3, = host.plot(self.alt_markers, self.i_temperature, label="Temperature", color="red")
par1.set_ylim(-180, 400)
par2.set_ylim(-180, 400)
host.legend()
host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
par2.axis["right"].label.set_color(p3.get_color())
plt.draw()
plt.show()
示例7: MakePlot
def MakePlot(ncanvas,ndata,title,FigName,xlab,ylab,invert,x1,y1,x2,y2,x3,y3,show):
if os.path.exists(FigName) == False :
plt.figure(ncanvas)
host = host_subplot(111)
host.set_xlabel(xlab)
host.set_ylabel(ylab)
if invert == True :
plt.gca().invert_xaxis()
if ndata == 1 or ndata == 2 or ndata == 3 :
plt.scatter(x1,y1,marker = 'o', color = 'g')
if ndata == 2 or ndata == 3 :
plt.scatter(x2,y2,marker = 'o', color = 'r')
if ndata == 3 :
plt.scatter(x3,y3,marker = 'o', color = 'b')
plt.title(title)
grid(False)
savefig(FigName)
plt.legend( loc='lower left')
print(FigName+" has been created "+"\n")
if show :
plt.show()
else :
print(FigName + " already exists"+"\n")
示例8: line_plot_overlapping_peak_intensity
def line_plot_overlapping_peak_intensity(dict_of_bins):
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
import matplotlib.pyplot as plt
if 1:
host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.75)
par1 = host.twinx()
par2 = host.twinx()
#par3 = host.twinx()
offset = 40
new_fixed_axis = par2.get_grid_helper().new_fixed_axis
par2.axis["right"] = new_fixed_axis(loc="right",
axes=par2,
offset=(offset, 0))
#new_fixed_axis = par3.get_grid_helper().new_fixed_axis
#par3.axis["right"] = new_fixed_axis(loc="right",
# axes=par3,
# offset=(2 * offset, 0))
par2.axis["right"].toggle(all=True)
#par3.axis["right"].toggle(all=True)
List = dict_of_bins.values()
names = dict_of_bins.keys()
x_range = range(0, len(List[0]))
host.set_xlim(0, len(List[0]))
host.set_ylim(0, int(max(List[1])) + 10)
host.set_xlabel("Clustered peaks")
host.set_ylabel(names[1])
par1.set_ylabel(names[2])
par2.set_ylabel(names[3])
#par3.set_ylabel(names[3])
p1, = host.plot(x_range, List[1], label=names[1], marker='o')
p2, = par1.plot(x_range, List[2], label=names[2], marker='o')
p3, = par2.plot(x_range, List[3], label=names[3], marker='o')
#p4, = par3.plot(x_range, List[3], label=names[3], marker='o')
par1.set_ylim(0, int(max(List[2])) + 10)
par2.set_ylim(0, int(max(List[3])) + 10)
#par3.set_ylim(0, int(max(List[3])) + 10)
host.legend(loc='upper left')
host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
par2.axis["right"].label.set_color(p3.get_color())
#par3.axis["right"].label.set_color(p4.get_color())
plt.draw()
# plt.show()
plt.savefig(
'/ps/imt/e/20141009_AG_Bauer_peeyush_re_analysis/further_analysis/overlap/overlapping_peak_intensity_'+names[0]+names[1]+'.png')
plt.clf()
示例9: density_plot
def density_plot(rbin1, mTbin1, rhobin1, partAge1, rbin2, mTbin2, rhobin2, partAge2):
if partAge1 < 0.0:
particle_1_label = str(int(abs(partAge1))) + ' yr prior to formation'
else:
particle_1_label = str(int(partAge1)) + ' yr after formation'
if partAge2 < 0.0:
particle_2_label = str(int(abs(partAge2))) + ' yr prior to formation'
else:
particle_2_label = str(int(partAge2)) + ' yr after formation'
pl.clf()
pl.rc('text', usetex=True)
pl.rc('font', family='serif')
host = host_subplot(111, axes_class=AA.Axes)
par1 = host.twinx()
Ndensity_Y_min = 1e1
Ndensity_Y_max = 1e8
host.set_xlim(3e-3, 5e0)
host.set_ylim(Ndensity_Y_min, Ndensity_Y_max)
Mdensity_Y_min = Ndensity_Y_min * 2. * mp
Mdensity_Y_max = Ndensity_Y_max * 2. * mp
par1.set_ylim(Mdensity_Y_min, Mdensity_Y_max)
par1.set_yscale('log')
pl.gcf().subplots_adjust(bottom=0.15)
host.set_ylabel('$n$ $({\\rm cm}^{-3})$', fontsize = 28)
host.set_xlabel('$r$ $({\\rm pc})$', fontsize = 28)
par1.set_ylabel('$\\rho$ $({\\rm g\\, cm}^{-3})$', fontsize = 28)
host.axis["left"].label.set_fontsize(25)
host.axis["bottom"].label.set_fontsize(25)
par1.axis["right"].label.set_fontsize(25)
host.loglog(rbin1, rhobin1/mp, 'b.--', label = particle_1_label)
host.loglog(rbin2, rhobin2/mp, 'g-', label = particle_2_label)
pl.legend(loc=0, fontsize='20', frameon=False)
pl.rc('text', usetex=False)
示例10: on_epoch_end
def on_epoch_end(self, epoch, logs={}):
self.val_losses.append(logs.get('val_loss'))
self.val_accs.append(logs.get(self.additional_metric_name))
self.epochs.append(epoch)
host = host_subplot(111)
par = host.twinx()
host.set_xlabel('epochs')
host.set_ylabel("Accuracy")
par.set_ylabel("Loss")
p1, = host.plot(self.epochs, self.val_accs, label=self.additional_metric_name)
p2, = par.plot(self.epochs, self.val_losses, label="Validation Loss")
leg = plt.legend(loc='lower left')
host.yaxis.get_label().set_color(p1.get_color())
leg.texts[0].set_color(p1.get_color())
par.yaxis.get_label().set_color(p2.get_color())
leg.texts[1].set_color(p2.get_color())
plt.title('Metrics by epoch')
plt.savefig(self.filename)
plt.close()
# Do also flush STDOUT
sys.stdout.flush()
示例11: plot_gef_load_Z01_raw
def plot_gef_load_Z01_raw():
X, y, D = fear_load_mat('../data/gef_load_full_Xy.mat', 1)
host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.85)
par1 = host.twinx()
# host.set_xlim(0, 2)
# host.set_ylim(0, 2)
host.set_xlabel("Time")
host.set_ylabel("Load (Z01)")
par1.set_ylabel("Temperature (T09)")
p1, = host.plot(X[0:499,0], y[0:499])
p2, = par1.plot(X[0:499,0], X[0:499,9])
# par1.set_ylim(0, 4)
host.legend()
host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
plt.draw()
plt.show()
示例12: create_plot
def create_plot(self, parent):
"""Create plot area"""
plotframe = QtGui.QFrame(parent)
sizepol = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Fixed)
sizepol.setHorizontalStretch(0)
sizepol.setVerticalStretch(0)
sizepol.setHeightForWidth(plotframe.sizePolicy().hasHeightForWidth())
plotframe.setSizePolicy(sizepol)
plotframe.setMinimumSize(QtCore.QSize(0, 200))
plotframe.setMaximumSize(QtCore.QSize(1980, 200))
# plotframe.setFrameShape(QtGui.QFrame.StyledPanel)
# plotframe.setFrameShadow(QtGui.QFrame.Raised)
plotframe.setObjectName("plotframe")
plotlayout = QtGui.QVBoxLayout(plotframe)
plotlayout.setMargin(0)
plotlayout.setObjectName("plotlayout")
fig = plt.figure(dpi=100)#, frameon=False figsize=(20, 4),
fig.patch.set_facecolor('white')
rcParams['axes.color_cycle'] = ['k', 'b', 'g', 'r']
self.canvas = FigureCanvas(fig)
self.axes.append(host_subplot(111, axes_class=aa.Axes))
self.axes[0].set_xlabel("Time")
self.axes[0].set_ylabel(DATA_LABELS[9])
self.axes[0].set_aspect('auto', 'datalim')
self.plots.append(self.axes[0].plot(aprs_daemon.LIVE_DATA['timestamps'],
aprs_daemon.LIVE_DATA['altitudes'])[0])
fig.add_axes(self.axes[0])
self.axes[0].axis["left"].label.set_color(self.plots[0].get_color())
self.axes[0].tick_params(axis='y', color=self.plots[0].get_color())
for row in range(5, len(DATA_LABELS)/2):
if row % 2 == 0:
side = "left"
offset = -1
else:
side = "right"
offset = 1
self.axes.append(self.axes[0].twinx())
self.axes[row-4].axis["right"].set_visible(False)
new_fixed_axis = self.axes[row-4].get_grid_helper().new_fixed_axis
self.axes[row-4].axis[side] = new_fixed_axis(loc=side, axes=self.axes[row-4],
offset=(offset*(60*((row-5)%2+(row-5)/2)), 0))
self.axes[row-4].axis[side].label.set_visible(True)
self.axes[row-4].axis[side].major_ticklabels.set_ha(side)
self.axes[row-4].axis[side].set_label(DATA_LABELS[2*row+1])
self.plots.append(self.axes[row-4].plot(aprs_daemon.LIVE_DATA['timestamps'],
aprs_daemon.LIVE_DATA[DATA_LABELS[2*row]])[0])
self.axes[row-4].axis[side].label.set_color(self.plots[row-4].get_color())
self.axes[row-4].set_aspect('auto', 'datalim')
self.axes[row-4].tick_params(axis='y',
colors=self.plots[row-4].get_color())
plt.subplots_adjust(bottom=0.3, left=0.20, right=0.8, top=0.85)
fig.tight_layout()
self.canvas.setParent(plotframe)
self.canvas.setStyleSheet("background-color: rgb(255, 0, 255);")
self.canvas.draw()
plotlayout.addWidget(self.canvas)
return plotframe
示例13: plot_cummulative_distance
def plot_cummulative_distance(self, i, j, fixed):
# i,j is grid id
# fixed is table of (theta, starting position)
delta_d_alpha = []
for elem in self.all_data:
if elem.info["angle"] == fixed["angle"]:
if elem.info["starting_point"] == fixed["starting_point"]:
delta_d_alpha.append([elem.grid[i][j][2],
elem.info["distance"],
elem.get_apical_angle(i,j)])
delta_d_alpha.sort(key=lambda x:x[1])
splitted = zip(*delta_d_alpha)
host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.75)
par1 = host.twinx()
host.set_xlabel("Distance")
host.set_ylabel("Delta")
par1.set_ylabel("Apical Angle")
p1, = host.plot(splitted[1], splitted[0], label="Delta")
p2, = par1.plot(splitted[1], splitted[2], label="Distance")
host.legend()
host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
plt.draw()
plt.show()
示例14: DrawLines
def DrawLines(xlists, ylists, ylabels):
line_count = len(ylists)
ymin = min([min(ylist) for ylist in ylists])
ymax = max([max(ylist) for ylist in ylists])
diff = ymax-ymin
ymin = ymin - 0.1*diff
ymax = ymax + 0.1*diff
clf()
host = host_subplot(111, axes_class=AA.Axes)
pyplot.subplots_adjust(right=(0.9-0.05*line_count))
host.set_xlabel('time')
host.set_ylabel(ylabels[0])
host.set_ylim(ymin, ymax)
p1, = host.plot(xlists[0], ylists[0], label=ylabels[0])
host.axis['left'].label.set_color(p1.get_color())
for i in range(1, line_count):
offset = 60*i
par = host.twinx()
new_fixed_axis = par.get_grid_helper().new_fixed_axis
par.axis["right"] = new_fixed_axis(loc="right", axes=par, offset=(offset, 0))
par.axis['right'].toggle(all=True)
par.set_ylabel(ylabels[i])
p, = par.plot(xlists[i], ylists[i], label = ylabels[i])
par.set_ylim(ymin, ymax)
par.axis['right'].label.set_color(p.get_color())
host.legend()
pyplot.draw()
pyplot.show()
示例15: __init__
def __init__(self, data, labels, colors=None):
self.data = data
host = host_subplot(111, axes_class=AA.Axes)
#plt.subplots_adjust(right=0.75)
plt.gca().set_frame_on(False)
host.set_frame_on(False)
xticks = np.arange(data.shape[1])
host.set_xticks(xticks)
host.set_xticklabels(labels)
host.yaxis.set_visible(False)
host.tick_params(axis='x', length=0)
host.axis['top'].set_visible(False)
host.axis['right'].set_visible(False)
host.set_ylim(np.min(data[:, 0]) - 0.1, np.max(data[:, 0]) + 0.1)
axes = [host]
for i in range(1, data.shape[1]):
ax = host.twinx()
ax.set_ylim(np.min(data[:, i]), np.max(data[:, i]))
ax.axis["right"] = ax.new_floating_axis(1, value=i)
ax.axis["right"].set_axis_direction("left")
axes.append(ax)
else:
ax.axis["right"].set_axis_direction("right")
self.axes = axes
self.colors = colors