本文整理汇总了Python中pylab.subplot方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.subplot方法的具体用法?Python pylab.subplot怎么用?Python pylab.subplot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.subplot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_hits
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_hits(filename_fil, filename_dat):
""" Plot the hits in a .dat file. """
table = find_event.read_dat(filename_dat)
print(table)
plt.figure(figsize=(10, 8))
N_hit = len(table)
if N_hit > 10:
print("Warning: More than 10 hits found. Only plotting first 10")
N_hit = 10
for ii in range(N_hit):
plt.subplot(N_hit, 1, ii+1)
plot_event.plot_hit(filename_fil, filename_dat, ii)
plt.tight_layout()
plt.savefig(filename_dat.replace('.dat', '.png'))
plt.show()
示例2: plot_wt_layout
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_wt_layout(wt_layout, borders=None, depth=None):
fig = plt.figure(figsize=(6,6), dpi=2000)
fs = 14
ax = plt.subplot(111)
if depth is not None:
N = 100
X, Y = plt.meshgrid(plt.linspace(depth[:,0].min(), depth[:,0].max(), N),
plt.linspace(depth[:,1].min(), depth[:,1].max(), N))
Z = plt.griddata(depth[:,0],depth[:,1],depth[:,2],X,Y, interp='linear')
plt.contourf(X,Y,Z, label='depth [m]')
plt.colorbar().set_label('water depth [m]')
#ax.plot(wt_layout.wt_positions[:,0], wt_layout.wt_positions[:,1], 'or', label='baseline position')
ax.scatter(wt_layout.wt_positions[:,0], wt_layout.wt_positions[:,1], wt_layout._wt_list('rotor_diameter'), label='baseline position')
if borders is not None:
ax.plot(borders[:,0], borders[:,1], 'r--', label='border')
ax.set_xlabel('x [m]');
ax.set_ylabel('y [m]')
ax.axis('equal');
ax.legend(loc='lower left')
示例3: plot_wind_rose
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_wind_rose(wind_rose):
fig = plt.figure(figsize=(12,5), dpi=1000)
# Plotting the wind statistics
ax1 = plt.subplot(121, polar=True)
w = 2.*np.pi/len(wind_rose.frequency)
b = ax1.bar(np.pi/2.0-np.array(wind_rose.wind_directions)/180.*np.pi - w/2.0,
np.array(wind_rose.frequency)*100, width=w)
# Trick to set the right axes (by default it's not oriented as we are used to in the WE community)
mirror = lambda d: 90.0 - d if d < 90.0 else 360.0 + (90.0 - d)
ax1.set_xticklabels([u'%d\xb0'%(mirror(d)) for d in linspace(0.0, 360.0,9)[:-1]]);
ax1.set_title('Wind direction frequency');
# Plotting the Weibull A parameter
ax2 = plt.subplot(122, polar=True)
b = ax2.bar(np.pi/2.0-np.array(wind_rose.wind_directions)/180.*np.pi - w/2.0,
np.array(wind_rose.A), width=w)
ax2.set_xticklabels([u'%d\xb0'%(mirror(d)) for d in linspace(0.0, 360.0,9)[:-1]]);
ax2.set_title('Weibull A parameter per wind direction sectors');
示例4: plot
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot(self, overlay_alpha=0.5):
import pylab as pl
rows = int(sqrt(self.layers()))
cols = int(ceil(self.layers()/rows))
for i in range(rows*cols):
pl.subplot(rows, cols, i+1)
pl.axis('off')
if i >= self.layers():
continue
pl.title('{}({})'.format(self.labels[i], i))
pl.imshow(self.image)
pl.imshow(colorize(self.features[i].argmax(0),
colors=np.array([[0, 0, 255],
[0, 255, 255],
[255, 255, 0],
[255, 0, 0]])),
alpha=overlay_alpha)
示例5: __init__
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def __init__(self, norder = 2):
"""Initializes the class when returning an instance. Pass it the polynomial order. It will
set up two figure windows, one for the graph the other for the coefficent interface. It will then initialize
the coefficients to zero and plot the (not so interesting) polynomial."""
self.order = norder
self.c = M.zeros(self.order,'f')
self.ax = [None]*(self.order-1)#M.zeros(self.order-1,'i') #Coefficent axes
self.ffig = M.figure() #The first figure window has the plot
self.replotf()
self.cfig = M.figure() #The second figure window has the
row = M.ceil(M.sqrt(self.order-1))
for n in xrange(self.order-1):
self.ax[n] = M.subplot(row, row, n+1)
M.setp(self.ax[n],'label', n)
M.plot([0],[0],'.')
M.axis([-1, 1, -1, 1]);
self.replotc()
M.connect('button_press_event', self.click_event)
示例6: on_epoch_end
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def on_epoch_end(self, epoch, logs={}):
self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch)))
self.show_edit_distance(256)
word_batch = next(self.text_img_gen)[0]
res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words])
if word_batch['the_input'][0].shape[0] < 256:
cols = 2
else:
cols = 1
for i in range(self.num_display_words):
pylab.subplot(self.num_display_words // cols, cols, i + 1)
if K.image_data_format() == 'channels_first':
the_input = word_batch['the_input'][i, 0, :, :]
else:
the_input = word_batch['the_input'][i, :, :, 0]
pylab.imshow(the_input.T, cmap='Greys_r')
pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i]))
fig = pylab.gcf()
fig.set_size_inches(10, 13)
pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch)))
pylab.close()
示例7: plot
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot(t, plots, shot_ind):
n = len(plots)
for i in range(0,n):
label, data = plots[i]
plt = py.subplot(n, 1, i+1)
plt.tick_params(labelsize=8)
py.grid()
py.xlim([t[0], t[-1]])
py.ylabel(label)
py.plot(t, data, 'k-')
py.scatter(t[shot_ind], data[shot_ind], marker='*', c='g')
py.xlabel("Time")
py.show()
py.close()
示例8: draw_graph_row
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def draw_graph_row(graphs,
index=0,
contract=True,
n_graphs_per_line=5,
size=4,
xlim=None,
ylim=None,
**args):
"""draw_graph_row."""
dim = len(graphs)
size_y = size
size_x = size * n_graphs_per_line * args.get('size_x_to_y_ratio', 1)
plt.figure(figsize=(size_x, size_y))
if xlim is not None:
plt.xlim(xlim)
plt.ylim(ylim)
else:
plt.xlim(xmax=3)
for i in range(dim):
plt.subplot(1, n_graphs_per_line, i + 1)
graph = graphs[i]
draw_graph(graph,
size=None,
pos=graph.graph.get('pos_dict', None),
**args)
if args.get('file_name', None) is None:
plt.show()
else:
row_file_name = '%d_' % (index) + args['file_name']
plt.savefig(row_file_name,
bbox_inches='tight',
transparent=True,
pad_inches=0)
plt.close()
示例9: plot_confusion_matrices
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_confusion_matrices(y_true, y_pred, size=12):
"""plot_confusion_matrices."""
plt.figure(figsize=(size, size))
plt.subplot(121)
plot_confusion_matrix(y_true, y_pred, normalize=False)
plt.subplot(122)
plot_confusion_matrix(y_true, y_pred, normalize=True)
plt.tight_layout(w_pad=5)
plt.show()
示例10: plot_aucs
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_aucs(y_true, y_score, size=12):
"""plot_confusion_matrices."""
plt.figure(figsize=(size, size / 2.0))
plt.subplot(121, aspect='equal')
plot_roc_curve(y_true, y_score)
plt.subplot(122, aspect='equal')
plot_precision_recall_curve(y_true, y_score)
plt.tight_layout(w_pad=5)
plt.show()
示例11: solid_plot
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def solid_plot():
# reference values, see
sref=0.0924102
wref=0.000170152
# List of the element types to process (text files)
eltyps=["C3D8",
"C3D8R",
"C3D8I",
"C3D20",
"C3D20R",
"C3D4",
"C3D10"]
pylab.figure(figsize=(10, 5.0), dpi=100)
pylab.subplot(1,2,1)
pylab.title("Stress")
# pylab.hold(True) # deprecated
for elty in eltyps:
data = numpy.genfromtxt(elty+".txt")
pylab.plot(data[:,1],data[:,2]/sref,"o-")
pylab.xscale("log")
pylab.xlabel('Number of nodes')
pylab.ylabel('Max $\sigma / \sigma_{\mathrm{ref}}$')
pylab.grid(True)
pylab.subplot(1,2,2)
pylab.title("Displacement")
# pylab.hold(True) # deprecated
for elty in eltyps:
data = numpy.genfromtxt(elty+".txt")
pylab.plot(data[:,1],data[:,3]/wref,"o-")
pylab.xscale("log")
pylab.xlabel('Number of nodes')
pylab.ylabel('Max $u / u_{\mathrm{ref}}$')
pylab.ylim([0,1.2])
pylab.grid(True)
pylab.legend(eltyps,loc="lower right")
pylab.tight_layout()
pylab.savefig("solid.svg",format="svg")
# pylab.show()
# Move new files and folders to 'Refs'
示例12: explorer
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def explorer():
for c in range(0, len(captchas), 77):
e = del_line(captchas[c])
pl.figure(c)
for i, p in enumerate(split_pic(e)):
pl.subplot(221+i)
char = e[:, p[0]:p[1]]
y1, y2 = split_y(char)
pl.imshow(regularize(char[y1:y2, :]), cmap=pl.cm.Greys)
pl.show()
if raw_input() == 'q':
pl.close('all')
break
示例13: plot_parameter_uncertainty
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_parameter_uncertainty(posterior_results,evaluation, fig_name='Posterior_parameter_uncertainty.png'):
import pylab as plt
simulation_fields = get_simulation_fields(posterior_results)
fig= plt.figure(figsize=(16,9))
for i in range(len(evaluation)):
if evaluation[i] == -9999:
evaluation[i] = np.nan
ax = plt.subplot(1,1,1)
q5,q95=[],[]
for field in simulation_fields:
q5.append(np.percentile(list(posterior_results[field]),2.5))
q95.append(np.percentile(list(posterior_results[field]),97.5))
ax.plot(q5,color='dimgrey',linestyle='solid')
ax.plot(q95,color='dimgrey',linestyle='solid')
ax.fill_between(np.arange(0,len(q5),1),list(q5),list(q95),facecolor='dimgrey',zorder=0,
linewidth=0,label='parameter uncertainty')
ax.plot(evaluation,'r.',markersize=1, label='Observation data')
bestindex,bestobjf = get_maxlikeindex(posterior_results,verbose=False)
plt.plot(list(posterior_results[simulation_fields][bestindex][0]),'b-',label='Obj='+str(round(bestobjf,2)))
plt.xlabel('Number of Observation Points')
plt.ylabel ('Simulated value')
plt.legend(loc='upper right')
fig.savefig(fig_name,dpi=300)
text='A plot of the parameter uncertainty has been saved as '+fig_name
print(text)
示例14: plot_parametertrace_algorithms
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_parametertrace_algorithms(result_lists, algorithmnames, spot_setup,
fig_name='parametertrace_algorithms.png'):
"""Example Plot as seen in the SPOTPY Documentation"""
import matplotlib.pyplot as plt
font = {'family' : 'calibri',
'weight' : 'normal',
'size' : 20}
plt.rc('font', **font)
fig=plt.figure(figsize=(17,5))
subplots=len(result_lists)
parameter = spotpy.parameter.get_parameters_array(spot_setup)
rows=len(parameter['name'])
for j in range(rows):
for i in range(subplots):
ax = plt.subplot(rows,subplots,i+1+j*subplots)
data=result_lists[i]['par'+parameter['name'][j]]
ax.plot(data,'b-')
if i==0:
ax.set_ylabel(parameter['name'][j])
rep = len(data)
if i>0:
ax.yaxis.set_ticks([])
if j==rows-1:
ax.set_xlabel(algorithmnames[i-subplots])
else:
ax.xaxis.set_ticks([])
ax.plot([1]*rep,'r--')
ax.set_xlim(0,rep)
ax.set_ylim(parameter['minbound'][j],parameter['maxbound'][j])
#plt.tight_layout()
fig.savefig(fig_name, bbox_inches='tight')
示例15: plot_parametertrace
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import subplot [as 别名]
def plot_parametertrace(results,parameternames=None,fig_name='Parameter_trace.png'):
"""
Get a plot with all values of a given parameter in your result array.
The plot will be saved as a .png file.
:results: Expects an numpy array which should of an index "like" for objectivefunctions
:type: array
:parameternames: A List of Strings with parameternames. A line object will be drawn for each String in the List.
:type: list
:return: Plot of all traces of the given parameternames.
:rtype: figure
"""
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(16,9))
if not parameternames:
parameternames=get_parameternames(results)
names=''
i=1
for name in parameternames:
ax = plt.subplot(len(parameternames),1,i)
ax.plot(results['par'+name],label=name)
names+=name+'_'
ax.set_ylabel(name)
if i==len(parameternames):
ax.set_xlabel('Repetitions')
if i==1:
ax.set_title('Parametertrace')
ax.legend()
i+=1
fig.savefig(fig_name)
text='The figure as been saved as "'+fig_name
print(text)