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