本文整理汇总了Python中matplotlib.plot函数的典型用法代码示例。如果您正苦于以下问题:Python plot函数的具体用法?Python plot怎么用?Python plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: genCurve
def genCurve(dataSet, tree):
x = [] # stores the x axis of the graph
trainList = [] # the list of accuracies derived from training data
valList = [] # the list of accuracies derived from validation data
i = 0
while i < 1:
i = i+0.1
a = 0
b = 0
for trial in range(3):
newData = sortData(dataSet, i) # MAKE THIS
tree = getTree(newData) # NEED TO GET THIS FUNCTION WHEN TREEGEN WORKS
a = a + model_validation.validateTree(tree, newData)
b = b + model_validation.validateTree(tree, newData)
a = float(a)/3
b = float(b)/3
trainList.append(a)
valList.append(b)
x.append(i)
plt.plot(x, trainList)
plt.plot(x, valList)
plt.xlabel('percent training used')
plt.ylabel('percent accuracy')
plt.title('learning curve')
plt.show()
开发者ID:guiklink,项目名称:eecs349_machine_learning_hw2,代码行数:27,代码来源:make_graph.py
示例2: shist
def shist(self,data,sflag,spath,sname,pflag):
g.tprinter('Running sist',pflag)
xdata=data[:,0]
ydata=data[:,1]
plt.plot(xdata,ydata,'ro')
plt.savefig(os.path.join(spath,str(sname))+'.pdf')
plt.close()
开发者ID:OliStein,项目名称:minions,代码行数:7,代码来源:plotter.py
示例3: plotRaster
def plotRaster(clustaArray=[]):
if len(clustaArray) < 1:
print "Nothing to plot!"
else:
# create list of times that maps to each spike
p_sptimes = []
for a in clustaArray:
for b in a.spike_samples:
p_sptimes.append(b)
sptimes = np.array(p_sptimes)
p_clusters = []
for c in clustaArray:
for d in c.id_of_spike:
p_clusters.append(c.id_of_clusta)
clusters = np.array(p_clusters)
# dynamically generate cluster list
clusterList = []
for a in clustaArray:
clusterList.append(a.id_of_clusta)
# plot raster for all clusters
# nclusters = 20
# #for n in range(nclusters):
timesList = []
for n in clusterList:
# if n<>9:
ctimes = sptimes[clusters == n]
timesList.append(ctimes)
plt.plot(ctimes, np.ones(len(ctimes)) * n, "|")
plt.show()
开发者ID:RaymondDunn,项目名称:branco_pipeline,代码行数:34,代码来源:generateGraphs.py
示例4: show_data_set_plot
def show_data_set_plot(self):
data_plots = []
for i in range(self.data_set.shape[1]):
data_plots.append(go.Scatter(x=list(range(self.data_set.shape[0])), y=self.data_set[:, i], mode="markers", name="Characteristic "+str(i+1)))
plot(data_plots, filename="Dataset.html")
# Add delay between plots showing to avoid crashing of browser
time.sleep(1.5)
开发者ID:b14ckfir3,项目名称:Rbfc,代码行数:10,代码来源:Rbfc.py
示例5: plotsig
def plotsig (ReconSig, electrode):
"""
plots the reconstructed signal and the original
in: ReconSig, the reconstructed signal
electrode, the original signal
"""
plt.plot (ReconSig)
plt.plot (electrode)
plt.show
开发者ID:jdestupinan1332,项目名称:TareasComp,代码行数:10,代码来源:sk.py
示例6: plotDataFrame
def plotDataFrame(self, variables):
try:
import matplotlib.pyplot as plt
except ImportError:
print "Unable to import matplotlib"
plt.plot(self.df[variables[0]], self.df[variables[1]])
plt.xlabel(r"{}".format(variables[0]))
plt.ylabel(r"$P$")
plt.minorticks_on()
plt.show()
开发者ID:dsmiff,项目名称:pandasUtils,代码行数:10,代码来源:pandasCore.py
示例7: plot2D
def plot2D(x,y,x_ex,y_ex,ylabl):
#static variable counter
plot2D.fig_num += 1
plt.subplot(2,2,plot2D.fig_num)
plt.xlabel('$x$ (cm)')
plt.ylabel(ylabl)
plt.plot(x,y,"b+-",label="Lagrangian")
plt.plot(x_ex,y_ex,"r--",label="Exact")
plt.savefig("var_"+str(plot2D.fig_num)+".pdf")
开发者ID:jhansel,项目名称:radhydro,代码行数:11,代码来源:lag_hydro.py
示例8: draw_circle
def draw_circle(c,r):
t = arange(0,1.01,.01)*2*pi
x = r*cos(t) + c[0]
y = r*sin(t) + c[1]
plt.plot(x,y,'b',linewidth=2)
plt.imshow(im)
if circle:
for p in locs:
plt.draw_circle(p[:2],p[2])
else:
plt.plot(locs[:,0],locs[:,1],'ob')
plt.axis('off')
开发者ID:maxschommer,项目名称:Multirotors,代码行数:12,代码来源:sift.py
示例9: plot2D
def plot2D(x,y,ylabl,x_ex=None,y_ex=None):
#static variable counter
plot2D.fig_num += 1
plt.subplot(2,2,plot2D.fig_num)
plt.xlabel('$x$ (cm)')
plt.ylabel(ylabl)
plt.plot(x,y,"b+-",label="Numerical")
if (x_ex != None):
plt.plot(x_ex,y_ex,"r-x",label="Exact")
plt.savefig("var_"+str(plot2D.fig_num)+".pdf")
开发者ID:jhansel,项目名称:radhydro,代码行数:13,代码来源:muscl_hanc.py
示例10: viz_losses
def viz_losses(filename, losses):
if '.' not in filename: filename += '.png'
x = history['epoch']
legend = losses.keys
for v in losses.values: plt.plot(np.arange(len(v)) + 1, v, marker='.')
plt.title('Loss over epochs')
plt.xlabel('Epochs')
plt.xticks(history['epoch'], history['epoch'])
plt.legend(legend, loc = 'upper right')
plt.savefig(filename)
开发者ID:AhmedKamalAK,项目名称:py_ml_utils,代码行数:13,代码来源:visualize.py
示例11: get_trajectories_for_DF
def get_trajectories_for_DF(DF):
GetXYS=ct.get_xys(DF)
xys_s=ct.get_xys_s(GetXYS['xys'],GetXYS['Nmin'])
plt.figure(figsize=(5, 5),frameon=False)
for m in list(range(9)):
plt.plot()
plt.subplot(3,3,m+1)
xys_s_x_n=xys_s[m]['X']-min(xys_s[m]['X'])
xys_s_y_n=xys_s[m]['Y']-min(xys_s[m]['Y'])
plt.plot(xys_s_x_n,xys_s_y_n)
plt.axis('off')
axes = plt.gca()
axes.set_ylim([0,125])
axes.set_xlim([0,125])
开发者ID:bmdaort,项目名称:3D_CellTracking_Analysis,代码行数:14,代码来源:use_tracking_functions.py
示例12: plotHistogram
def plotHistogram(clustaArray=[]):
if len(clustaArray) < 1:
print "Nothing to plot!"
else:
# create list of times that maps to each spike
p_sptimes = []
for a in clustaArray:
for b in a.spike_samples:
p_sptimes.append(b)
sptimes = np.array(p_sptimes)
p_clusters = []
for c in clustaArray:
for d in c.id_of_spike:
p_clusters.append(c.id_of_clusta)
clusters = np.array(p_clusters)
# dynamically generate cluster list
clusterList = []
for a in clustaArray:
clusterList.append(a.id_of_clusta)
# plot raster for all clusters
# nclusters = 20
# #for n in range(nclusters):
timesList = []
for n in clusterList:
# if n<>9:
ctimes = sptimes[clusters == n]
timesList.append(ctimes)
# plt.plot(ctimes, np.ones(len(ctimes))*n, '|')
# plt.show()
# plot frequency in Hz over time
dt = 1 / 30000.0 # in seconds
binSize = 1 # in seconds
binSizeSamples = round(binSize / dt)
recLen = np.max(sptimes)
nbins = round(recLen / binSizeSamples)
binCount = []
cluster = 3
for b in np.arange(0, nbins - 1):
n = np.sum((timesList[cluster] > b * binSizeSamples) & (timesList[cluster] < (b + 1) * binSizeSamples))
binCount.append(n / binSize) # makes Hz
plt.plot(binCount)
plt.ylim([0, 20])
plt.show()
开发者ID:RaymondDunn,项目名称:branco_pipeline,代码行数:50,代码来源:generateGraphs.py
示例13: animate_plotting
def animate_plotting(subdir_path,):
average_filename = 'averaged_out.txt'
if os.path.exists( os.path.join(subdir_path,average_filename) ):
print(subdir_path+average_filename+' already exists please use hotPlot.py')
#import existing data for average at the end
# data_out = numpy.genfromtxt(os.path.join(subdir_path,average_filename))
# averaged_data = numpy.array(data_out[:,1])
# angles = data_out[:,0]
#os.remove( os.path.join(subdir_path,average_filename))
else:
files = os.listdir(subdir_path)
#files = [d for d in os.listdir(subdir_path) if os.path.isdir(os.path.join(subdir_path, d))]
onlyfiles_path = [os.path.join(subdir_path,f) for f in files if os.path.isfile(os.path.join(subdir_path,f))]
onlyfiles_path = natsort.natsorted(onlyfiles_path)
averaged_data = []
angles = []
for f in onlyfiles_path:
data = numpy.genfromtxt(f,delimiter = ',')
#data = pandas.read_csv(f)
averaged_data.append(numpy.mean(data))
angle = os.path.basename(f).split('_')[0]
angles.append(float(angle))
fig = plt.plot(angles, averaged_data,'o')
plt.yscale('log')
plt.xscale('log')
plt.legend(loc='upper right')
plt.title(base_path)
plt.grid(True)
plt.xlabel(r'$\theta$ $[deg.]}$')
#plt.xlabel(r'$\mathrm{xlabel\;with\;\LaTeX\;font}$')
plt.ylabel(r'I($\theta$) $[a.u.]$')
开发者ID:phcerdan,项目名称:scatteringLab-IFS,代码行数:31,代码来源:hotPlotLive.py
示例14: plot_data
def plot_data():
import matplotlib.pylab as plt
t, suffering = np.loadtxt('suffering.dat', unpack= True, usecols = (0,1))
t, fitness = np.loadtxt('fitness.dat', unpack = True, usecols = (0,1))
plt.plot(t, suffering)
plt.xlabel('t')
plt.ylabel('suffering')
plt.savefig('suffering.png')
plt.close()
plt.plot(t, fitness)
plt.xlabel('t')
plt.ylabel('fitness')
plt.savefig('fitness.png')
plt.close()
开发者ID:colemathis,项目名称:BlackQueen,代码行数:17,代码来源:Output.py
示例15: plotEqDistn
def plotEqDistn(r1, r2, board):
xs = []
ys =[]
handCount = 0.0
for hand in r1.getHandsSortedAndEquities(r2, board):
#plot hand at (handCount, equity) and (handCount + r1.getFrac(hand[0]), equity)
xs.append(handCount)
handCount += r1.getFrac(hand[0])
xs.append(handCount)
ys.append(hand[1])
ys.append(hand[1])
plot (xs, ys)
开发者ID:github-account-because-they-want-it,项目名称:PokerViewer,代码行数:17,代码来源:notebook.py
示例16: grafico
def grafico(e):
plt.plot(k, np.repeat(dfa, N+1), 'k-')
plt.plot(k, vff, 'go')
plt.plot(k, vaf, 'ro')
plt.plot(k, vbf, 'bo')
plt.axis([0, N, dfa - e, dfa + e])
plt.grid(True)
plt.show()
开发者ID:masbicudo,项目名称:Trabalhos-UFRJ,代码行数:10,代码来源:p1q2.py
示例17: blca
def blca(datafile,numprocs):
#run c++ blocking routine, saves txt data file with blocking data
os.system("make --silent")
os.system("mpirun -n %i blocking.out 100 3000 2 %i %s"%(nprocs,numprocs,datafile))#VMC
#os.system("mpirun -n %i blocking.out 5000 100 20000 %i %s"%(nprocs,numprocs,datafile))#DMC
#read txt file and save plot
data = np.genfromtxt(fname=datafile+'.txt')
fig=plt.figure()
plt.plot(data[:,0],data[:,2],'k+')
plt.xlabel(r'$\tau_{trial}$', size=20)
plt.ylabel(r'$\epsilon$', size=20)
plt.xlim(np.min(data[:,0]),np.max(data[:,0]))
plt.ylim(np.min(data[:,2]),np.max(data[:,2]))
fig.savefig(datafile+'.eps',format='eps')
#open plot if -p in argv
if plot_res:
os.system('evince %s%s '%(datafile+'.eps','&'))
print("plot saved : %s"%(datafile+'.eps'))
开发者ID:kleikanger,项目名称:vmc,代码行数:18,代码来源:blocking.py
示例18: plotWaveforms
def plotWaveforms(clustaArray=[]):
if len(clustaArray) < 1:
print "Nothing to plot!"
else:
clustaToPlot = int(raw_input("Please enter the cluster id to plot: "))
i = 0
while i < len(clustaArray):
if clustaToPlot == clustaArray[i].id_of_clusta:
j = 0
while j < len(clustaArray[i].waveforms):
k = 0
while k < len(clustaArray[i].waveforms[j]):
plt.plot([k], [clustaArray[i].waveforms[j][k]], "ro")
k = k + 1
j = j + 1
i = i + 1
plt.show()
开发者ID:RaymondDunn,项目名称:branco_pipeline,代码行数:18,代码来源:generateGraphs.py
示例19: plot_sinad_sfdr
def plot_sinad_sfdr (label, data_x, data_y, chans=[0,1,2,3],
titles=['SFDR','SINAD']):
"""
x x values of data (same for all chans)
y array with shape (2, chans, data)
"""
n=len(chans)
n2=len(titles)
pos=np.arange(n2*n)+1
for t in range(n2):
pos_val=pos[t::n2]
for chan in chans:
plt.subplot(n,n2,pos_val[chan])
plt.plot(data_x,data_y[t][chan],label=label)
if t==0:
plt.ylabel('Chan %i' %chan)
if chan==0:
plt.title(titles[t])
开发者ID:umass-wares,项目名称:wares_spec,代码行数:19,代码来源:SFDR_plot.py
示例20: __save
def __save(self,n,plot,sfile):
p.figure(figsize=sfile)
p.xlabel(plot.xlabel)
p.ylabel(plot.ylabel)
p.xscale(plot.xscale)
p.yscale(plot.yscale)
p.grid()
for curve in plot.curves:
if curve[1] == None: p.plot(curve[0],curve[2], label=curve[3])
else: p.plot(curve[0], curve[1], curve[2], label=curve[3])
p.rc('legend', fontsize='small')
p.legend(shadow=0, loc='best')
p.axes().set_aspect(plot.aspect)
if not plot.dir: plot.dir = './plots/'
if not plot.name: plot.name = self.__global_name+'_%0*i'%(2,n)
if not os.path.isdir(plot.dir): os.mkdir(plot.dir)
if plot.pgf: p.savefig(plot.dir+plot.name+'.pgf')
else: p.savefig(plot.dir+plot.name+'.pdf', bbox_inches='tight')
p.close()
开发者ID:simphys,项目名称:exercises,代码行数:19,代码来源:plotter.py
注:本文中的matplotlib.plot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论