python colorbar xtick locator_Python pyplot.MaxNLocator方法代碼示例

本文详细整理了Python中matplotlib.pyplot.MaxNLocator方法的常见用法,包括在图像坐标轴上设置整数刻度等。通过多个示例代码,展示了如何在不同场景下应用MaxNLocator进行刻度定位,适用于需要精确控制图像刻度显示的场景。
摘要由CSDN通过智能技术生成

本文整理匯總了Python中matplotlib.pyplot.MaxNLocator方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.MaxNLocator方法的具體用法?Python pyplot.MaxNLocator怎麽用?Python pyplot.MaxNLocator使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊matplotlib.pyplot的用法示例。

在下文中一共展示了pyplot.MaxNLocator方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。

示例1: plot_overlap_matrix

​點讚 6

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def plot_overlap_matrix(overlap_matrix, color_map="bwr"):

"""

Visualizes the pattern overlap

Args:

overlap_matrix:

color_map:

"""

plt.imshow(overlap_matrix, interpolation="nearest", cmap=color_map)

plt.title("pattern overlap m(i,k)")

plt.xlabel("pattern k")

plt.ylabel("pattern i")

plt.axes().get_xaxis().set_major_locator(plt.MaxNLocator(integer=True))

plt.axes().get_yaxis().set_major_locator(plt.MaxNLocator(integer=True))

cb = plt.colorbar(ticks=np.arange(-1, 1.01, 0.25).tolist())

cb.set_clim(-1, 1)

plt.show()

開發者ID:EPFL-LCN,項目名稱:neuronaldynamics-exercises,代碼行數:21,

示例2: test_contourf_symmetric_locator

​點讚 5

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def test_contourf_symmetric_locator():

# github issue 7271

z = np.arange(12).reshape((3, 4))

locator = plt.MaxNLocator(nbins=4, symmetric=True)

cs = plt.contourf(z, locator=locator)

assert_array_almost_equal(cs.levels, np.linspace(-12, 12, 5))

開發者ID:holzschu,項目名稱:python3_ios,代碼行數:8,

示例3: plot_state_sequence_and_overlap

​點讚 5

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def plot_state_sequence_and_overlap(state_sequence, pattern_list, reference_idx, color_map="brg", suptitle=None):

"""

For each time point t ( = index of state_sequence), plots the sequence of states and the overlap (barplot)

between state(t) and each pattern.

Args:

state_sequence: (list(numpy.ndarray))

pattern_list: (list(numpy.ndarray))

reference_idx: (int) identifies the pattern in pattern_list for which wrong pixels are colored.

"""

if reference_idx is None:

reference_idx = 0

reference = pattern_list[reference_idx]

f, ax = plt.subplots(2, len(state_sequence))

if len(state_sequence) == 1:

ax = [ax]

_plot_list(ax[0, :], state_sequence, reference, "S{0}", color_map)

for i in range(len(state_sequence)):

overlap_list = pattern_tools.compute_overlap_list(state_sequence[i], pattern_list)

ax[1, i].bar(range(len(overlap_list)), overlap_list)

ax[1, i].set_title("m = {1}".format(i, round(overlap_list[reference_idx], 2)))

ax[1, i].set_ylim([-1, 1])

ax[1, i].get_xaxis().set_major_locator(plt.MaxNLocator(integer=True))

if i > 0: # show lables only for the first subplot

ax[1, i].set_xticklabels([])

ax[1, i].set_yticklabels([])

if suptitle is not None:

f.suptitle(suptitle)

plt.show()

開發者ID:EPFL-LCN,項目名稱:neuronaldynamics-exercises,代碼行數:31,

示例4: plot_prediction

​點讚 5

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def plot_prediction(ax, inputs, mean, std, area=2):

order = np.argsort(inputs)

inputs, mean, std = inputs[order], mean[order], std[order]

ax.plot(inputs, mean, alpha=0.5)

ax.fill_between(

inputs, mean - area * std, mean + area * std, alpha=0.1, lw=0)

ax.yaxis.set_major_locator(plt.MaxNLocator(5, prune='both'))

ax.set_xlim(inputs.min(), inputs.max())

min_, max_ = inputs.min(), inputs.max()

min_ -= 0.1 * (max_ - min_ + 1e-6)

max_ += 0.1 * (max_ - min_ + 1e-6)

ax.set_xlim(min_, max_)

ax.yaxis.tick_right()

ax.yaxis.set_label_coords(-0.05, 0.5)

開發者ID:brain-research,項目名稱:ncp,代碼行數:16,

示例5: plot_std_area

​點讚 5

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def plot_std_area(ax, inputs, std, **kwargs):

kwargs['alpha'] = kwargs.get('alpha', 0.5)

kwargs['lw'] = kwargs.get('lw', 0.0)

order = np.argsort(inputs)

inputs, std = inputs[order], std[order]

ax.fill_between(inputs, std, 0 * std, **kwargs)

ax.set_xlim(inputs.min(), inputs.max())

ax.set_ylim(0, std.max())

ax.yaxis.set_major_locator(plt.MaxNLocator(4, prune='both'))

ax.yaxis.tick_right()

ax.yaxis.set_label_coords(-0.05, 0.5)

開發者ID:brain-research,項目名稱:ncp,代碼行數:13,

示例6: plot_results

​點讚 5

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def plot_results(args):

load_results = lambda x: tools.load_results(

os.path.join(args.logdir, x) + '-*/*.npz')

results = [

('BBB+NCP', load_results('bbb_ncp')),

('ODC+NCP', load_results('det_mix_ncp')),

('BBB', load_results('bbb')),

('Det', load_results('det')),

]

fig, ax = plt.subplots(ncols=4, figsize=(8, 2))

for a in ax:

a.xaxis.set_major_locator(plt.MaxNLocator(5))

a.yaxis.set_major_locator(plt.MaxNLocator(5))

tools.plot_distance(ax[0], results, 'train_distances', {})

ax[0].set_xlabel('Data points seen')

ax[0].set_title('Train RMSE')

ax[0].set_ylim(0.1, 0.5)

tools.plot_likelihood(ax[1], results, 'train_likelihoods', {})

ax[1].set_xlabel('Data points seen')

ax[1].set_title('Train NLPD')

ax[1].set_ylim(-0.8, 0.7)

tools.plot_distance(ax[2], results, 'test_distances', {})

ax[2].set_xlabel('Data points seen')

ax[2].set_title('Test RMSE')

ax[2].set_ylim(0.35, 0.55)

tools.plot_likelihood(ax[3], results, 'test_likelihoods', {})

ax[3].set_xlabel('Data points seen')

ax[3].set_title('Test NLPD')

ax[3].set_ylim(0.4, 1.3)

ax[3].legend(frameon=False, labelspacing=0.2, borderpad=0)

fig.tight_layout(pad=0, w_pad=0.5)

filename = os.path.join(args.logdir, 'results.pdf')

fig.savefig(filename)

開發者ID:brain-research,項目名稱:ncp,代碼行數:35,

示例7: plot_figures

​點讚 5

# 需要導入模塊: from matplotlib import pyplot [as 別名]

# 或者: from matplotlib.pyplot import MaxNLocator [as 別名]

def plot_figures(self, prev_subplot_map=None):

subplot_map = {}

for idx, (environment, full_file_path) in enumerate(self.environments):

environment = environment.split('level')[1].split('-')[1].split('Deterministic')[0][1:]

if prev_subplot_map:

# skip on environments which were not plotted before

if environment not in prev_subplot_map.keys():

continue

subplot_idx = prev_subplot_map[environment]

else:

subplot_idx = idx + 1

print(environment)

axis = plt.subplot(self.rows, self.cols, subplot_idx)

subplot_map[environment] = subplot_idx

signals = SignalsFile(full_file_path)

signals.change_averaging_window(self.smoothness, force=True, signals=[self.signal_to_plot])

steps = signals.bokeh_source.data[self.x_axis]

rewards = signals.bokeh_source.data[self.signal_to_plot]

yloc = plt.MaxNLocator(4)

axis.yaxis.set_major_locator(yloc)

axis.ticklabel_format(style='sci', axis='x', scilimits=(0, 0))

plt.title(environment, fontsize=10, y=1.08)

plt.plot(steps, rewards, self.color, linewidth=0.8)

plt.subplots_adjust(hspace=2.0, wspace=0.4)

return subplot_map

開發者ID:NervanaSystems,項目名稱:coach,代碼行數:29,

注:本文中的matplotlib.pyplot.MaxNLocator方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值