本文整理汇总了Python中matplotlib.ticker.PercentFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python ticker.PercentFormatter方法的具体用法?Python ticker.PercentFormatter怎么用?Python ticker.PercentFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.ticker
的用法示例。
在下文中一共展示了ticker.PercentFormatter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import PercentFormatter [as 别名]
def test_basic(self, xmax, decimals, symbol,
x, display_range, expected):
formatter = mticker.PercentFormatter(xmax, decimals, symbol)
with matplotlib.rc_context(rc={'text.usetex': False}):
assert formatter.format_pct(x, display_range) == expected
示例2: test_latex
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import PercentFormatter [as 别名]
def test_latex(self, is_latex, usetex, expected):
fmt = mticker.PercentFormatter(symbol='\\{t}%', is_latex=is_latex)
with matplotlib.rc_context(rc={'text.usetex': usetex}):
assert fmt.format_pct(50, 100) == expected
示例3: test_element_xformatter_instance
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import PercentFormatter [as 别名]
def test_element_xformatter_instance(self):
formatter = PercentFormatter()
curve = Curve(range(10)).options(xformatter=formatter)
plot = mpl_renderer.get_plot(curve)
xaxis = plot.handles['axis'].xaxis
xformatter = xaxis.get_major_formatter()
self.assertIs(xformatter, formatter)
示例4: test_element_yformatter_instance
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import PercentFormatter [as 别名]
def test_element_yformatter_instance(self):
formatter = PercentFormatter()
curve = Curve(range(10)).options(yformatter=formatter)
plot = mpl_renderer.get_plot(curve)
yaxis = plot.handles['axis'].yaxis
yformatter = yaxis.get_major_formatter()
self.assertIs(yformatter, formatter)
示例5: test_element_zformatter_instance
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import PercentFormatter [as 别名]
def test_element_zformatter_instance(self):
formatter = PercentFormatter()
curve = Scatter3D([]).options(zformatter=formatter)
plot = mpl_renderer.get_plot(curve)
zaxis = plot.handles['axis'].zaxis
zformatter = zaxis.get_major_formatter()
self.assertIs(zformatter, formatter)
示例6: plot_rs_dist_overlap
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import PercentFormatter [as 别名]
def plot_rs_dist_overlap(rs, fig_title, mean=False, median=False, color=None, methodName=None):
return_in_percent = np.array(rs) / rl_constants.initial_cash
# stat = plt.hist(return_in_percent, bins=30, weights=np.ones(len(return_in_percent)) / len(return_in_percent))
y, binEdges = np.histogram(return_in_percent, bins=50, density=True)
bincenters = 0.5*(binEdges[1:]+binEdges[:-1])
plt.plot(bincenters,y,'-', color=color, label=methodName)
mean_stat = return_in_percent.mean()
median_stat = np.median(return_in_percent)
if mean:
plt.axvline(mean_stat, color=color, linestyle='dashed', linewidth=1, label=methodName+' Mean: {:.3f}'.format(mean_stat))
if median:
plt.axvline(median_stat, color=color, linestyle='dashed', linewidth=1, label=methodName+' Median: {:.3f}'.format(median_stat))
plt.gcf().set_size_inches(14, 7)
# plt.gca().yaxis.set_major_formatter(PercentFormatter(1))
plt.gca().xaxis.set_major_formatter(PercentFormatter(1))
if len(fig_title) != 0:
plt.suptitle(fig_title)
plt.xlabel('return')
plt.ylabel('density of the distribution of all pairs')
plt.legend(loc='upper right')
# print(stat)
_logger.info('Number of pairs:', len(return_in_percent))
_logger.info('Mean return over all pairs: {:.4f}'.format(np.mean(return_in_percent)))
# global batch_id to keep track of the progress