本文整理汇总了Python中pylab.plot方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.plot方法的具体用法?Python pylab.plot怎么用?Python pylab.plot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.plot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lines_dists
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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()
示例2: test_proj
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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()
示例3: plot_roc_curve
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def plot_roc_curve(y_true, y_score, size=None):
"""plot_roc_curve."""
false_positive_rate, true_positive_rate, thresholds = roc_curve(
y_true, y_score)
if size is not None:
plt.figure(figsize=(size, size))
plt.axis('equal')
plt.plot(false_positive_rate, true_positive_rate, lw=2, color='navy')
plt.plot([0, 1], [0, 1], color='gray', lw=1, linestyle='--')
plt.xlabel('False positive rate')
plt.ylabel('True positive rate')
plt.ylim([-0.05, 1.05])
plt.xlim([-0.05, 1.05])
plt.grid()
plt.title('Receiver operating characteristic AUC={0:0.2f}'.format(
roc_auc_score(y_true, y_score)))
示例4: plot_stats
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def plot_stats(x=None, y=None, label=None, color='navy'):
"""plot_stats."""
y = np.array(y)
y0 = y[0]
y1 = y[1]
y2 = y[2]
y3 = y[3]
y4 = y[4]
plt.fill_between(x, y3, y4, color=color, alpha=0.08)
plt.fill_between(x, y1, y2, color=color, alpha=0.08)
plt.plot(x, y0, '-', lw=2, color=color, label=label)
plt.plot(x, y0,
linestyle='None',
markerfacecolor='white',
markeredgecolor=color,
marker='o',
markeredgewidth=2,
markersize=8)
示例5: train
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def train(self):
# self.load_model('./save_model/cartpole_a3c.h5')
agents = [Agent(i, self.actor, self.critic, self.optimizer, self.env_name, self.discount_factor,
self.action_size, self.state_size) for i in range(self.threads)]
for agent in agents:
agent.start()
while True:
time.sleep(20)
plot = scores[:]
pylab.plot(range(len(plot)), plot, 'b')
pylab.savefig("./save_graph/cartpole_a3c.png")
self.save_model('./save_model/cartpole_a3c.h5')
示例6: test_lines_dists
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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()
示例7: plot_it
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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()
示例8: plot_question2
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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
示例9: plot_question3
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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
示例10: polyfitting
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [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()
示例11: plot_question7
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def plot_question7():
'''
graph of total resources generated as a function of time,
for upgrade_cost_increment == 1
'''
data = resources_vs_time(1.0, 50)
time = [item[0] for item in data]
resource = [item[1] for item in data]
a, b, c = pylab.polyfit(time, resource, 2)
print 'polyfit with argument \'2\' fits the data, thus the degree of the polynomial is 2 (quadratic)'
# plot in pylab on logarithmic scale (total resources over time for upgrade growth 0.0)
#pylab.loglog(time, resource, 'o')
# plot fitting function
yp = pylab.polyval([a, b, c], time)
pylab.plot(time, yp)
pylab.scatter(time, resource)
pylab.title('Silly Homework, Question 7')
pylab.legend(('Resources for increment 1', 'Fitting function' + ', slope: ' + str(a)))
pylab.xlabel('Current Time')
pylab.ylabel('Total Resources Generated')
pylab.grid()
pylab.show()
示例12: plot_entropy
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def plot_entropy(self):
"""
Returns:
"""
try:
import pylab as plt
except ImportError:
import matplotlib.pyplot as plt
plt.plot(
self.temperatures,
self.eV_to_J_per_mol / self.num_atoms * self.get_entropy_p(),
label="S$_p$",
)
plt.plot(
self.temperatures,
self.eV_to_J_per_mol / self.num_atoms * self.get_entropy_v(),
label="S$_V$",
)
plt.legend()
plt.xlabel("Temperature [K]")
plt.ylabel("Entropy [J K$^{-1}$ mol-atoms$^{-1}$]")
示例13: contour_pressure
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def contour_pressure(self):
"""
Returns:
"""
try:
import pylab as plt
except ImportError:
import matplotlib.pyplot as plt
x, y = self.meshgrid()
p_coeff = np.polyfit(self.volumes, self.pressure.T, deg=self._fit_order)
p_grid = np.array([np.polyval(p_coeff, v) for v in self._volumes]).T
plt.contourf(x, y, p_grid)
plt.plot(self.get_minimum_energy_path(), self.temperatures)
plt.xlabel("Volume [$\AA^3$]")
plt.ylabel("Temperature [K]")
示例14: contour_entropy
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def contour_entropy(self):
"""
Returns:
"""
try:
import pylab as plt
except ImportError:
import matplotlib.pyplot as plt
s_coeff = np.polyfit(self.volumes, self.entropy.T, deg=self._fit_order)
s_grid = np.array([np.polyval(s_coeff, v) for v in self.volumes]).T
x, y = self.meshgrid()
plt.contourf(x, y, s_grid)
plt.plot(self.get_minimum_energy_path(), self.temperatures)
plt.xlabel("Volume [$\AA^3$]")
plt.ylabel("Temperature [K]")
示例15: plot_contourf
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import plot [as 别名]
def plot_contourf(self, ax=None, show_min_erg_path=False):
"""
Args:
ax:
show_min_erg_path:
Returns:
"""
try:
import pylab as plt
except ImportError:
import matplotlib.pyplot as plt
x, y = self.meshgrid()
if ax is None:
fig, ax = plt.subplots(1, 1)
ax.contourf(x, y, self.energies)
if show_min_erg_path:
plt.plot(self.get_minimum_energy_path(), self.temperatures, "w--")
plt.xlabel("Volume [$\AA^3$]")
plt.ylabel("Temperature [K]")
return ax