本文整理汇总了Python中matplotlib.pyplot.yticks函数的典型用法代码示例。如果您正苦于以下问题:Python yticks函数的具体用法?Python yticks怎么用?Python yticks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yticks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_jobs_by_skills
def plot_jobs_by_skills(cur, skills):
skill_jobs = {}
for skill in skills:
cur.execute('''select count(j.id) amount from jobs j where j.id in
(select js.job_id from job_skills js where js.skill=?)''',
(skill,))
res = cur.fetchone()
skill_jobs[skill] = res[0]
sorted_skill_jobs = zip(*sorted(skill_jobs.items(),
key=operator.itemgetter(1), reverse=False))
fig = plt.figure()
y_pos = np.arange(len(skill_jobs))
print y_pos
ax = plt.barh(y_pos, sorted_skill_jobs[1], align='center', alpha=0.3)
plt.yticks(y_pos, ['\n'.join(wrap(x, 10)) for x in sorted_skill_jobs[0]])
plt.ylabel('Skill')
plt.xlabel('Amount of jobs')
autolabel_h(ax)
plt.gcf().subplots_adjust(left=0.20)
return fig
示例2: filterFunc
def filterFunc():
rects = []
hsv_planes = [[[]]]
if os.path.isfile(Image_File):
BGR=cv2.imread(Image_File)
gray = cv2.cvtColor(BGR, cv2.COLOR_BGR2GRAY)
img = gray
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
magnitude_spectrum = 20*np.log(np.abs(fshift))
plt.subplot(221),plt.imshow(img, cmap = 'gray')
plt.title('Input Image'), plt.xticks([]), plt.yticks([])
plt.subplot(222),plt.imshow(magnitude_spectrum, cmap = 'gray')
plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])
FiltzeredFFT = HighPassFilter(fshift, 60)
plt.subplot(223),plt.imshow(np.abs(FiltzeredFFT), cmap = 'gray')
plt.title('Filtered'), plt.xticks([]), plt.yticks([])
f_ishift = np.fft.ifftshift(FiltzeredFFT)
img_back = np.fft.ifft2(f_ishift)
img_back = np.abs(img_back)
plt.subplot(224),plt.imshow(np.abs(img_back), cmap = 'gray')
plt.title('Filtered Image'), plt.xticks([]), plt.yticks([])
plt.show()
示例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: tuning
def tuning(x, y, err=None, smooth=None, ylabel=None, pal=None):
"""
Plot a tuning curve
"""
if smooth is not None:
xs, ys = smoothfit(x, y, smooth)
plt.plot(xs, ys, linewidth=4, color="black", zorder=1)
else:
ys = asarray([0])
if pal is None:
pal = sns.color_palette("husl", n_colors=len(x) + 6)
pal = pal[2 : 2 + len(x)][::-1]
plt.scatter(x, y, s=300, linewidth=0, color=pal, zorder=2)
if err is not None:
plt.errorbar(x, y, yerr=err, linestyle="None", ecolor="black", zorder=1)
plt.xlabel("Wall distance (mm)")
plt.ylabel(ylabel)
plt.xlim([-2.5, 32.5])
errTmp = err
errTmp[isnan(err)] = 0
rng = max([nanmax(ys), nanmax(y + errTmp)])
plt.ylim([0 - rng * 0.1, rng + rng * 0.1])
plt.yticks(linspace(0, rng, 3))
plt.xticks(range(0, 40, 10))
sns.despine()
return rng
示例5: as_pyplot_figure
def as_pyplot_figure(self, label=1, **kwargs):
"""Returns the explanation as a pyplot figure.
Will throw an error if you don't have matplotlib installed
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exception.
kwargs: keyword arguments, passed to domain_mapper
Returns:
pyplot figure (barchart).
"""
import matplotlib.pyplot as plt
exp = self.as_list(label, **kwargs)
fig = plt.figure()
vals = [x[1] for x in exp]
names = [x[0] for x in exp]
vals.reverse()
names.reverse()
colors = ['green' if x > 0 else 'red' for x in vals]
pos = np.arange(len(exp)) + .5
plt.barh(pos, vals, align='center', color=colors)
plt.yticks(pos, names)
plt.title('Local explanation for class %s' % self.class_names[label])
return fig
示例6: make_entity_plot
def make_entity_plot(filename, title, fixed_noip, fixed_ip, dynamic_noip, dynamic_ip):
plt.figure(figsize=(12,5))
plt.title("Settings comparison - " + title)
plt.xlabel('Time (ms)', fontsize=12)
plt.xlim([0,62000])
x = 0
barwidth = 0.5
bargroupspacing = 1.5
fixed_noip_mean,fixed_noip_conf = conf_stats(fixed_noip)
fixed_ip_mean,fixed_ip_conf = conf_stats(fixed_ip)
dynamic_noip_mean,dynamic_noip_conf = conf_stats(dynamic_noip)
dynamic_ip_mean,dynamic_ip_conf = conf_stats(dynamic_ip)
values = [fixed_noip_mean,fixed_ip_mean,dynamic_noip_mean, dynamic_ip_mean]
errs = [fixed_noip_conf,fixed_ip_conf,dynamic_noip_conf, dynamic_ip_conf]
y_pos = numpy.arange(len(values))
plt.barh(y_pos, values, xerr=errs, align='center', color=['r', 'b', 'r', 'b'], ecolor='black', alpha=0.7)
plt.yticks(y_pos, ["Fixed | no I.P.", "Fixed | I.P.", "Dynamic | no I.P.", "Dynamic | I.P."])
plt.savefig(output_file(filename))
plt.clf()
示例7: make_bar
def make_bar(
x,
y,
f_name,
title=None,
legend=None,
x_label=None,
y_label=None,
x_ticks=None,
y_ticks=None,
):
fig = plt.figure()
if title is not None:
plt.title(title, fontsize=16)
if x_label is not None:
plt.ylabel(x_label)
if y_label is not None:
plt.xlabel(y_label)
if x_ticks is not None:
plt.xticks(x, x_ticks)
if y_ticks is not None:
plt.yticks(y_ticks)
plt.bar(x, y, align="center")
if legend is not None:
plt.legend(legend)
plt.savefig(f_name)
plt.close(fig)
示例8: nodeplot
def nodeplot(xnode,figtitle):
fig = demo.figure(figtitle,'', '',[-0.0001, 1.0001], [-0.05, 0.05],figsize=[6,1.5])
plt.plot(xnode, np.zeros_like(xnode),'bo',ms=8)
plt.xticks([0,1])
plt.yticks([])
figures.append(fig)
示例9: streamlineBxz_dens
def streamlineBxz_dens():
fig=plt.figure()
ppy=yt.ProjectionPlot(ds, "y", "Bxz", weight_field="density") #Project X-component of B-field from z-direction
By=ppy._frb["density"]
ax=fig.add_subplot(111)
plt.xticks(tick_locs,tick_lbls)
plt.yticks(tick_locs,tick_lbls)
Bymag=ax.pcolormesh(np.log10(By), cmap="YlGn")
cbar_m=plt.colorbar(Bymag)
cbar_m.set_label("density")
res=800
#densxy=Density2D(0,1) #integrated density along given axis
U=Flattenx(0,1) #X-magnetic field integrated along given axis
V=Flattenz(0,1) #Z-magnetic field
#U=np.asarray(zip(*x2)[::-1]) #rotate the matrix 90 degrees to correct orientation to match projected plots
#V=np.asarray(zip(*y2)[::-1])
norm=np.sqrt(U**2+V**2) #magnitude of the vector
Unorm=U/norm #normalise vectors
Vnorm=V/norm
#mask_Unorm=np.ma.masked_where(densxy<np.mean(densxy),Unorm) #create a masked array of Unorm values only in high density regions
#mask_Vnorm=np.ma.masked_where(densxy<np.mean(densxy),Vnorm)
X,Y=np.meshgrid(np.linspace(0,res,64, endpoint=True),np.linspace(0,res,64,endpoint=True))
streams=plt.streamplot(X,Y,Unorm,Vnorm,color=norm*1e6,density=(3,3),cmap=plt.cm.autumn)
cbar=plt.colorbar(orientation="horizontal")
cbar.set_label('Bxz streamlines (uG)')
plt.title("Bxz streamlines on weighted density projection")
plt.xlabel("(1e4 AU)")
plt.ylabel("(1e4 AU)")
示例10: _plot
def _plot(_df, fig, ax):
"""
"""
_df = pd.DataFrame(_df)
df = _df.sort('ratio')
df['color'] = 'grey'
df.color[(df.lower > 1) & (df.upper > 1)] = 'blue'
df.color[(df.lower < 1) & (df.upper < 1)] = 'red'
df.index = range(len(df)) # reset the index to reflect order
if fig is None and ax is None:
fig, ax = plt.subplots(figsize=(8, 12))
ax.set_aspect('auto')
ax.set_xlabel('Odds ratio')
ax.grid(False)
ax.set_ylim(-.5, len(df) - .5)
plt.yticks(df.index)
ax.scatter(df.ratio, df.index, c=df.color, s=50)
for pos in range(len(df)):
ax.fill_between([df.lower[pos], df.upper[pos]], pos-.01, pos+.01, color='grey', alpha=.3)
ax.set_yticklabels(df.names)
ax.vlines(x=1, ymin=-.5, ymax=len(df)-.5, colors='grey', linestyles='--')
return fig, ax
示例11: plot_heat_net
def plot_heat_net(net_mat, sectors):
"""Plot a heat map of the net relations.
Parameters
----------
net_mat: np.ndarray
the net represented in a matrix way.
sectors: list
the name of the elements of the adjacency matrix network.
Returns
-------
fig: matplotlib.pyplot.figure
the figure of the matrix heatmap.
"""
vmax = np.sort([np.abs(net_mat.max()), np.abs(net_mat.min())])[::-1][0]
n_sectors = len(sectors)
assert(net_mat.shape[0] == net_mat.shape[1])
assert(n_sectors == len(net_mat))
fig = plt.figure()
plt.imshow(net_mat, interpolation='none', cmap=plt.cm.RdYlGn,
vmin=-vmax, vmax=vmax)
plt.xticks(range(n_sectors), sectors)
plt.yticks(range(n_sectors), sectors)
plt.xticks(rotation=90)
plt.colorbar()
return fig
示例12: tiCarryPlot
def tiCarryPlot(getTIresult):
conCarry = getTIresult.ix[:,0]*getTIresult.ix[:,1]
disCarry = getTIresult.ix[:,0]*getTIresult.ix[:,2]
cumBetas = np.cumprod(getTIresult.ix[:,0]/100+1)-1
cumConBetas = np.cumprod(conCarry/100+1)-1
cumDisBetas = np.cumprod(disCarry/100+1)-1
fig = plt.figure()
ax1 = fig.add_subplot(311)
ax1.set_title('Cumulative Betas')
cumBetas.plot(style='r',label='Original Beta')
cumConBetas.plot(style='b', label='Discrete Weights')
cumDisBetas.plot(style='g', label='Digital Weights')
plt.legend(loc=2)
ax2 = fig.add_subplot(312)
ax2.set_title('Discrete Weights')
getTIresult.ix[:,1].plot(style='b')
plt.ylim([0, 1.2])
plt.yticks([0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2])
ax3 = fig.add_subplot(313)
ax3.set_title('Digital Weights')
getTIresult.ix[:,2].plot(style='g')
plt.ylim([-0.1, 1.1])
plt.yticks([-0.1, 0.1, 0.3, 0.5, 0.7, 0.9, 1.1])
fig.tight_layout()
plt.show()
示例13: makePlot
def makePlot(
k,
counts,
yaxis=[],
width=0.8,
figsize=[14.0,8.0],
title="",
ylabel='tmpylabel',
xlabel='tmpxlabel',
labels=[],
show=False,
grid=True,
xticks=[],
yticks=[],
steps=5,
save=False
):
'''
'''
if not list(yaxis):
yaxis = np.arange(len(counts))
if not labels:
labels = yaxis
index = np.arange(len(yaxis))
fig, ax = plt.subplots()
fig.set_size_inches(figsize[0],figsize[1])
plt.bar(index, counts, width)
plt.title(title)
if not xticks:
print ('Making xticks')
ticks = makeTicks(yMax=len(yaxis),steps=steps)
xticks.append(ticks+width/2.)
xticks.append(labels)
print ('Done making xticks')
if yticks:
print ('Making yticks')
# plt.yticks([1,2000],[0,100])
plt.yticks(yticks[0],yticks[1])
# ax.set_yticks(np.arange(0,100,10))
print ('Done making yticks')
plt.xticks(xticks[0]+width/2., xticks[1])
plt.ylabel(ylabel)
plt.xlabel(xlabel)
# ax.set_xticks(range(0,len(counts)+2))
fig.autofmt_xdate()
# ax.set_xticklabels(ks)
plt.axis([0, len(yaxis), 0, max(counts) + (max(counts)/100)])
plt.grid(grid)
location = ROOT_FOLDER + "/../muchBazar/src/image/" + k + "distribution.png"
if save:
plt.savefig(location)
print ('Distribution written to: %s' % location)
if show:
plt.show()
示例14: plotresult
def plotresult(i=0, j=101, step=1):
import matplotlib.pyplot as mpl
from numpy import arange
res = getevaluation(i, j, step)
x = [k / 100.0 for k in range(i, j, step)]
nbcurve = len(res[0])
nres = [[] for i in xrange(nbcurve)]
mres = []
maxofmin = -1, 0.01
for kindex, kres in enumerate(res):
minv = min(kres.values())
if minv > maxofmin[1]:
maxofmin = kindex, minv
lres = [(i, j) for i, j in kres.items()]
lres.sort(lambda x, y: cmp(x[0], y[0]))
for i, v in enumerate(lres):
nres[i].append(v[1])
mres.append(sum([j for i, j in lres]) / nbcurve)
print maxofmin
for y in nres:
mpl.plot(x, y)
mpl.plot(x, mres, linewidth=2)
mpl.ylim(0.5, 1)
mpl.xlim(0, 1)
mpl.axhline(0.8)
mpl.axvline(0.77)
mpl.xticks(arange(0, 1.1, 0.1))
mpl.yticks(arange(0.5, 1.04, 0.05))
mpl.show()
示例15: fig
def fig(data, target):
#FIXME
plt.scatter(data, target, color='black')
plt.xticks(())
plt.yticks(())
plt.show()