本文整理汇总了Python中matplotlib.pyplot.axis函数的典型用法代码示例。如果您正苦于以下问题:Python axis函数的具体用法?Python axis怎么用?Python axis使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了axis函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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))
示例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
示例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()
示例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()
示例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()
示例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
示例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()
示例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()
示例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
示例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')
示例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()
示例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')
示例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.")
示例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()