本文整理匯總了Python中matplotlib.pyplot.yticks方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.yticks方法的具體用法?Python pyplot.yticks怎麽用?Python pyplot.yticks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.yticks方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: plot_n_image
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plot_n_image(X, n):
""" plot first n images
n has to be a square number
"""
pic_size = int(np.sqrt(X.shape[1]))
grid_size = int(np.sqrt(n))
first_n_images = X[:n, :]
fig, ax_array = plt.subplots(nrows=grid_size, ncols=grid_size,
sharey=True, sharex=True, figsize=(8, 8))
for r in range(grid_size):
for c in range(grid_size):
ax_array[r, c].imshow(first_n_images[grid_size * r + c].reshape((pic_size, pic_size)))
plt.xticks(np.array([]))
plt.yticks(np.array([]))
示例2: plot_tsne
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plot_tsne(self, save_eps=False):
''' Plot TSNE figure. Set save_eps=True if you want to save a .eps file.
'''
tsne = TSNE(n_components=2, init='pca', random_state=0)
features = tsne.fit_transform(self.features)
x_min, x_max = np.min(features, 0), np.max(features, 0)
data = (features - x_min) / (x_max - x_min)
del features
for i in range(data.shape[0]):
plt.text(data[i, 0], data[i, 1], str(self.labels[i]),
color=plt.cm.Set1(self.labels[i] / 10.),
fontdict={'weight': 'bold', 'size': 9})
plt.xticks([])
plt.yticks([])
plt.title('T-SNE')
if save_eps:
plt.savefig('tsne.eps', dpi=600, format='eps')
plt.show()
示例3: make_plot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def make_plot(files, labels):
plt.figure()
for file_idx in range(len(files)):
rot_err, trans_err = read_csv(files[file_idx])
success_dict = count_success(trans_err)
x_range = success_dict.keys()
x_range.sort()
success = []
for i in x_range:
success.append(success_dict[i])
success = np.array(success)/total_cases
plt.plot(x_range, success, linewidth=3, label=labels[file_idx])
# plt.scatter(x_range, success, s=50)
plt.ylabel('Success Ratio', fontsize=40)
plt.xlabel('Threshold for Translation Error', fontsize=40)
plt.tick_params(labelsize=40, width=3, length=10)
plt.grid(True)
plt.ylim(0,1.005)
plt.yticks(np.arange(0,1.2,0.2))
plt.xticks(np.arange(0,2.1,0.2))
plt.xlim(0,2)
plt.legend(fontsize=30, loc=4)
示例4: _show_plot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
示例5: save_movie_to_frame
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def save_movie_to_frame(images, filename, idx=0, cmap='Blues'):
# Collect to single image
image = movie_to_frame(images[idx])
# Flip it
# image = np.fliplr(image)
# image = np.flipud(image)
f = plt.figure(figsize=[12, 12])
plt.imshow(image, cmap=plt.cm.get_cmap(cmap), interpolation='none', vmin=0, vmax=1)
plt.axis('image')
plt.xticks([])
plt.yticks([])
plt.savefig(filename, format='png', bbox_inches='tight', dpi=80)
plt.close(f)
示例6: imshow
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def imshow(data, which, levels):
"""
Display order book data as an image, where order book data is either of
`df_price` or `df_volume` returned by `load_hdf5` or `load_postgres`.
"""
if which == 'prices':
idx = ['askprc.' + str(i) for i in range(levels, 0, -1)]
idx.extend(['bidprc.' + str(i) for i in range(1, levels + 1, 1)])
elif which == 'volumes':
idx = ['askvol.' + str(i) for i in range(levels, 0, -1)]
idx.extend(['bidvol.' + str(i) for i in range(1, levels + 1, 1)])
plt.imshow(data.loc[:, idx].T, interpolation='nearest', aspect='auto')
plt.yticks(range(0, levels * 2, 1), idx)
plt.colorbar()
plt.tight_layout()
plt.show()
示例7: show_classification_areas
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def show_classification_areas(X, Y, lr):
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.02), np.arange(y_min, y_max, 0.02))
Z = lr.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.figure(1, figsize=(30, 25))
plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Pastel1)
# Plot also the training points
plt.scatter(X[:, 0], X[:, 1], c=np.abs(Y - 1), edgecolors='k', cmap=plt.cm.coolwarm)
plt.xlabel('X')
plt.ylabel('Y')
plt.xlim(xx.min(), xx.max())
plt.ylim(yy.min(), yy.max())
plt.xticks(())
plt.yticks(())
plt.show()
開發者ID:PacktPublishing,項目名稱:Fundamentals-of-Machine-Learning-with-scikit-learn,代碼行數:23,代碼來源:1logistic_regression.py
示例8: plotSigHeats
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plotSigHeats(signals,markets,start=0,step=2,size=1,iters=6):
"""
打印信號回測盈損熱度圖,尋找參數穩定島
"""
sigMat = pd.DataFrame(index=range(iters),columns=range(iters))
for i in range(iters):
for j in range(iters):
climit = start + i*step
wlimit = start + j*step
caps,poss = plotSigCaps(signals,markets,climit=climit,wlimit=wlimit,size=size,op=False)
sigMat[i][j] = caps[-1]
sns.heatmap(sigMat.values.astype(np.float64),annot=True,fmt='.2f',annot_kws={"weight": "bold"})
xTicks = [i+0.5 for i in range(iters)]
yTicks = [iters-i-0.5 for i in range(iters)]
xyLabels = [str(start+i*step) for i in range(iters)]
_, labels = plt.yticks(yTicks,xyLabels)
plt.setp(labels, rotation=0)
_, labels = plt.xticks(xTicks,xyLabels)
plt.setp(labels, rotation=90)
plt.xlabel('Loss Stop @')
plt.ylabel('Profit Stop @')
return sigMat
示例9: subfig_evo_rad_pow
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def subfig_evo_rad_pow(ax_rad_pow, g, legend, log=1, **kwargs):
ax_rad_pow.plot(g.z, np.amax(g.p_int, axis=0), 'g-', linewidth=1.5)
ax_rad_pow.set_ylabel('P [W]')
ax_rad_pow.get_yaxis().get_major_formatter().set_useOffset(False)
ax_rad_pow.get_yaxis().get_major_formatter().set_scientific(True)
if np.amax(g.p_int) > 0 and log:
ax_rad_pow.set_yscale('log')
plt.yticks(plt.yticks()[0][0:-1])
ax_rad_pow.grid(False) # , which='minor')
ax_rad_pow.tick_params(axis='y', which='both', colors='g')
ax_rad_pow.yaxis.label.set_color('g')
ax_rad_pow.yaxis.get_offset_text().set_color(ax_rad_pow.yaxis.label.get_color())
if kwargs.get('showtext', True):
ax_rad_pow.text(0.98, 0.02, r'$P_{end}$= %.2e W' % (np.amax(g.p_int[:, -1])), fontsize=12,
horizontalalignment='right', verticalalignment='bottom', transform=ax_rad_pow.transAxes)
示例10: plot_embedding
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plot_embedding(data, label, title):
ids = np.unique(label)
label_color = label.copy()
for i, label_id in enumerate(ids):
label_color[label_color==label_id] = i
x_min, x_max = np.min(data, 0), np.max(data, 0)
data = (data - x_min) / (x_max - x_min)
fig = plt.figure()
ax = plt.subplot(111)
for i in range(data.shape[0]):
plt.text(data[i, 0], data[i, 1], str(label[i]),
color=plt.cm.Set1(label_color[i] / 10.),
fontdict={'weight': 'bold', 'size': 9})
plt.xticks([])
plt.yticks([])
plt.title(title)
plt.show()
return fig
示例11: update
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def update(self, conf_mat, classes, normalize=False):
"""This function prints and plots the confusion matrix.
Normalization can be applied by setting `normalize=True`.
"""
plt.imshow(conf_mat, interpolation='nearest', cmap=self.cmap)
plt.title(self.title)
plt.colorbar()
tick_marks = np.arange(len(classes))
plt.xticks(tick_marks, classes, rotation=45)
plt.yticks(tick_marks, classes)
if normalize:
conf_mat = conf_mat.astype('float') / conf_mat.sum(axis=1)[:, np.newaxis]
thresh = conf_mat.max() / 2.
for i, j in itertools.product(range(conf_mat.shape[0]), range(conf_mat.shape[1])):
plt.text(j, i, conf_mat[i, j],
horizontalalignment="center",
color="white" if conf_mat[i, j] > thresh else "black")
plt.tight_layout()
plt.ylabel('True label')
plt.xlabel('Predicted label')
plt.draw()
示例12: main
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def main():
colors = "rgbcmyk"
d = grap_all_feat_corr_dict()
keys = sorted(d.keys())
N = len(keys)
fig = plt.figure()
ax = fig.add_subplot(111)
for e,k in enumerate(keys, start=1):
vals = sorted(d[k])
color = colors[(e-1) % len(colors)]
plt.bar(np.linspace(e-0.48,e+0.48,len(vals)), vals,
width=1./(len(vals)+10), color=color, edgecolor=color)
plt.xlabel("Feature Group", fontsize=15)
plt.ylabel("Correlation Coefficient", fontsize=15)
plt.xticks(range(1,N+1), fontsize=15)
plt.yticks([-0.4, -0.2, 0, 0.2, 0.4], fontsize=15)
ax.set_xticklabels(keys, rotation=45, ha="right")
ax.set_xlim([0, N+1])
ax.set_ylim([-0.4, 0.4])
pos1 = ax.get_position()
pos2 = [pos1.x0 - 0.075, pos1.y0 + 0.175, pos1.width * 1.2, pos1.height * 0.85]
ax.set_position(pos2)
plt.show()
示例13: plot_preds
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plot_preds(image, preds):
"""Displays image and the top-n predicted probabilities in a bar graph
Args:
image: PIL image
preds: list of predicted labels and their probabilities
"""
"""# For Spyder
plt.imshow(image)
plt.axis('off')"""
plt.figure()
labels = ("cat", "dog")
plt.barh([0, 1], preds, alpha=0.5)
plt.yticks([0, 1], labels)
plt.xlabel('Probability')
plt.xlim(0,1.01)
plt.tight_layout()
plt.savefig('out.png')
示例14: plot_i
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plot_i(Image, nit, chi2, fig=1, cmap='afmhot'):
"""Plot the total intensity image at each iteration
"""
plt.ion()
plt.figure(fig)
plt.pause(0.00001)
plt.clf()
plt.imshow(Image.imvec.reshape(Image.ydim,Image.xdim), cmap=plt.get_cmap(cmap), interpolation='gaussian')
xticks = ticks(Image.xdim, Image.psize/RADPERAS/1e-6)
yticks = ticks(Image.ydim, Image.psize/RADPERAS/1e-6)
plt.xticks(xticks[0], xticks[1])
plt.yticks(yticks[0], yticks[1])
plt.xlabel('Relative RA ($\mu$as)')
plt.ylabel('Relative Dec ($\mu$as)')
plt.title("step: %i $\chi^2$: %f " % (nit, chi2), fontsize=20)
示例15: plot_bad_images
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import yticks [as 別名]
def plot_bad_images(images):
"""This takes a list of images misclassified by a pretty good
neural network --- one achieving over 93 percent accuracy --- and
turns them into a figure."""
bad_image_indices = [8, 18, 33, 92, 119, 124, 149, 151, 193, 233, 241, 247, 259, 300, 313, 321, 324, 341, 349, 352, 359, 362, 381, 412, 435, 445, 449, 478, 479, 495, 502, 511, 528, 531, 547, 571, 578, 582, 597, 610, 619, 628, 629, 659, 667, 691, 707, 717, 726, 740, 791, 810, 844, 846, 898, 938, 939, 947, 956, 959, 965, 982, 1014, 1033, 1039, 1044, 1050, 1055, 1107, 1112, 1124, 1147, 1181, 1191, 1192, 1198, 1202, 1204, 1206, 1224, 1226, 1232, 1242, 1243, 1247, 1256, 1260, 1263, 1283, 1289, 1299, 1310, 1319, 1326, 1328, 1357, 1378, 1393, 1413, 1422, 1435, 1467, 1469, 1494, 1500, 1522, 1523, 1525, 1527, 1530, 1549, 1553, 1609, 1611, 1634, 1641, 1676, 1678, 1681, 1709, 1717, 1722, 1730, 1732, 1737, 1741, 1754, 1759, 1772, 1773, 1790, 1808, 1813, 1823, 1843, 1850, 1857, 1868, 1878, 1880, 1883, 1901, 1913, 1930, 1938, 1940, 1952, 1969, 1970, 1984, 2001, 2009, 2016, 2018, 2035, 2040, 2043, 2044, 2053, 2063, 2098, 2105, 2109, 2118, 2129, 2130, 2135, 2148, 2161, 2168, 2174, 2182, 2185, 2186, 2189, 2224, 2229, 2237, 2266, 2272, 2293, 2299, 2319, 2325, 2326, 2334, 2369, 2371, 2380, 2381, 2387, 2393, 2395, 2406, 2408, 2414, 2422, 2433, 2450, 2488, 2514, 2526, 2548, 2574, 2589, 2598, 2607, 2610, 2631, 2648, 2654, 2695, 2713, 2720, 2721, 2730, 2770, 2771, 2780, 2863, 2866, 2896, 2907, 2925, 2927, 2939, 2995, 3005, 3023, 3030, 3060, 3073, 3102, 3108, 3110, 3114, 3115, 3117, 3130, 3132, 3157, 3160, 3167, 3183, 3189, 3206, 3240, 3254, 3260, 3280, 3329, 3330, 3333, 3383, 3384, 3475, 3490, 3503, 3520, 3525, 3559, 3567, 3573, 3597, 3598, 3604, 3629, 3664, 3702, 3716, 3718, 3725, 3726, 3727, 3751, 3752, 3757, 3763, 3766, 3767, 3769, 3776, 3780, 3798, 3806, 3808, 3811, 3817, 3821, 3838, 3848, 3853, 3855, 3869, 3876, 3902, 3906, 3926, 3941, 3943, 3951, 3954, 3962, 3976, 3985, 3995, 4000, 4002, 4007, 4017, 4018, 4065, 4075, 4078, 4093, 4102, 4139, 4140, 4152, 4154, 4163, 4165, 4176, 4199, 4201, 4205, 4207, 4212, 4224, 4238, 4248, 4256, 4284, 4289, 4297, 4300, 4306, 4344, 4355, 4356, 4359, 4360, 4369, 4405, 4425, 4433, 4435, 4449, 4487, 4497, 4498, 4500, 4521, 4536, 4548, 4563, 4571, 4575, 4601, 4615, 4620, 4633, 4639, 4662, 4690, 4722, 4731, 4735, 4737, 4739, 4740, 4761, 4798, 4807, 4814, 4823, 4833, 4837, 4874, 4876, 4879, 4880, 4886, 4890, 4910, 4950, 4951, 4952, 4956, 4963, 4966, 4968, 4978, 4990, 5001, 5020, 5054, 5067, 5068, 5078, 5135, 5140, 5143, 5176, 5183, 5201, 5210, 5331, 5409, 5457, 5495, 5600, 5601, 5617, 5623, 5634, 5642, 5677, 5678, 5718, 5734, 5735, 5749, 5752, 5771, 5787, 5835, 5842, 5845, 5858, 5887, 5888, 5891, 5906, 5913, 5936, 5937, 5945, 5955, 5957, 5972, 5973, 5985, 5987, 5997, 6035, 6042, 6043, 6045, 6053, 6059, 6065, 6071, 6081, 6091, 6112, 6124, 6157, 6166, 6168, 6172, 6173, 6347, 6370, 6386, 6390, 6391, 6392, 6421, 6426, 6428, 6505, 6542, 6555, 6556, 6560, 6564, 6568, 6571, 6572, 6597, 6598, 6603, 6608, 6625, 6651, 6694, 6706, 6721, 6725, 6740, 6746, 6768, 6783, 6785, 6796, 6817, 6827, 6847, 6870, 6872, 6926, 6945, 7002, 7035, 7043, 7089, 7121, 7130, 7198, 7216, 7233, 7248, 7265, 7426, 7432, 7434, 7494, 7498, 7691, 7777, 7779, 7797, 7800, 7809, 7812, 7821, 7849, 7876, 7886, 7897, 7902, 7905, 7917, 7921, 7945, 7999, 8020, 8059, 8081, 8094, 8095, 8115, 8246, 8256, 8262, 8272, 8273, 8278, 8279, 8293, 8322, 8339, 8353, 8408, 8453, 8456, 8502, 8520, 8522, 8607, 9009, 9010, 9013, 9015, 9019, 9022, 9024, 9026, 9036, 9045, 9046, 9128, 9214, 9280, 9316, 9342, 9382, 9433, 9446, 9506, 9540, 9544, 9587, 9614, 9634, 9642, 9645, 9700, 9716, 9719, 9729, 9732, 9738, 9740, 9741, 9742, 9744, 9745, 9749, 9752, 9768, 9770, 9777, 9779, 9792, 9808, 9831, 9839, 9856, 9858, 9867, 9879, 9883, 9888, 9890, 9893, 9905, 9944, 9970, 9982]
n = len(bad_image_indices)
bad_images = [images[j] for j in bad_image_indices]
fig = plt.figure(figsize=(10, 15))
for j in xrange(1, n+1):
ax = fig.add_subplot(25, 125, j)
ax.matshow(bad_images[j-1], cmap = matplotlib.cm.binary)
ax.set_title(str(bad_image_indices[j-1]))
plt.xticks(np.array([]))
plt.yticks(np.array([]))
plt.subplots_adjust(hspace = 1.2)
plt.show()