本文整理汇总了Python中matplotlib.pyplot.autoscale函数的典型用法代码示例。如果您正苦于以下问题:Python autoscale函数的具体用法?Python autoscale怎么用?Python autoscale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了autoscale函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_k_walls
def plot_k_walls(k_walls, plot_range=None,
plot_data_points=False,):
"""
Plot K-walls for debugging purpose.
"""
pyplot.figure()
pyplot.axes().set_aspect('equal')
for k_wall in k_walls:
xs = k_wall.get_xs()
ys = k_wall.get_ys()
pyplot.plot(xs, ys, '-', label=k_wall.identifier)
if(plot_data_points == True):
pyplot.plot(xs, ys, 'o', color='k', markersize=4)
if plot_range is None:
pyplot.autoscale(enable=True, axis='both', tight=None)
else:
[[x_min, x_max], [y_min, y_max]] = plot_range
pyplot.xlim(x_min, x_max)
pyplot.ylim(y_min, y_max)
mpldatacursor.datacursor(
formatter='{label}'.format,
hover=True,
)
pyplot.show()
示例2: imshow_active_cells
def imshow_active_cells(grid, values, var_name=None, var_units=None,
grid_units=(None, None), symmetric_cbar=False,
cmap='pink'):
"""
.. deprecated:: 0.6
Use :meth:`imshow_active_cell_grid`, above, instead.
"""
data = values.view()
data.shape = (grid.shape[0]-2, grid.shape[1]-2)
y = np.arange(data.shape[0]) - grid.dx * .5
x = np.arange(data.shape[1]) - grid.dx * .5
if symmetric_cbar:
(var_min, var_max) = (data.min(), data.max())
limit = max(abs(var_min), abs(var_max))
limits = (-limit, limit)
else:
limits = (None, None)
plt.pcolormesh(x, y, data, vmin=limits[0], vmax=limits[1], cmap=cmap)
plt.gca().set_aspect(1.)
plt.autoscale(tight=True)
plt.colorbar()
plt.xlabel('X (%s)' % grid_units[1])
plt.ylabel('Y (%s)' % grid_units[0])
if var_name is not None:
plt.title('%s (%s)' % (var_name, var_units))
plt.show()
示例3: plotSpectogramF0Segments
def plotSpectogramF0Segments(x, fs, w, N, H, f0, segments):
"""
Code for plotting the f0 contour on top of the spectrogram
"""
# frequency range to plot
maxplotfreq = 1000.0
fontSize = 16
fig = plt.figure()
ax = fig.add_subplot(111)
mX, pX = stft.stftAnal(x, fs, w, N, H) #using same params as used for analysis
mX = np.transpose(mX[:,:int(N*(maxplotfreq/fs))+1])
timeStamps = np.arange(mX.shape[1])*H/float(fs)
binFreqs = np.arange(mX.shape[0])*fs/float(N)
plt.pcolormesh(timeStamps, binFreqs, mX)
plt.plot(timeStamps, f0, color = 'k', linewidth=5)
for ii in range(segments.shape[0]):
plt.plot(timeStamps[segments[ii,0]:segments[ii,1]], f0[segments[ii,0]:segments[ii,1]], color = '#A9E2F3', linewidth=1.5)
plt.autoscale(tight=True)
plt.ylabel('Frequency (Hz)', fontsize = fontSize)
plt.xlabel('Time (s)', fontsize = fontSize)
plt.legend(('f0','segments'))
xLim = ax.get_xlim()
yLim = ax.get_ylim()
ax.set_aspect((xLim[1]-xLim[0])/(2.0*(yLim[1]-yLim[0])))
plt.autoscale(tight=True)
plt.show()
示例4: plot_different_versions
def plot_different_versions(repo_name, pre_fetch_size, distance_to_fetch,
fig_name=None):
"""Sample plot of several different repos."""
x = range(100)
legend = []
fig, ax = plt.subplots()
for version in version_color:
csv_reader = _file_to_csv(
version=version, repo_name=repo_name,
pre_fetch_size=pre_fetch_size, distance_to_fetch=distance_to_fetch)
y = get_column(csv_reader, 'hit_rate')
if y is not None:
plt.plot(x, y, color=version_color[version])
line = mlines.Line2D(
[], [],
label=version, color=version_color[version], linewidth=2)
legend.append(line)
plt.title('Different version outputs of %s.git' % (repo_name,),
y=1.02)
plt.legend(handles=legend, loc=4)
plt.ylabel('hit rate')
plt.xlabel('cache size (%)')
legend_text = 'pfs = %s, dtf = %s\ncommit_num = %s' % (
pre_fetch_size, distance_to_fetch, REPO_DATA[repo_name]['commit_num'])
text(0.55, 0.07, legend_text, ha='center', va='center',
transform=ax.transAxes, multialignment='left',
bbox=dict(alpha=1.0, boxstyle='square', facecolor='white'))
plt.grid(True)
plt.autoscale(False)
plt.show()
示例5: draw_methods
def draw_methods(argmts,da_method):
methods,ys,yerrs,x,lookfor_pair = argmts
fig, ax = plt.subplots(figsize=(12,8))
index = np.arange(len(x))
markers = ['.','x']*(len(methods)/2)
i = 0
# print index,[len(y) for y in ys]
for y in ys: #yerr=yerrs[i]
plt.errorbar(index,y,marker= markers[i],alpha=opacity,label=convert(methods[i]),mew=3,linewidth=3.0,markersize=10)
i += 1
plt.xticks(index,x)
plt.title(lookfor_pair+': '+da_method,size=22)
plt.xlabel('$\\lambda$',size=22)
plt.ylabel('Accuracy',size=22)
# bottom box
# box = ax.get_position()
# ax.set_position([box.x0, box.y0 + box.height * 0.1,box.width, box.height * 0.9])
# ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.1),
# fancybox=True, shadow=True, ncol=5)
# plt.show()
plt.autoscale()
plt.ylim([57,90])
plt.savefig('%s:%s-acc.png'%(lookfor_pair,da_method))
pass
示例6: create_2_plots_v
def create_2_plots_v(mic1, mic2, title1, title2, xlabel1, ylabel1, xlabel2, ylabel2, colormap):
fig, axes = plt.subplots(2, sharex=True)
mic_array = array(mic1)
dimensions = mic_array.shape
nx = dimensions[0]
ny = dimensions[1]
axes[0].imshow(mic1, extent=(0, nx, ny, 0),cmap=cm.get_cmap(colormap))
axes[0].set_title(title1)
axes[0].set_xlabel(xlabel1)
axes[0].set_ylabel(ylabel1)
axes[0].set_ylim([0,ny])
mic_array = array(mic2)
dimensions = mic_array.shape
nx = dimensions[0]
ny = dimensions[1]
print(nx, ny)
axes[1].imshow(mic2, extent=(0, nx, ny, 0),cmap=cm.get_cmap(colormap))
axes[1].set_title(title2)
axes[1].set_xlabel(xlabel2)
axes[1].set_ylabel(ylabel2)
axes[1].set_ylim([0,ny])
plt.axis('tight')
plt.autoscale(enable=True, axis='y', tight=True)
plt.show()
示例7: plot_layer
def plot_layer(self, layer):
layer = {k: v for k, v in layer.iteritems() if k in self.VALID_AES}
layer.update(self.manual_aes)
x = layer.pop('x')
if 'weight' not in layer:
counts = pd.value_counts(x)
labels = counts.index.tolist()
weights = counts.tolist()
else:
weights = layer.pop('weight')
if not isinstance(x[0], Timestamp):
labels = x
else:
df = pd.DataFrame({'weights':weights, 'timepoint': pd.to_datetime(x)})
df = df.set_index('timepoint')
ts = pd.TimeSeries(df.weights, index=df.index)
ts = ts.resample('W', how='sum')
ts = ts.fillna(0)
weights = ts.values.tolist()
labels = ts.index.to_pydatetime().tolist()
indentation = np.arange(len(labels)) + 0.2
width = 0.35
idx = np.argsort(labels)
labels, weights = np.array(labels)[idx], np.array(weights)[idx]
labels = sorted(labels)
plt.bar(indentation, weights, width, **layer)
plt.autoscale()
return [
{"function": "set_xticks", "args": [indentation+width/2]},
{"function": "set_xticklabels", "args": [labels]}
]
示例8: plot_compare_paths
def plot_compare_paths(pos_rigid, pos_inertial):
fig, ax = plt.subplots(1)
plt.plot(*zip(*pos_rigid), color='r', label='rigid', alpha=0.8)
plt.plot(*zip(*pos_inertial), color='g', label='inertial', alpha=0.8)
ax.legend(loc='upper right')
p1 = Circle(pos_rigid[0], radius=ax.get_ylim()[0] / 50., fill=True, color='r', alpha=0.8)
p2 = Circle(pos_inertial[0], radius=ax.get_ylim()[0] / 50., fill=True, color='g', alpha=0.8)
for p in [p1, p2]:
ax.add_patch(p)
plt.title("Both paths")
plt.axis('equal')
plt.xlabel('x')
plt.ylabel('y')
plt.autoscale()
if Plotter.live is True:
plt.show()
else:
plt.savefig('plot/path compare.png')
plt.close()
示例9: plot_measurements
def plot_measurements(xs, ys=None, color='k', lw=2, label='Measurements',
lines=False, **kwargs):
""" Helper function to give a consistant way to display
measurements in the book.
"""
plt.autoscale(tight=True)
'''if ys is not None:
plt.scatter(xs, ys, marker=marker, c=c, s=s,
label=label, alpha=alpha)
if connect:
plt.plot(xs, ys, c=c, lw=1, alpha=alpha)
else:
plt.scatter(range(len(xs)), xs, marker=marker, c=c, s=s,
label=label, alpha=alpha)
if connect:
plt.plot(range(len(xs)), xs, lw=1, c=c, alpha=alpha)'''
if lines:
if ys is not None:
plt.plot(xs, ys, color=color, lw=lw, ls='--', label=label, **kwargs)
else:
plt.plot(xs, color=color, lw=lw, ls='--', label=label, **kwargs)
else:
if ys is not None:
plt.scatter(xs, ys, edgecolor=color, facecolor='none',
lw=2, label=label, **kwargs)
else:
plt.scatter(range(len(xs)), xs, edgecolor=color, facecolor='none',
lw=2, label=label, **kwargs)
示例10: output
def output(portfolio):
"""
Output
"""
printer={}
for key, value in portfolio.items():
X=[]
for subkey, subvalue in value.items():
X.append(subvalue)
std = np.std(X) #standard deviation
mean = np.mean(X) #average
printer[key]=std, mean
plt.figure()
plt.hist(X, 100, range=[-1,1])
plt.xlabel("The probability to win or lose")
plt.title('thk301 - The histogram of the result $%s' %key)
plt.ylabel('The number of trials')
plt.autoscale(False, tight=True)
if key==1000:
plt.savefig('histogram_1000_pos.png')
elif key==100:
plt.savefig('histogram_0100_pos.png')
elif key==10:
plt.savefig('histogram_0010_pos.png')
elif key==1:
plt.savefig('histogram_0001_pos.png')
else:
plt.savefig('histogram_%s_pos.png' %key)
file = open("results.txt", "w") #save the "printer" dictionary
for key, value in printer.items():
file.write( "$%d\n" %key)
file.write("Standard Deviation:%f\n"%value[0])
file.write( "Mean:%f\n\n"%value[1])
示例11: _fractions_grid
def _fractions_grid(data, dom_x, dom_y, title, case_id, plot_dir):
'''
Plot diagnostic plots of fraction variables
'''
# ---------------------------------------------------------------- #
# Plot Fractions
pfname = _make_filename(title, case_id, plot_dir)
mask = data <= 0.0
data = np.ma.array(data, mask=mask)
cmap = matplotlib.cm.cool
cmap.set_bad(color='w')
fig = plt.figure()
plt.pcolormesh(data, cmap=cmap)
plt.autoscale(tight=True)
plt.axis('tight')
plt.colorbar()
plt.title(title)
plt.xlabel('x')
plt.ylabel('y')
plt.ylim([0, dom_y.shape[0]])
plt.xlim([0, dom_x.shape[1]])
fig.savefig(pfname)
plt.close()
# ---------------------------------------------------------------- #
return pfname
示例12: _show_order_info
def _show_order_info(problem, mesh_sizes, stabilization):
"""Performs consistency check for the given problem/method combination and
show some information about it. Useful for debugging.
"""
errors, hmax = _compute_errors(problem, mesh_sizes, stabilization)
order = helpers.compute_numerical_order_of_convergence(hmax, errors)
# Print the data
print()
print("hmax ||u - u_h|| conv. order")
print("{:e} {:e}".format(hmax[0], errors[0]))
for j in range(len(errors) - 1):
print(32 * " " + "{:2.5f}".format(order[j]))
print("{:e} {:e}".format(hmax[j + 1], errors[j + 1]))
# Plot the actual data.
plt.loglog(hmax, errors, "-o")
# Compare with order curves.
plt.autoscale(False)
e0 = errors[0]
for order in range(4):
plt.loglog(
[hmax[0], hmax[-1]], [e0, e0 * (hmax[-1] / hmax[0]) ** order], color="0.7"
)
plt.xlabel("hmax")
plt.ylabel("||u-u_h||")
plt.show()
return
示例13: plot_m
def plot_m(mesh, npy, comp='x', based=None):
if comp == 'x':
cmpi = 0
elif comp == 'y':
cmpi = 1
elif comp == 'z':
cmpi = 2
else:
raise Exception('Seems the given component is wrong!!!')
data = np.load(npy)
if based is not None:
data = data - based
data.shape = (-1, 3)
m = data[:,cmpi]
nx = mesh.nx
ny = mesh.ny
nz = mesh.nz
m.shape = (nz, ny, nx)
m2 = m[0,:,:]
fig = plt.figure()
# norm=color.Normalize(-1,1)
plt.imshow(m2, aspect=1, cmap=plt.cm.coolwarm,
origin='lower', interpolation='none')
plt.autoscale(False)
plt.xticks([])
plt.yticks([])
fig.savefig('%s_%s.png' % (npy[:-4], comp))
示例14: quick_plt_loc
def quick_plt_loc(robot, map):
plt.imshow(map, cmap='gray')
plt.autoscale(False)
a = np.asarray(robot.past_loc)
plt.scatter(a[:,1], a[:,0])
plt.plot(a[:,1], a[:,0])
plt.show()
示例15: generate_graph
def generate_graph():
with open('../../data/netinterface.dat', 'r') as csvfile:
data_source = csv.reader(csvfile, delimiter=' ', skipinitialspace=True)
for row in data_source:
# [0] column is a time column
# Convert to datetime data type
a = datetime.strptime((row[0]),'%H:%M:%S')
x.append((a))
# The remaining columns contain data
r_kb.append(row[4])
s_kb.append(row[5])
# Plot lines
plt.plot(x,r_kb, label='Kilobytes received per second', color='#009973', antialiased=True)
plt.plot(x,s_kb, label='Kilobytes sent per second', color='#b3b300', antialiased=True)
# Graph properties
plt.xlabel('Time',fontstyle='italic')
plt.ylabel('Kb/s',fontstyle='italic')
plt.title('Network statistics')
plt.grid(linewidth=0.4, antialiased=True)
plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.18), ncol=2, fancybox=True, shadow=True)
plt.autoscale(True)
# Graph saved to PNG file
plt.savefig('../../graphs/netinterface.png', bbox_inches='tight')