本文整理汇总了Python中pylab.plt.plot函数的典型用法代码示例。如果您正苦于以下问题:Python plot函数的具体用法?Python plot怎么用?Python plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_slip
def plot_slip(slip, nx, ny,
label='x-',
legend = None
):
epochs = slip.get_epochs()
s = slip.get_cumu_slip_at_subfault(nx, ny)
plt.plot(epochs, s, label, label=legend)
示例2: plot_stat
def plot_stat(rows, cache):
"Use matplotlib to plot DAS statistics"
if not PLOT_ALLOWED:
raise Exception('Matplotlib is not available on the system')
if cache in ['cache', 'merge']: # cachein, cacheout, mergein, mergeout
name_in = '%sin' % cache
name_out = '%sout' % cache
else: # webip, webq, cliip, cliq
name_in = '%sip' % cache
name_out = '%sq' % cache
def format_date(date):
"Format given date"
val = str(date)
return '%s-%s-%s' % (val[:4], val[4:6], val[6:8])
date_range = [r['date'] for r in rows]
formated_dates = [format_date(str(r['date'])) for r in rows]
req_in = [r[name_in] for r in rows]
req_out = [r[name_out] for r in rows]
plt.plot(date_range, req_in , 'ro-',
date_range, req_out, 'gv-',
)
plt.grid(True)
plt.axis([min(date_range), max(date_range), \
0, max([max(req_in), max(req_out)])])
plt.xticks(date_range, tuple(formated_dates), rotation=17)
# plt.xlabel('dates [%s, %s]' % (date_range[0], date_range[-1]))
plt.ylabel('DAS %s behavior' % cache)
plt.savefig('das_%s.pdf' % cache, format='pdf', transparent=True)
plt.close()
示例3: initWidgets
def initWidgets(self):
self.fig = plt.figure(1)
self.manager=get_current_fig_manager()
self.img = subplot(2,1,1)
self.TempGraph=subplot(2,1,2)
x1=sp.linspace(0.0,5.0)
y1=sp.cos(2*sp.pi*x1)*sp.exp(-x1)
plt.plot(x1,y1)
row=0
self.grid()
self.lblPower=tk.Label(self,text="Power")
self.lblPower.grid(row=row,column=0)
self.sclPower=tk.Scale(self,from_=0,to_=100000,orient=tk.HORIZONTAL)
self.sclPower.grid(row=row,column=1,columnspan=3)
#lastrow
row=row+1
self.btnOne=tk.Button(master=self,text="Run")
self.btnOne["command"]=self.Run
self.btnOne.grid(row=row,column=0)
self.btnTwo=tk.Button(master=self,text="Soak")
self.btnTwo["command"]=self.Soak
self.btnTwo.grid(row=row,column=2)
self.QUIT=tk.Button(master=self,text="QUIT")
self.QUIT["command"]=self.quit
self.QUIT.grid(row=row,column=3)
示例4: serve_css
def serve_css(name, length, keys, values):
from pylab import plt, mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = False
from matplotlib.font_manager import FontProperties
# font = FontProperties(fname="d:\Users\ll.tong\Desktop\msyh.ttf", size=12)
font = FontProperties(fname="/usr/share/fonts/msyh.ttf", size=11)
plt.xlabel(u'')
plt.ylabel(u'出现次数',fontproperties=font)
plt.title(u'词频统计',fontproperties=font)
plt.grid()
keys = keys.decode("utf-8").split(' ')
values = values.split(' ')
valuesInt = []
for value in values:
valuesInt.append(int(value))
plt.xticks(range(int(length)), keys)
plt.plot(range(int(length)), valuesInt)
plt.xticks(rotation=defaultrotation, fontsize=9,fontproperties=font)
plt.yticks(fontsize=10,fontproperties=font)
name = name + str(datetime.now().date()).replace(':', '') + '.png'
imgUrl = 'static/temp/' + name
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(12.2, 2)
plt.savefig(imgUrl, bbox_inches='tight', figsize=(20,4), dpi=100)
plt.close()
tempfile = static_file(name, root='./static/temp/')
#os.remove(imgUrl)
return tempfile
示例5: plot_wlp
def plot_wlp(self,**kwargs):
"""
Plot weighted log prior
"""
if self.lp_func is None:
return
plt.plot(np.asarray(self.record.lp)*self.wlp,**kwargs)
示例6: draw
def draw(cls, t_max, agents_proportions, eco_idx, parameters):
color_set = ["green", "blue", "red"]
for agent_type in range(3):
plt.plot(np.arange(t_max), agents_proportions[:, agent_type],
color=color_set[agent_type], linewidth=2.0, label="Type-{} agents".format(agent_type))
plt.ylim([-0.1, 1.1])
plt.xlabel("$t$")
plt.ylabel("Proportion of indirect exchanges")
# plt.suptitle('Direct choices proportion per type of agents', fontsize=14, fontweight='bold')
plt.legend(loc='upper right', fontsize=12)
print(parameters)
plt.title(
"Workforce: {}, {}, {}; displacement area: {}; vision area: {}; alpha: {}; tau: {}\n"
.format(
parameters["x0"],
parameters["x1"],
parameters["x2"],
parameters["movement_area"],
parameters["vision_area"],
parameters["alpha"],
parameters["tau"]
), fontsize=12)
if not path.exists("../../figures"):
mkdir("../../figures")
plt.savefig("../../figures/figure_{}.pdf".format(eco_idx))
plt.show()
示例7: plot_fit
def plot_fit(self, size=None, tol=0.1, axis_on=True):
n, d = self.D.shape
if size:
nrows, ncols = size
else:
sq = np.ceil(np.sqrt(n))
nrows = int(sq)
ncols = int(sq)
ymin = np.nanmin(self.D)
ymax = np.nanmax(self.D)
print 'ymin: {0}, ymax: {1}'.format(ymin, ymax)
numplots = np.min([n, nrows * ncols])
plt.figure()
for n in xrange(numplots):
plt.subplot(nrows, ncols, n + 1)
plt.ylim((ymin - tol, ymax + tol))
plt.plot(self.L[n, :] + self.S[n, :], 'r')
plt.plot(self.L[n, :], 'b')
if not axis_on:
plt.axis('off')
示例8: plot
def plot(fn, marker, label):
result_file = fn
fid = vj.inv.ResultFileReader(result_file)
epochs = fid.epochs
rms = fid.rms_inland_at_epoch
plt.plot(epochs, rms, 'o-', label=label)
示例9: disp_deformed_grid_lines
def disp_deformed_grid_lines(self,level,color=None,lw=1):
# return
if self.hlines is None or self.vlines is None:
raise ValueError
hlines,vlines=self.hlines,self.vlines
# for lines,c in zip([hlines,vlines],['r','b']):
# pts_at_0=np.asarray([lines[:,0,:].flatten(),
# lines[:,1,:].flatten()]).T
# pts_at_0 = CpuGpuArray(pts_at_0.copy())
# pts_at_T=CpuGpuArray.zeros_like(pts_at_0)
# self.calc_T_fwd(pts_src=pts_at_0,
# pts_fwd=pts_at_T,
# level=level,verbose=0,int_quality=1)
# if self.nCols != self.nCols:
# raise NotImplementedError
# pts_at_T.gpu2cpu()
# lines_new_x=pts_at_T.cpu[:,0].reshape(lines[:,0,:].shape).copy()
# lines_new_y=pts_at_T.cpu[:,1].reshape(lines[:,0,:].shape).copy()
# for line_new_x,line_new_y in zip(lines_new_x,lines_new_y):
#
# plt.plot(line_new_x,line_new_y,c)
if color is None:
colors=['r','b']
else:
colors=[color,color]
s = hlines.shape
if s[2]<=1:
raise ValueError
p = 0
L = 50000
if L >=s[2]:
while p < np.ceil(s[2]):
hlines=self.hlines[:,:,p:p+L]
vlines=self.vlines[:,:,p:p+L]
p+=L
for lines,c in zip([hlines,vlines],colors):
pts_at_0=np.asarray([lines[:,0,:].flatten(),
lines[:,1,:].flatten()]).T
if pts_at_0.size==0:
break
pts_at_0 = CpuGpuArray(pts_at_0.copy())
pts_at_T=CpuGpuArray.zeros_like(pts_at_0)
self.calc_T_fwd(pts_src=pts_at_0,
pts_fwd=pts_at_T,
level=level,int_quality=1)
if self.nCols != self.nCols:
raise NotImplementedError
pts_at_T.gpu2cpu()
lines_new_x=pts_at_T.cpu[:,0].reshape(lines[:,0,:].shape).copy()
lines_new_y=pts_at_T.cpu[:,1].reshape(lines[:,0,:].shape).copy()
for line_new_x,line_new_y in zip(lines_new_x,lines_new_y):
plt.plot(line_new_x,line_new_y,c,lw=lw)
else:
raise NotImplementedError
示例10: plot_wlp_plus_ll
def plot_wlp_plus_ll(self,**kwargs):
"""
Plot log likelihood + weighted log prior
"""
if self.lp_func is None:
return
plt.plot(np.asarray(self.record.ll)+
np.asarray(self.record.lp)*self.wlp,**kwargs)
示例11: test_dip
def test_dip(self):
xf = arange(0, 425)
dips = self.fm.get_dip(xf)
plt.plot(xf,dips)
plt.grid('on')
plt.gca().set_xticks(self.fm.Y_PC)
plt.ylim([0, 30])
plt.gca().invert_yaxis()
plt.savefig(join(self.outs_dir, '~y_fc_dips.png'))
plt.close()
示例12: test_respace
def test_respace(self):
fn = '/home/zy/workspace/viscojapan/tests/share/slip0.h5'
arr = vj.epoch_3d_array.Slip.load(fn)
epochs = [0, 100, 200, 300]
arr1 = arr.respace(epochs)
nx= 2
ny = 13
plt.plot(arr.get_epochs(), arr.get_cumu_slip_at_subfault(nx, ny))
plt.plot(arr1.get_epochs(), arr1.get_cumu_slip_at_subfault(nx, ny), 'x')
示例13: plot_smoothed_alpha_comparison
def plot_smoothed_alpha_comparison(self,rmsval,suffix=''):
plt.plot(self.f,self.alpha,'ko',label='data set')
plt.plot(self.f,self.salpha,'c-',lw=2,label='smoothed angle $\phi$')
plt.xlabel('frequency in Hz')
plt.ylabel('angle $\phi$ in coordinates of circle')
plt.legend()
ylims=plt.axes().get_ylim()
plt.yticks((arange(9)-4)*0.5*pi, ['$-2\pi$','$-3\pi/2$','$-\pi$','$-\pi/2$','$0$','$\pi/2$','$\pi$','$3\pi/2$','$2\pi$'])
plt.ylim(ylims)
plt.title('RMS offset from smooth curve: {:.4f}'.format(rmsval))
if self.show: plt.show()
else: plt.savefig(join(self.sdc.plotpath,'salpha','c{}_salpha_on_{}_circle'.format(self.sdc.case,self.ZorY)+self.sdc.suffix+self.sdc.outsuffix+suffix+'.png'), dpi=240)
plt.close()
示例14: plot_axis_control
def plot_axis_control(self, axis,
show_mux_cmd=True, show_asctec_cmd=True, show_vicon_meas=True, show_imu_meas=True):
axismap = {'roll': (self.v.control.roll_cmd, 2, +1, self.v.asctec_ctrl_input.roll_cmd, -1),
'pitch': (self.v.control.pitch_cmd, 1, -1, self.v.asctec_ctrl_input.pitch_cmd, -1),
'yaw': (self.v.control.yaw_cmd, 0, -1, self.v.asctec_ctrl_input.yaw_rate_cmd, +1) # not sure about the multiplier here
}
control_mode_cmd, state_axis, imu_mult, asctec_cmd, asctec_cmd_mult = axismap[axis]
newfig("%s Axis Control" % axis.capitalize(), "time [s]", "%s [deg]" % axis.capitalize())
# np.clip() and the [1:] stuff in the following to attempt deal with bogus initial data points in IMU data:
if show_mux_cmd:
plt.plot(self.v.control.t[self.v.control.istart:self.v.control.iend],
control_mode_cmd[self.v.control.istart:self.v.control.iend], label='cmd (from mux)')
if show_vicon_meas:
plt.plot(self.v.state.t[self.v.state.istart:self.v.state.iend],
self.v.state.ori_ypr[self.v.state.istart:self.v.state.iend, state_axis], label='meas (Vicon)')
if show_imu_meas:
plt.plot(np.clip(self.v.imu.t[self.v.imu.istart:self.v.imu.iend], 0, np.inf),
imu_mult*self.v.imu.ori_ypr[self.v.imu.istart:self.v.imu.iend, state_axis], label='meas (IMU)')
if show_asctec_cmd and axis is not 'yaw':
plt.plot(self.v.asctec_ctrl_input.t[self.v.asctec_ctrl_input.istart:self.v.asctec_ctrl_input.iend],
asctec_cmd_mult*asctec_cmd[self.v.asctec_ctrl_input.istart:self.v.asctec_ctrl_input.iend],
label='cmd (AscTec)')
# Plot difference between vicon and imu: (broken, comment it out for now..)
# tout, data_out = uniform_resample((('linear', self.v.imu.t[self.v.asctec_ctrl_input.istart:self.v.asctec_ctrl_input.iend],
# self.v.imu.ori_ypr[self.v.asctec_ctrl_input.istart:self.v.asctec_ctrl_input.iend,state_axis]),
# ('linear', self.v.state.t[self.v.state.istart:self.v.state.iend],
# self.v.state.ori_ypr[self.v.state.istart:self.v.state.iend, state_axis])),
# 0.02)
# plt.plot(tout, imu_mult*data_out[0][0] - data_out[1][0], label='IMU - Vicon')
plt.legend()
self._timeseries_postplot()
示例15: draw
def draw(cls, t_max, agents_proportions, suffix):
color_set = ["green", "blue", "red"]
for agent_type in range(3):
plt.plot(np.arange(t_max), agents_proportions[:, agent_type],
color=color_set[agent_type], linewidth=1.0)
plt.ylim([0, 1])
# plt.suptitle('Direct choices proportion per type of agents', fontsize=14, fontweight='bold')
# plt.legend(loc='lower left', frameon=False)
plt.savefig("figure_{}.pdf".format(suffix))