本文整理汇总了Python中pylab.show方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.show方法的具体用法?Python pylab.show怎么用?Python pylab.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: time_upgrades_relationship
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def time_upgrades_relationship():
'''
helper function to show relationship between time and number of upgrades,
for upgrade_cost_increment == 1.0
'''
print 'Time unit / Incremental resources'
data = resources_vs_time(1.0, 10)
time = [item[0] for item in data]
resource = [item[1] for item in data]
for index in xrange(len(time) - 1):
delta = resource[index + 1] - resource[index]
print time[index], '\t', delta
print 'sum is known as a triangular sum, 1/2(n + 1)n; for t it\'s 1/2(t + 1)t'
#time_upgrades_relationship()
# Question 10
示例2: plot_hits
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def plot_hits(filename_fil, filename_dat):
""" Plot the hits in a .dat file. """
table = find_event.read_dat(filename_dat)
print(table)
plt.figure(figsize=(10, 8))
N_hit = len(table)
if N_hit > 10:
print("Warning: More than 10 hits found. Only plotting first 10")
N_hit = 10
for ii in range(N_hit):
plt.subplot(N_hit, 1, ii+1)
plot_event.plot_hit(filename_fil, filename_dat, ii)
plt.tight_layout()
plt.savefig(filename_dat.replace('.dat', '.png'))
plt.show()
示例3: test_lines_dists
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def test_lines_dists():
import pylab
ax = pylab.gca()
xs, ys = (0,30), (20,150)
pylab.plot(xs, ys)
points = list(zip(xs, ys))
p0, p1 = points
xs, ys = (0,0,20,30), (100,150,30,200)
pylab.scatter(xs, ys)
dist = line2d_seg_dist(p0, p1, (xs[0], ys[0]))
dist = line2d_seg_dist(p0, p1, np.array((xs, ys)))
for x, y, d in zip(xs, ys, dist):
c = Circle((x, y), d, fill=0)
ax.add_patch(c)
pylab.xlim(-200, 200)
pylab.ylim(-200, 200)
pylab.show()
示例4: test_proj
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def test_proj():
import pylab
M = test_proj_make_M()
ts = ['%d' % i for i in [0,1,2,3,0,4,5,6,7,4]]
xs, ys, zs = [0,1,1,0,0, 0,1,1,0,0], [0,0,1,1,0, 0,0,1,1,0], \
[0,0,0,0,0, 1,1,1,1,1]
xs, ys, zs = [np.array(v)*300 for v in (xs, ys, zs)]
#
test_proj_draw_axes(M, s=400)
txs, tys, tzs = proj_transform(xs, ys, zs, M)
ixs, iys, izs = inv_transform(txs, tys, tzs, M)
pylab.scatter(txs, tys, c=tzs)
pylab.plot(txs, tys, c='r')
for x, y, t in zip(txs, tys, ts):
pylab.text(x, y, t)
pylab.xlim(-0.2, 0.2)
pylab.ylim(-0.2, 0.2)
pylab.show()
示例5: execute
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def execute(self):
plt.ion()
if self.inc==0:
try:
pa(self.result_file+'.results').remove()
except:
pass
self.iterations = [self.inc]
self.targvalue = [[getattr(self, i) for i in self.targname]]
self.pre_plot()
else:
self.iterations.append(self.inc)
self.targvalue.append([getattr(self, i) for i in self.targname])
#print self.iterations,self.targvalue
#if self.inc % (2*self.wt_positions.shape[0]) == 0:
#self.refresh()
#plt.show()
self.save_plot('fig/'+self.png_name+'layout%d.png'%(self.inc))
self.inc += 1
示例6: generate
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def generate(self, filename, show=True):
'''Generate a sample sequence, plot the resulting piano-roll and save
it as a MIDI file.
filename : string
A MIDI file will be created at this location.
show : boolean
If True, a piano-roll of the generated sequence will be shown.'''
piano_roll = self.generate_function()
midiwrite(filename, piano_roll, self.r, self.dt)
if show:
extent = (0, self.dt * len(piano_roll)) + self.r
pylab.figure()
pylab.imshow(piano_roll.T, origin='lower', aspect='auto',
interpolation='nearest', cmap=pylab.cm.gray_r,
extent=extent)
pylab.xlabel('time (s)')
pylab.ylabel('MIDI note number')
pylab.title('generated piano-roll')
示例7: test_lines_dists
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def test_lines_dists():
import pylab
ax = pylab.gca()
xs, ys = (0,30), (20,150)
pylab.plot(xs, ys)
points = zip(xs, ys)
p0, p1 = points
xs, ys = (0,0,20,30), (100,150,30,200)
pylab.scatter(xs, ys)
dist = line2d_seg_dist(p0, p1, (xs[0], ys[0]))
dist = line2d_seg_dist(p0, p1, np.array((xs, ys)))
for x, y, d in zip(xs, ys, dist):
c = Circle((x, y), d, fill=0)
ax.add_patch(c)
pylab.xlim(-200, 200)
pylab.ylim(-200, 200)
pylab.show()
示例8: plot
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def plot(self):
"""
Plot startup data.
"""
import pylab
print("Plotting result...", end="")
avg_data = self.average_data()
avg_data = self.__sort_data(avg_data, False)
if len(self.raw_data) > 1:
err = self.stdev_data()
sorted_err = [err[k] for k in list(zip(*avg_data))[0]]
else:
sorted_err = None
pylab.barh(range(len(avg_data)), list(zip(*avg_data))[1],
xerr=sorted_err, align='center', alpha=0.4)
pylab.yticks(range(len(avg_data)), list(zip(*avg_data))[0])
pylab.xlabel("Average startup time (ms)")
pylab.ylabel("Plugins")
pylab.show()
print(" done.")
示例9: plot_it
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def plot_it():
'''
helper function to gain insight on provided data sets background,
using pylab
'''
data1 = [[1.0, 1], [2.25, 3.5], [3.58333333333, 7.5], [4.95833333333, 13.0], [6.35833333333, 20.0], [7.775, 28.5], [9.20357142857, 38.5], [10.6410714286, 50.0], [12.085515873, 63.0], [13.535515873, 77.5]]
data2 = [[1.0, 1], [1.75, 2.5], [2.41666666667, 4.5], [3.04166666667, 7.0], [3.64166666667, 10.0], [4.225, 13.5], [4.79642857143, 17.5], [5.35892857143, 22.0], [5.91448412698, 27.0], [6.46448412698, 32.5], [7.00993867244, 38.5], [7.55160533911, 45.0], [8.09006687757, 52.0], [8.62578116328, 59.5], [9.15911449661, 67.5], [9.69036449661, 76.0], [10.2197762613, 85.0], [10.7475540391, 94.5], [11.2738698286, 104.5], [11.7988698286, 115.0]]
time1 = [item[0] for item in data1]
resource1 = [item[1] for item in data1]
time2 = [item[0] for item in data2]
resource2 = [item[1] for item in data2]
# plot in pylab (total resources over time)
pylab.plot(time1, resource1, 'o')
pylab.plot(time2, resource2, 'o')
pylab.title('Silly Homework')
pylab.legend(('Data Set no.1', 'Data Set no.2'))
pylab.xlabel('Current Time')
pylab.ylabel('Total Resources Generated')
pylab.show()
#plot_it()
示例10: plot_question2
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def plot_question2():
'''
graph of total resources generated as a function of time,
for four various upgrade_cost_increment values
'''
for upgrade_cost_increment in [0.0, 0.5, 1.0, 2.0]:
data = resources_vs_time(upgrade_cost_increment, 5)
time = [item[0] for item in data]
resource = [item[1] for item in data]
# plot in pylab (total resources over time for each constant)
pylab.plot(time, resource, 'o')
pylab.title('Silly Homework')
pylab.legend(('0.0', '0.5', '1.0', '2.0'))
pylab.xlabel('Current Time')
pylab.ylabel('Total Resources Generated')
pylab.show()
#plot_question2()
# Question 3
示例11: plot_question3
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def plot_question3():
'''
graph of total resources generated as a function of time;
for upgrade_cost_increment == 0
'''
data = resources_vs_time(0.0, 100)
time = [item[0] for item in data]
resource = [item[1] for item in data]
# plot in pylab on logarithmic scale (total resources over time for upgrade growth 0.0)
pylab.loglog(time, resource)
pylab.title('Silly Homework')
pylab.legend('0.0')
pylab.xlabel('Current Time')
pylab.ylabel('Total Resources Generated')
pylab.show()
#plot_question3()
# Question 4
示例12: time_upgrades_relationship_0
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def time_upgrades_relationship_0():
'''
helper function to show relationship between time and number of upgrades,
for upgrade_cost_increment == 0.0
'''
print 'Incremental time to achieve upgrade'
data = resources_vs_time(0.0, 11)
time = [item[0] for item in data]
resource = [item[1] for item in data]
for index in xrange(len(time) - 1):
delta1 = time[index + 1] - time[index]
delta2 = resource[index + 1] - resource[index]
print delta1, '\t\t', delta2
print '\nsum is called a harmonic sum and has only an approximate solution: log(t) + constant;'
print 'question 6 asks for "...we seek the inverse function g for f..." thus e**(t) in form E^t'
#time_upgrades_relationship_0()
# Question 7
示例13: polyfitting
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def polyfitting():
'''
helper function to play around with polyfit from:
http://www.wired.com/2011/01/linear-regression-with-pylab/
'''
x = [0.2, 1.3, 2.1, 2.9, 3.3]
y = [3.3, 3.9, 4.8, 5.5, 6.9]
slope, intercept = pylab.polyfit(x, y, 1)
print 'slope:', slope, 'intercept:', intercept
yp = pylab.polyval([slope, intercept], x)
pylab.plot(x, yp)
pylab.scatter(x, y)
pylab.show()
#polyfitting()
示例14: test_plotting
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def test_plotting():
""" Some basic plotting tests
TODO: Improve these tests (and the functions for that matter!
"""
filename_fil = os.path.join(HERE, 'Voyager1.single_coarse.fine_res.h5')
fil = bl.Waterfall(filename_fil)
# Test make_waterfall_plots -- needs 6x files
filenames_list = [filename_fil] * 6
target = 'Voyager'
drates = [-0.392226]
fvals = [8419.274785]
f_start = 8419.274374 - 600e-6
f_stop = 8419.274374 + 600e-6
node_string = 'test'
filter_level = 1
plot_event.make_waterfall_plots(filenames_list, target, drates, fvals, f_start, f_stop, node_string, filter_level)
plt.show()
示例15: render_sdf
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import show [as 别名]
def render_sdf(obj_, object_name_):
plt.figure()
# ax = h.add_subplot(111, projection='3d')
# surface_points = np.where(np.abs(sdf.sdf_values) < thresh)
# surface_points = np.array(surface_points)
# surface_points = surface_points[:, np.random.choice(surface_points[0].size, 3000, replace=True)]
# # from IPython import embed; embed()
surface_points = obj_.sdf.surface_points()[0]
surface_points = np.array(surface_points)
ind = np.random.choice(np.arange(len(surface_points)), 1000)
x = surface_points[ind, 0]
y = surface_points[ind, 1]
z = surface_points[ind, 2]
ax = plt.gca(projection=Axes3D.name)
ax.scatter(x, y, z, '.', s=np.ones_like(x) * 0.3, c='b')
ax.set_xlim3d(0, obj_.sdf.dims_[0])
ax.set_ylim3d(0, obj_.sdf.dims_[1])
ax.set_zlim3d(0, obj_.sdf.dims_[2])
plt.title(object_name_)
plt.show()