本文整理汇总了Python中pylab.ticklabel_format函数的典型用法代码示例。如果您正苦于以下问题:Python ticklabel_format函数的具体用法?Python ticklabel_format怎么用?Python ticklabel_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ticklabel_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aa
def aa(current_data):
from pylab import ticklabel_format, xticks, gca, cos, pi
plotcc(current_data)
title_hours(current_data)
ticklabel_format(format='plain',useOffset=False)
xticks(rotation=20)
a = gca()
a.set_aspect(1./cos(41.75*pi/180.))
示例2: plotraw
def plotraw(self):
"""quickly plots the raw isotope pattern (with mass defects preserved)"""
import pylab as pl
pl.bar(self.rawip[0],self.rawip[1],width=0.0001)
pl.xlabel('m/z', style='italic')
pl.ylabel('normalized intensity')
pl.ticklabel_format(useOffset=False)
pl.show()
示例3: aa
def aa(current_data):
from pylab import ticklabel_format, xticks, gca, cos, pi, savefig
title_hours(current_data)
ticklabel_format(format="plain", useOffset=False)
xticks(rotation=20)
a = gca()
a.set_aspect(1.0 / cos(46.349 * pi / 180.0))
示例4: aa_innerprod
def aa_innerprod(current_data):
from pylab import ticklabel_format, xticks, gca, cos, pi, yticks
plotcc(current_data)
title_innerproduct(current_data)
ticklabel_format(format='plain',useOffset=False)
xticks([180, 200, 220, 240], rotation=20, fontsize = 28)
pylab.tick_params(axis='y', labelleft='off')
a = gca()
a.set_aspect(1./cos(41.75*pi/180.))
示例5: aa
def aa(current_data):
from pylab import ticklabel_format, xticks, gca, cos, pi, yticks
plotcc(current_data)
title(current_data)
ticklabel_format(format='plain',useOffset=False)
xticks([180, 200, 220, 240], rotation=20, fontsize = 28)
yticks(fontsize = 28)
a = gca()
a.set_aspect(1./cos(41.75*pi/180.))
示例6: plotbar
def plotbar(self):
"""quickly plots a bar plot of the isotope bar pattern"""
import pylab as pl
fwhm = self.em/self.ks['res']
pl.bar(self.barip[0], self.barip[1], width=fwhm, align='center')
pl.xlabel('m/z', style='italic')
pl.ylabel('normalized intensity')
pl.ticklabel_format(useOffset=False)
pl.show()
示例7: fixup
def fixup(current_data):
import pylab
#addgauges(current_data)
t = current_data.t
t = t / 3600. # hours
pylab.title('Surface at %4.2f hours' % t, fontsize=20)
pylab.ticklabel_format(format='plain',useOffset=False)
mean_lat = 19.7
pylab.gca().set_aspect(1.0 / pylab.cos(pylab.pi / 180.0 * mean_lat))
示例8: createLines
def createLines(pStrip,ySpecs,isY1=True,y2Exists=False):
'''Create data lines from specifications; this code is common for y1 and y2 axes;
it handles y-data specified as callables, which might create additional lines when updated with liveUpdate.
'''
# save the original specifications; they will be smuggled into the axes object
# the live updated will run yNameFuncs to see if there are new lines to be added
# and will add them if necessary
yNameFuncs=set([d[0] for d in ySpecs if callable(d[0])]) | set([d[0].keys for d in ySpecs if hasattr(d[0],'keys')])
yNames=set()
ySpecs2=[]
for ys in ySpecs:
# ys[0]() must return list of strings, which are added to ySpecs2; line specifier is synthesized by tuplifyYAxis and cannot be specified by the user
if callable(ys[0]): ySpecs2+=[(ret,ys[1]) for ret in ys[0]()]
elif hasattr(ys[0],'keys'): ySpecs2+=[(yy,'') for yy in ys[0].keys()]
else: ySpecs2.append(ys)
if len(ySpecs2)==0:
print 'yade.plot: creating fake plot, since there are no y-data yet'
line,=pylab.plot([nan],[nan])
line2,=pylab.plot([nan],[nan])
currLineRefs.append(LineRef(line,None,line2,[nan],[nan]))
# set different color series for y1 and y2 so that they are recognizable
if pylab.rcParams.has_key('axes.color_cycle'): pylab.rcParams['axes.color_cycle']='b,g,r,c,m,y,k' if not isY1 else 'm,y,k,b,g,r,c'
for d in ySpecs2:
yNames.add(d)
line,=pylab.plot(data[pStrip],data[d[0]],d[1],label=xlateLabel(d[0]))
line2,=pylab.plot([],[],d[1],color=line.get_color(),alpha=afterCurrentAlpha)
# use (0,0) if there are no data yet
scatterPt=[0,0] if len(data[pStrip])==0 else (data[pStrip][current],data[d[0]][current])
# if current value is NaN, use zero instead
scatter=pylab.scatter(scatterPt[0] if not math.isnan(scatterPt[0]) else 0,scatterPt[1] if not math.isnan(scatterPt[1]) else 0,s=scatterSize,color=line.get_color(),**scatterMarkerKw)
currLineRefs.append(LineRef(line,scatter,line2,data[pStrip],data[d[0]]))
axes=line.get_axes()
labelLoc=(legendLoc[0 if isY1 else 1] if y2Exists>0 else 'best')
l=pylab.legend(loc=labelLoc)
if hasattr(l,'draggable'): l.draggable(True)
if scientific:
pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both')
# fixes scientific exponent placement for y2: https://sourceforge.net/mailarchive/forum.php?thread_name=20101223174750.GD28779%40ykcyc&forum_name=matplotlib-users
if not isY1: axes.yaxis.set_offset_position('right')
if isY1:
pylab.ylabel((', '.join([xlateLabel(_p[0]) for _p in ySpecs2])) if p not in xylabels or not xylabels[p][1] else xylabels[p][1])
pylab.xlabel(xlateLabel(pStrip) if (p not in xylabels or not xylabels[p][0]) else xylabels[p][0])
else:
pylab.ylabel((', '.join([xlateLabel(_p[0]) for _p in ySpecs2])) if (p not in xylabels or len(xylabels[p])<3 or not xylabels[p][2]) else xylabels[p][2])
# if there are callable/dict ySpecs, save them inside the axes object, so that the live updater can use those
if yNameFuncs:
axes.yadeYNames,axes.yadeYFuncs,axes.yadeXName,axes.yadeLabelLoc=yNames,yNameFuncs,pStrip,labelLoc # prepend yade to avoid clashes
示例9: test_verify_AIS
def test_verify_AIS(self):
model = iRBM(input_size=self.input_size,
hidden_size=self.hidden_size,
beta=self.beta)
model.W.set_value(self.W)
model.b.set_value(self.b)
model.c.set_value(self.c)
# Brute force
print "Computing lnZ using brute force (i.e. summing the free energy of all posible $v$)..."
V = theano.shared(value=cartesian([(0, 1)] * self.input_size, dtype=config.floatX))
brute_force_lnZ = logsumexp(-model.free_energy(V), 0)
f_brute_force_lnZ = theano.function([], brute_force_lnZ)
params_bak = [param.get_value() for param in model.parameters]
print "Approximating lnZ using AIS..."
import time
start = time.time()
try:
ais_working_dir = tempfile.mkdtemp()
result = compute_AIS(model, M=self.nb_samples, betas=self.betas, seed=1234, ais_working_dir=ais_working_dir, force=True)
logcummean_Z, logcumstd_Z_down, logcumstd_Z_up = result['logcummean_Z'], result['logcumstd_Z_down'], result['logcumstd_Z_up']
std_lnZ = result['std_lnZ']
print "{0} sec".format(time.time() - start)
import pylab as plt
plt.gca().set_xmargin(0.1)
plt.errorbar(range(1, self.nb_samples+1), logcummean_Z, yerr=[std_lnZ, std_lnZ], fmt='or')
plt.errorbar(range(1, self.nb_samples+1), logcummean_Z, yerr=[logcumstd_Z_down, logcumstd_Z_up], fmt='ob')
plt.plot([1, self.nb_samples], [f_brute_force_lnZ()]*2, '--g')
plt.ticklabel_format(useOffset=False, axis='y')
plt.show()
AIS_logZ = logcummean_Z[-1]
assert_array_equal(params_bak[0], model.W.get_value())
assert_array_equal(params_bak[1], model.b.get_value())
assert_array_equal(params_bak[2], model.c.get_value())
print np.abs(AIS_logZ - f_brute_force_lnZ())
assert_almost_equal(AIS_logZ, f_brute_force_lnZ(), decimal=2)
finally:
shutil.rmtree(ais_working_dir)
示例10: plot_from_list
def plot_from_list( list_of_coordinates, fitfunction="nullfit", cubicspline=True, xticks=-1, yticks=-1 ):
'''Plots the given list. The list should be in the following format:
[[x1,y1], [x2,y2], [x3,y3], [x4,y4], .. ]
:param list_of_coordinates List of coordinates to be plotted
'''
index = 1
fig = pl.figure()
for i in list_of_coordinates:
#title="(" + i[2] + "," + i[3] + ")"
pl.subplot(len(list_of_coordinates), 1, index)
#ax = fig.add_subplot(len(list_of_coordinates), 1, index)
x = i[0]
y = i[1]
pl.xlabel(i[2])
pl.ylabel(i[3])
xlength = max(x) - min(x)
ylength = max(y) - min(y)
pl.xlim([min(x) - 0.01*xlength, max(x) + 0.01*xlength])
pl.ylim([min(y) - 0.05*ylength, max(y) + 0.05*ylength])
plot_variables(x,y,False,fitfunction,cubicspline=cubicspline)
pl.ticklabel_format(style='sci', axis='y', scilimits=(-3,3))
# Set y ticks
if yticks > 0 and len(i) == 4:
ticks = min(y) + np.arange(yticks + 1) / (float)(yticks)*ylength
print len(i)
from decimal import *
getcontext().prec = 2
# Get two decimals
ticks = [float(Decimal(j)/Decimal(1)) for j in ticks]
pl.yticks(ticks)
print ticks
# Set x ticks
if xticks > 0 and len(i) == 4:
ticks = min(x) + np.arange(xticks + 1) / (float)(xticks)*xlength
from decimal import *
getcontext().prec = 2
# Get two decimals
ticks = [float(Decimal(j)/Decimal(1)) for j in ticks]
pl.xticks(ticks)
index = index + 1
#pl.tight_layout()
pl.ion()
pl.show()
示例11: plotDepth
def plotDepth():
d = pd.read_pickle(utl.outpath + 'real/D.F59.df').replace({0: 1})
z = pd.Series(np.ndarray.flatten(d.values))
plt.figure(figsize=(8, 8), dpi=100);
plt.subplot(2, 1, 1);
sns.distplot(z, bins=180, norm_hist=False, kde=False);
plt.xlim([0, 200]);
plt.xlabel('Depth');
plt.ylabel('Number of Measurments' + ' (out of {:.1f}M)'.format(z.shape[0] / 1e6));
plt.ticklabel_format(axis='y', style='sci', scilimits=(0, 0))
plt.subplot(2, 1, 2);
sns.distplot(d.min(1), bins=50, norm_hist=False, kde=False);
plt.xlim([0, 200]);
plt.xlabel('Minimum Depth of each Site');
plt.ylabel('Number of Sites' + ' (out of {:.1f}M)'.format(d.shape[0] / 1e6));
plt.ticklabel_format(axis='y', style='sci', scilimits=(0, 0))
plt.savefig(utl.paperFiguresPath + 'depth.pdf')
示例12: plotDepth
def plotDepth():
sns.set_style("whitegrid", {"grid.color": "1", 'axes.linewidth': .5, "grid.linewidth": ".09"})
sns.set_context("notebook", font_scale=1.4, rc={"lines.linewidth": 2.5})
d = pd.read_pickle(utl.outpath + 'real/CD.F59.df').xs('D', level='READ', axis=1)
(d.min(1) > 50).sum()
(d > 50).sum().sum()
z = pd.Series(np.ndarray.flatten(d.values))
fontsize = 6
mpl.rcParams.update({'font.size': fontsize})
plt.figure(figsize=(6, 4), dpi=300);
plt.subplot(2, 2, 1);
z.value_counts().sort_index().plot()
plt.xlim([0, 200]);
plt.xlabel('Depth');
plt.ylabel('Number of Measurments' + '\n (out of {:.1f}M)'.format(z.shape[0] / 1e6));
plt.ticklabel_format(axis='y', style='sci', scilimits=(0, 0))
plt.title('Scaled PDF')
pplt.annotate('(A)', xpad=0.85, ypad=0.45, fontsize=fontsize)
plt.axvline(50, linestyle='--', linewidth=1, color='k')
pplt.setSize(plt.gca(), fontsize)
plt.subplot(2, 2, 2);
z.value_counts().sort_index().cumsum().plot()
plt.xlim([0, 200])
plt.ylim([-3e5, 2.05 * 1e7])
plt.xlabel('Depth');
plt.title('Scaled CDF')
pplt.annotate('(B)', xpad=0.85, ypad=0.45, fontsize=fontsize)
plt.axvline(50, linestyle='--', linewidth=1, color='k')
pplt.setSize(plt.gca(), fontsize)
plt.subplot(2, 2, 3);
d.min(1).value_counts().sort_index().plot()
plt.xlim([0, 100]);
plt.xlabel('Minimum Depth of each Variant');
plt.ylabel('Number of Variants' + '\n (out of {:.1f}M)'.format(d.shape[0] / 1e6));
plt.ticklabel_format(axis='y', style='sci', scilimits=(0, 0))
plt.rc('font', size=fontsize)
pplt.annotate('(C)', xpad=0.85, ypad=0.45, fontsize=fontsize)
plt.axvline(50, linestyle='--', linewidth=1, color='k')
pplt.setSize(plt.gca(), fontsize)
plt.subplot(2, 2, 4);
d.min(1).value_counts().sort_index().cumsum().plot()
plt.xlim([0, 60])
plt.ylim([0.25 * -1e5, plt.ylim()[1]])
plt.xlabel('Minimum Depth of each Variant');
plt.ticklabel_format(axis='y', style='sci', scilimits=(0, 0))
pplt.annotate('(D)', xpad=0.85, ypad=0.45, fontsize=fontsize)
plt.axvline(50, linestyle='--', linewidth=1, color='k')
pplt.setSize(plt.gca(), fontsize)
plt.gcf().subplots_adjust(bottom=0.15)
plt.gcf().tight_layout(h_pad=0.1)
fontsize = 6
mpl.rc('font', **{'family': 'serif', 'serif': ['Computer Modern'], 'size': fontsize});
mpl.rc('text', usetex=True)
mpl.rcParams.update({'font.size': 1})
pplt.savefig('depth', 300)
plt.show()
示例13: plotgaus
def plotgaus(self,exp=None):
"""quickly plots the simulated gaussian isotope pattern"""
import pylab as pl
try:
pl.plot(self.gausip[0],self.gausip[1],linewidth=1)
except AttributeError:
self.gausip = self.gaussianisotopepattern()
pl.plot(self.gausip[0],self.gausip[1],linewidth=1)
if exp is not None: # plots experimental if supplied
y = []
maxy = max(exp[1])
for val in exp[1]: # normalize
y.append(val/maxy*100)
comp = self.compare(exp)
pl.plot(exp[0],exp[1])
pl.text(max(exp[0]),95,'SER: '+`comp`)
#pl.fill_between(x,self.gausip[1],exp[1],where= exp[1] =< self.gausip[1],interpolate=True, facecolor='red')
pl.fill(self.gausip[0],self.gausip[1],facecolor='blue',alpha=0.25)
pl.xlabel('m/z', style='italic')
pl.ylabel('normalized intensity')
pl.ticklabel_format(useOffset=False)
pl.show()
示例14: P_AP
def P_AP(folder,keys):
for f in folder:
a=Analysis.AnalyseFile()
a.add_column(f.column('Current'),'Current')
a.add_column(f.column('Mean'),'NLV')
fit, fitVar= a.curve_fit(quad,'Current','NLV',bounds=lambda x,y:abs(x)>200e-6,result=True,header='Fit')
plt.title(r'')
plt.xlabel(r'Temperature (K)')
plt.ylabel(r'$\beta$ (V/A$^2$)')
plt.ticklabel_format(style='plain', scilimits=(3 ,3))
plt.hold(True)
'''
if f['IVtemp'] == 5:
plt.plot(a.column('Current'),a.column('NLV'),'b')
plt.plot(a.column('Current'),a.column('Fit'),'k')
'''
print f['state'],f['IVtemp']
if f['state'] == 'P':
#plt.plot(f['IVtemp'],fit[0],'ro')
print fitVar
plt.errorbar(f['IVtemp'],fit[0],numpy.sqrt(fitVar[0,0]),ecolor='k',marker='o',mfc='red', mec='k',ms=15.0)
print 'p'
if f['state'] == 'AP':
print 'ap'
plt.errorbar(f['IVtemp'],fit[0],numpy.sqrt(fitVar[0,0]),ecolor='k',marker='o',mfc='blue', mec='k',ms=15.0)
#plt.plot(f['IVtemp'],fit[0],'bx')
#plt.legend()
plt.savefig('/Users/Joe/PhD/Talks/MMM13/beta.eps', bbox_inches=0)
plt.show()
示例15: plot_stat_without_eq
def plot_stat_without_eq(dictionary, file, location=None):
fig = pylab.figure()
count = 0
print(type(dictionary))
lis = sorted(dictionary.keys())
for key in lis:
count+=1
axes = dictionary.get(key)
filename = str(file) + '.png'
fig.add_subplot(4, 2, (count))
pylab.ticklabel_format(style='sci', axis = 'both', scilimits=(0,0))
pylab.plot(axes.get('x'), axes.get('y'), str(1), color='0.4', marker='o', markeredgecolor='0.4')
pylab.xlabel('iTRAQAnalyzer')
pylab.ylabel('Protein Pilot')
pylab.rc('font', size=5.5)
# z[0] denotes slope, z[1] denotes the intercept
z = np.polyfit(axes.get('x'), axes.get('y'), 1)
p = np.poly1d(z)
coeff = np.corrcoef(axes.get('x'), axes.get('y'))
pylab.plot(axes.get('x'), p(axes.get('x')), "r-", color='0')
print "y=%.6fx+(%.6f)"%(z[0],z[1])
# pylab.text(0.1, 0.3, "y=%.6fx+(%.6f)"%(z[0],z[1]))
print str(coeff[0][1])
pylab.title(str(key))
pylab.tight_layout()
graph = pylab.gcf()
graph.canvas.set_window_title(str(filename))
graph.savefig(location + '/' + filename)
pylab.close()