本文整理汇总了Python中matplotlib.pyplot.axis函数的典型用法代码示例。如果您正苦于以下问题:Python axis函数的具体用法?Python axis怎么用?Python axis使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了axis函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_prop
def test_prop(self):
N = 800.0
V = linspace(5.0,51.0,50)
rho = 1.2255
beta = 45.0
J = list()
CT = list()
CP = list()
effy = list()
for v in V:
data = self.analyze_prop(beta,N,v,rho)
J.append(data[2])
CT.append(data[3])
CP.append(data[4])
effy.append(data[5])
plt.figure(1)
plt.grid(True)
plt.hold(True)
plt.plot(J,CT,'o-')
plt.xlabel('J')
plt.plot(J,CP,'ro-')
plt.axis([0,2.5,0,0.15])
plt.figure(2)
plt.plot(J,effy,'gs-')
plt.hold(True)
plt.grid(True)
plt.axis([0,2.5,0,1.0])
plt.xlabel('advance ratio')
plt.ylabel('efficiency')
plt.show()
开发者ID:maximtyan,项目名称:actools,代码行数:30,代码来源:propeller.py
示例2: do_plot
def do_plot(mode, content, wide):
global style
style.apply(mode, content, wide)
data = np.load("data/prr_AsAu_%s%s.npz"%(content, wide))
AU, TAU = np.meshgrid(-data["Au_range_dB"], data["tau_range"])
Zu = data["PRR_U"]
Zs = data["PRR_S"]
assert TAU.shape == AU.shape == Zu.shape, "The inputs TAU, AU, PRR_U must have the same shape for plotting!"
plt.clf()
if mode in ("sync",):
# Plot the inverse power ratio, sync signal is stronger for positive ratios
CSf = plt.contourf(TAU, AU, Zs, levels=(0.0, 0.2, 0.4, 0.6, 0.8, 0.9, 1.0), colors=("1.0", "0.75", "0.5", "0.25", "0.15", "0.0"), origin="lower")
CS2 = plt.contour(CSf, colors = ("r",)*5+("w",), linewidths=(0.75,)*5+(1.0,), origin="lower", hold="on")
else:
CSf = plt.contourf(TAU, AU, Zs, levels=(0.0, 0.2, 0.4, 0.6, 0.8, 0.9, 1.0), colors=("1.0", "0.75", "0.5", "0.25", "0.15", "0.0"), origin="lower")
CS2f = plt.contour(CSf, levels=(0.0, 0.2, 0.4, 0.6, 0.8, 1.0), colors=4*("r",)+("w",), linewidths=(0.75,)*4+(1.0,), origin="lower", hold="on")
#CS2f = plt.contour(TAU, -AU, Zu, levels=(0.9, 1.0), colors=("0.0",), linewidths=(1.0,), origin="lower", hold="on")
if content in ("unif",):
CSu = plt.contourf(TAU, AU, Zu, levels=(0.2, 1.0), hatches=("////",), colors=("0.75",), origin="lower")
CS2 = plt.contour(CSu, levels=(0.2,), colors = ("r",), linewidths=(1.0,), origin="lower", hold="on")
style.annotate(mode, content, wide)
plt.axis([data["tau_range"][0], data["tau_range"][-1], -data["Au_range_dB"][-1], -data["Au_range_dB"][0]])
plt.ylabel(r"Signal power ratio ($\mathrm{SIR}$)", labelpad=2)
plt.xlabel(r"Time offset $\tau$ ($/T$)", labelpad=2)
plt.savefig("pdf/prrc2_%s_%s%s_z.pdf"%(mode, content, wide))
开发者ID:cnodadiaz,项目名称:collision,代码行数:34,代码来源:plot_ber_contour_AsAu.py
示例3: showOverlapTable
def showOverlapTable(modes_x, modes_y, **kwargs):
"""Show overlap table using :func:`~matplotlib.pyplot.pcolor`. *modes_x*
and *modes_y* are sets of normal modes, and correspond to x and y axes of
the plot. Note that mode indices are incremented by 1. List of modes
is assumed to contain a set of contiguous modes from the same model.
Default arguments for :func:`~matplotlib.pyplot.pcolor`:
* ``cmap=plt.cm.jet``
* ``norm=plt.normalize(0, 1)``"""
import matplotlib.pyplot as plt
overlap = abs(calcOverlap(modes_y, modes_x))
if overlap.ndim == 0:
overlap = np.array([[overlap]])
elif overlap.ndim == 1:
overlap = overlap.reshape((modes_y.numModes(), modes_x.numModes()))
cmap = kwargs.pop('cmap', plt.cm.jet)
norm = kwargs.pop('norm', plt.normalize(0, 1))
show = (plt.pcolor(overlap, cmap=cmap, norm=norm, **kwargs),
plt.colorbar())
x_range = np.arange(1, modes_x.numModes() + 1)
plt.xticks(x_range-0.5, x_range)
plt.xlabel(str(modes_x))
y_range = np.arange(1, modes_y.numModes() + 1)
plt.yticks(y_range-0.5, y_range)
plt.ylabel(str(modes_y))
plt.axis([0, modes_x.numModes(), 0, modes_y.numModes()])
if SETTINGS['auto_show']:
showFigure()
return show
开发者ID:karolamik13,项目名称:ProDy,代码行数:33,代码来源:plotting.py
示例4: zplane
def zplane(self, title="", fontsize=18):
""" Display filter in the complex plane
Parameters
----------
"""
rb = self.z
ra = self.p
t = np.arange(0, 2 * np.pi + 0.1, 0.1)
plt.plot(np.cos(t), np.sin(t), "k")
plt.plot(np.real(ra), np.imag(ra), "x", color="r")
plt.plot(np.real(rb), np.imag(rb), "o", color="b")
M1 = -10000
M2 = -10000
if len(ra) > 0:
M1 = np.max([np.abs(np.real(ra)), np.abs(np.imag(ra))])
if len(rb) > 0:
M2 = np.max([np.abs(np.real(rb)), np.abs(np.imag(rb))])
M = 1.6 * max(1.2, M1, M2)
plt.axis([-M, M, -0.7 * M, 0.7 * M])
plt.title(title, fontsize=fontsize)
plt.show()
开发者ID:tattoxcm,项目名称:pylayers,代码行数:25,代码来源:DF.py
示例5: vis_detections
def vis_detections (im, class_name, dets, thresh=0.5):
"""Draw detected bounding boxes."""
inds = np.where(dets[:, -1] >= thresh)[0]
if len(inds) == 0:
return
im = im[:, :, (2, 1, 0)]
fig, ax = plt.subplots(figsize=(12, 12))
ax.imshow(im, aspect='equal')
for i in inds:
bbox = dets[i, :4]
score = dets[i, -1]
ax.add_patch(
plt.Rectangle((bbox[0], bbox[1]),
bbox[2] - bbox[0],
bbox[3] - bbox[1], fill=False,
edgecolor='red', linewidth=3.5)
)
ax.text(bbox[0], bbox[1] - 2,
'{:s} {:.3f}'.format(class_name, score),
bbox=dict(facecolor='blue', alpha=0.5),
fontsize=14, color='white')
ax.set_title(('{} detections with '
'p({} | box) >= {:.1f}').format(class_name, class_name,
thresh),
fontsize=14)
plt.axis('off')
plt.tight_layout()
plt.draw()
开发者ID:brentsony,项目名称:py-faster-rcnn,代码行数:31,代码来源:demo.py
示例6: influence_plot
def influence_plot(X, y_true, y_pred, **kwargs):
"""Produces an influence plot.
Parameters
----------
X : array
Design matrix.
y_true : array_like
Observed labels, either 0 or 1.
y_pred : array_like
Predicted probabilities, floats on [0, 1].
Notes
-----
.. plot:: pyplots/influence_plot.py
"""
r = pearson_residuals(y_true, y_pred)
leverages = pregibon_leverages(X, y_pred)
delta_X2 = case_deltas(r, leverages)
dbetas = pregibon_dbetas(r, leverages)
plt.scatter(y_pred, delta_X2, s=dbetas * 800, **kwargs)
__, __, y1, y2 = plt.axis()
plt.axis((0, 1, y1, y2))
plt.xlabel('Predicted Probability')
plt.ylabel(r'$\Delta \chi^2$')
plt.tight_layout()
开发者ID:grivescorbett,项目名称:verhulst,代码行数:31,代码来源:plots.py
示例7: render
def render(self, interval=50, **kwargs):
import matplotlib.cm as cm
import matplotlib.animation as animation
import matplotlib.pyplot as plt
p = self.plot_layout
_axs = []
for i in range(self.image_list[0].shape[2]):
plt.subplot(p[0], p[1], 1 + i)
# Hide the x and y labels
plt.axis('off')
_ax = plt.imshow(self.image_list[0][:, :, i], cmap=cm.Greys_r,
**kwargs)
_axs.append(_ax)
def init():
return _axs
def animate(j):
for k, _ax in enumerate(_axs):
_ax.set_data(self.image_list[j][:, :, k])
return _axs
self._ani = animation.FuncAnimation(self.figure, animate,
init_func=init,
frames=len(self.image_list),
interval=interval, blit=True)
return self
开发者ID:jacksoncsy,项目名称:menpo,代码行数:28,代码来源:viewmatplotlib.py
示例8: cplot
def cplot(data, limits=[None,None], CM = 'jet', fname='', ext='png'):
"""Make a color contour plot of data
Usage: cplot(data, limits=[None,None], fname='')
If no filename is specified a plot is displayed
File format is ext (default is png)
"""
SIZE = 12
DPI = 100
nx, ny = data.shape[0], data.shape[1]
data = data.reshape(nx,ny)
scale = SIZE/float(max(nx,ny))
plt.figure(figsize=(scale*nx, scale*ny+1.0))
plt.clf()
c = plt.imshow(np.transpose(data), cmap=CM)
plt.clim(limits)
plt.axis([0,nx,0,ny])
#cbar = plt.colorbar(c, ticks=np.arange(0.831,0.835,0.001), aspect = 20, orientation='vertical', shrink=0.72, extend='neither', spacing='proportional')
#cbar = plt.colorbar(c, aspect = 40, orientation='vertical', shrink=0.72, extend='neither', spacing='proportional')
#cbar = plt.colorbar(c, orientation='horizontal', shrink=1.0)
cbar = plt.colorbar(c, orientation='vertical', shrink=0.72, extend='neither', spacing='proportional')
cbar.ax.tick_params(labelsize=21,size=10)
#cbar.ax.yaxis.set_ticks_position('left')
#c.cmap.set_under(color='black')
if len(fname) == 0:
plt.show()
else:
plt.savefig(fname+'.'+ ext, format=ext, dpi=DPI, bbox_inches='tight', pad_inches=0.1)
plt.close()
开发者ID:viratupadhyay,项目名称:ida,代码行数:32,代码来源:ida.py
示例9: xplot
def xplot(data, limits=[None,None], fname='', func='max', label='',
loc='upper right', ext='png'):
"""Make an axial plot of a funtion of data
Usage: xplot(data, limits=[None,None], fname='', loc='upper left', ext='png')
Possible functions to plot are max, min, avg
If no filename is specified a plot is displayed
The special filename 'M' turns "hold" on (for multiplots)
File format is ext (default is png)
"""
nx,ny = data.shape[0],data.shape[1]
z = np.zeros([3,nx])
for x in range(nx):
z[0,x] = data[x,:].min()
z[1,x] = data[x,:].max()
z[2,x] = data[x,:].sum()/float(ny)
#plt.plot(z[0], label=label+' min')
#plt.plot(z[1], label=label+' max')
plt.plot(z[2], label=label+' avg')
if (fname == 'M'):
plt.hold=True
else:
plt.legend(loc=loc)
plt.axis([0,data.shape[0]-1,limits[0],limits[1]])
plt.hold=False
if len(fname) == 0:
plt.show()
else:
plt.savefig(fname+'-x.'+ext, format=ext)
plt.close()
开发者ID:viratupadhyay,项目名称:ida,代码行数:33,代码来源:ida.py
示例10: plot_residuals
def plot_residuals(turnstile_weather, predictions):
'''
Using the same methods that we used to plot a histogram of entries
per hour for our data, why don't you make a histogram of the residuals
(that is, the difference between the original hourly entry data and the predicted values).
Based on this residual histogram, do you have any insight into how our model
performed? Reading a bit on this webpage might be useful:
http://www.itl.nist.gov/div898/handbook/pri/section2/pri24.htm
'''
plt.figure()
residuals = (turnstile_weather['ENTRIESn_hourly'] - predictions)
residuals_mean = np.mean(residuals)
residuals_std = np.std(residuals)
residuals.hist(color='blue', bins=100, alpha=0.5)
the_axis = [-15000, 20000, 0, 40000]
plt.axis(the_axis)
plt.xlabel('Actual Hourly Entries - Predictions')
plt.ylabel('Freq')
plt.title('Linear Regression with Gradient Descent Residuals')
return plt, residuals_mean, residuals_std
开发者ID:dvdunne,项目名称:Training_Archive,代码行数:25,代码来源:plot_residuals.py
示例11: plot_fun
def plot_fun(self, x, y, x_min, x_max, y_min, y_max, style):
fig = plt.figure()
plt.axis([x_min, x_max, y_min, y_max])
ax = fig.add_subplot(1, 1, 1)
ax.plot(x, y, 'g')
ax.set_xscale('log')
plt.savefig('plot.png')
开发者ID:willyrv,项目名称:MS-PSMC_experiments,代码行数:7,代码来源:core.py
示例12: png
def png(self, start_timestamp, end_timestamp):
self.load(start_timestamp, end_timestamp)
plt.figure(figsize=(10, 7.52))
plt.rc("axes", labelsize=12, titlesize=14)
plt.rc("font", size=10)
plt.rc("legend", fontsize=7)
plt.rc("xtick", labelsize=8)
plt.rc("ytick", labelsize=8)
plt.axes([0.08, 0.08, 1 - 0.27, 1 - 0.15])
for plot in self.plots:
plt.plot(self.timestamps, self.plots[plot], self.series_fmt(plot), label=self.series_label(plot))
plt.axis("tight")
plt.gca().xaxis.set_major_formatter(
matplotlib.ticker.FuncFormatter(lambda x, pos=None: time.strftime("%H:%M\n%b %d", time.localtime(x)))
)
plt.gca().yaxis.set_major_formatter(
matplotlib.ticker.FuncFormatter(lambda x, pos=None: locale.format("%.*f", (0, x), True))
)
plt.grid(True)
plt.legend(loc=(1.003, 0))
plt.xlabel("Time/Date")
plt.title(
self.description()
+ "\n%s to %s"
% (
time.strftime("%H:%M %d-%b-%Y", time.localtime(start_timestamp)),
time.strftime("%H:%M %d-%b-%Y", time.localtime(end_timestamp)),
)
)
output_buffer = StringIO.StringIO()
plt.savefig(output_buffer, format="png")
return output_buffer.getvalue()
开发者ID:rbroemeling,项目名称:udplogger,代码行数:32,代码来源:Graphs.py
示例13: plothist
def plothist():
n_groups = 3
means_men = (42.3113658071, 39.7803247373, 67.335243553)
std_men = (1, 2, 3)
fig, ax = plt.subplots()
index = np.array([0.5,1.5,2.5])
bar_width = 0.4
opacity = 0.4
error_config = {'ecolor': '0'}
rects1 = plt.bar(index, means_men, bar_width,
alpha=opacity,
color='b',
error_kw=error_config)
plt.xlabel('Approach')
plt.ylabel('Accuracy')
plt.axis((0,3.4,0,100))
plt.title('Evaluation')
plt.xticks(index + bar_width/2, ('Bing Liu', 'AFINN', 'SentiWordNet'))
plt.legend()
plt.tight_layout()
# plt.show()
plt.savefig('foo.png')
开发者ID:abhinavchanda,项目名称:mood_india,代码行数:30,代码来源:tester.py
示例14: plot
def plot(i, pcanc, lr, pp, labelFlag, Y):
if len(str(i)) == 1:
fig = plt.figure(i)
else:
fig = plt.subplot(i)
if pcanc == 0:
plt.title(
' learning_rate: ' + str(lr)
+ ' perplexity: ' + str(pp))
print("Plotting tSNE")
else:
plt.title(
'PCA-n_components: ' + str(pcanc)
+ ' learning_rate: ' + str(lr)
+ ' perplexity: ' + str(pp))
print("Plotting PCA-tSNE")
plt.scatter(Y[:, 0], Y[:, 1], c=colors)
if labelFlag == 1:
for label, cx, cy in zip(y, Y[:, 0], Y[:, 1]):
plt.annotate(
label.decode('utf-8'),
xy = (cx, cy),
xytext = (-10, 10),
fontproperties=font,
textcoords = 'offset points', ha = 'right', va = 'bottom',
bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.9))
#arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
ax.xaxis.set_major_formatter(NullFormatter())
ax.yaxis.set_major_formatter(NullFormatter())
plt.axis('tight')
print("Done.")
开发者ID:CORDEA,项目名称:niconico-visualization,代码行数:31,代码来源:mds_plot_hamming.py
示例15: yplot
def yplot(data, limits=[None,None], fname='', xval=[0.5], label='',
loc='upper left', ext='png'):
"""Make transverse plots of data
Usage: yplot(data, limits=[None,None], fname='', xval=[0.5], label='',
loc='upper left', ext='ext')
xval is a list of axial distances in units of nx
If no filename is specified a plot is displayed
The special filename 'M' turns "hold" on (for multiplots)
File format is ext (default is png)
"""
nx, ny = data.shape[0], data.shape[1]
y = np.array(range(ny)) + 0.5
for x in xval:
ix = int(x*nx)
plt.plot(y, data[ix,:], label=label+" : "+"x="+str(x))
if (fname == 'M'):
plt.hold=True
else:
plt.axis([0,data.shape[1],limits[0],limits[1]])
plt.legend(loc=loc)
plt.hold=False
if len(fname) == 0:
plt.show()
else:
plt.savefig(fname+'-y.'+ext, format=ext)
plt.close()
开发者ID:viratupadhyay,项目名称:ida,代码行数:30,代码来源:ida.py
示例16: visualize
def visualize(u1, t1, u2, t2, U, omega):
plt.figure(1)
plt.plot(t1, u1, 'r--o')
t_fine = np.linspace(0, t1[-1], 1001) # мелкая сетка для точного решения
u_e = u_exact(t_fine, U, omega)
plt.hold('on')
plt.plot(t_fine, u_e, 'b-')
plt.legend([u'приближенное', u'точное'], loc='upper left')
plt.xlabel('$t$')
plt.ylabel('$u$')
tau = t1[1] - t1[0]
plt.title('$\\tau = $ %g' % tau)
umin = 1.2*u1.min();
umax = -umin
plt.axis([t1[0], t1[-1], umin, umax])
plt.savefig('tmp1.png'); plt.savefig('tmp1.pdf')
plt.figure(2)
plt.plot(t2, u2, 'r--o')
t_fine = np.linspace(0, t2[-1], 1001) # мелкая сетка для точного решения
u_e = u_exact(t_fine, U, omega)
plt.hold('on')
plt.plot(t_fine, u_e, 'b-')
plt.legend([u'приближенное', u'точное'], loc='upper left')
plt.xlabel('$t$')
plt.ylabel('$u$')
tau = t2[1] - t2[0]
plt.title('$\\tau = $ %g' % tau)
umin = 1.2 * u2.min();
umax = -umin
plt.axis([t2[0], t2[-1], umin, umax])
plt.savefig('tmp2.png');
plt.savefig('tmp2.pdf')
开发者ID:LemSkMMU2017,项目名称:Year3P2,代码行数:32,代码来源:vib_undamped.py
示例17: main
def main():
fname = iris.sample_data_path('ostia_monthly.nc')
# load a single cube of surface temperature between +/- 5 latitude
cube = iris.load_cube(fname, iris.Constraint('surface_temperature', latitude=lambda v: -5 < v < 5))
# Take the mean over latitude
cube = cube.collapsed('latitude', iris.analysis.MEAN)
# Now that we have our data in a nice way, lets create the plot
# contour with 20 levels
qplt.contourf(cube, 20)
# Put a custom label on the y axis
plt.ylabel('Time / years')
# Stop matplotlib providing clever axes range padding
plt.axis('tight')
# As we are plotting annual variability, put years as the y ticks
plt.gca().yaxis.set_major_locator(mdates.YearLocator())
# And format the ticks to just show the year
plt.gca().yaxis.set_major_formatter(mdates.DateFormatter('%Y'))
plt.show()
开发者ID:RachelNorth,项目名称:iris,代码行数:26,代码来源:hovmoller.py
示例18: draw
def draw(self):
cols, rows = self.size
minx, maxx = self.xlimits
miny, maxy = self.ylimits
width, height = self.cell_dimensions
x = map(lambda i: minx + width*i, range(cols+1))
y = map(lambda i: miny + height*i, range(rows+1))
f = plt.figure(figsize=self.figsize)
hlines = np.column_stack(np.broadcast_arrays(x[0], y, x[-1], y))
vlines = np.column_stack(np.broadcast_arrays(x, y[0], x, y[-1]))
lines = np.concatenate([hlines, vlines]).reshape(-1, 2, 2)
line_collection = LineCollection(lines, color="black", linewidths=0.5)
ax = plt.gca()
ax.add_collection(line_collection)
ax.set_xlim(x[0]-1, x[-1]+1)
ax.set_ylim(y[0]-1, y[-1]+1)
plt.gca().set_aspect('equal', adjustable='box')
plt.axis('off')
self.draw_obstacles(plt.gca())
return plt.gca()
开发者ID:jakebarnwell,项目名称:incremental-path-planning,代码行数:25,代码来源:grid.py
示例19: main
def main():
G=nx.Graph()
G.add_edge('a','b',weight=0.6)
G.add_edge('a','c',weight=0.2)
G.add_edge('c','d',weight=0.1)
G.add_edge('c','e',weight=0.7)
G.add_edge('c','f',weight=0.9)
G.add_edge('a','d',weight=0.3)
elarge=[(u,v) for (u,v,d) in G.edges(data=True) if d['weight'] >0.5]
esmall=[(u,v) for (u,v,d) in G.edges(data=True) if d['weight'] <=0.5]
pos=nx.spring_layout(G) # positions for all nodes
# nodes
nx.draw_networkx_nodes(G,pos,node_size=700)
# edges
nx.draw_networkx_edges(G,pos,edgelist=elarge,width=6)
nx.draw_networkx_edges(G,pos,edgelist=esmall,width=6,alpha=0.5,edge_color='b',style='dashed')
# labels
nx.draw_networkx_labels(G,pos,font_size=20,font_family='sans-serif')
plt.axis('off')
#plt.savefig("weighted_graph.png") # save as png
plt.show() # display
return
开发者ID:e-coucou,项目名称:Test,代码行数:29,代码来源:Test.py
示例20: heatmap
def heatmap(vals, size=6, aspect=1):
"""
Plot a heatmap from matrix data
"""
plt.figure(figsize=(size, size))
plt.imshow(vals, cmap="gray", aspect=aspect, interpolation="none", vmin=0, vmax=1)
plt.axis("off")
开发者ID:speron,项目名称:sofroniew-vlasov-2015,代码行数:7,代码来源:plots.py
注:本文中的matplotlib.pyplot.axis函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论