當前位置: 首頁>>代碼示例>>Python>>正文


Python ticker.PercentFormatter方法代碼示例

本文整理匯總了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 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:7,代碼來源:test_ticker.py

示例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 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:6,代碼來源:test_ticker.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testelementplot.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testelementplot.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testelementplot.py

示例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 
開發者ID:wywongbd,項目名稱:pairstrade-fyp-2019,代碼行數:33,代碼來源:rl_train.py


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