Python matplotlib.ticker.PercentFormatter() Examples

The following are 10 code examples of matplotlib.ticker.PercentFormatter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.ticker , or try the search function .
Example #1
Source File: test_ticker.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #2
Source File: test_ticker.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #3
Source File: testelementplot.py    From holoviews with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #4
Source File: testelementplot.py    From holoviews with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #5
Source File: testelementplot.py    From holoviews with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #6
Source File: rl_train.py    From pairstrade-fyp-2019 with MIT License 5 votes vote down vote up
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 
Example #7
Source File: test_ticker.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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 
Example #8
Source File: test_ticker.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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 
Example #9
Source File: test_ticker.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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 
Example #10
Source File: test_ticker.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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