当前位置: 首页>>代码示例>>Python>>正文


Python ticker.FormatStrFormatter方法代码示例

本文整理汇总了Python中matplotlib.ticker.FormatStrFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python ticker.FormatStrFormatter方法的具体用法?Python ticker.FormatStrFormatter怎么用?Python ticker.FormatStrFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.ticker的用法示例。


在下文中一共展示了ticker.FormatStrFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: axisinfo

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def axisinfo(unit, axis):
        'return AxisInfo instance for x and unit'

        if unit == radians:
            return units.AxisInfo(
                majloc=ticker.MultipleLocator(base=np.pi/2),
                majfmt=ticker.FuncFormatter(rad_fn),
                label=unit.fullname,
            )
        elif unit == degrees:
            return units.AxisInfo(
                majloc=ticker.AutoLocator(),
                majfmt=ticker.FormatStrFormatter(r'$%i^\circ$'),
                label=unit.fullname,
            )
        elif unit is not None:
            if hasattr(unit, 'fullname'):
                return units.AxisInfo(label=unit.fullname)
            elif hasattr(unit, 'unit'):
                return units.AxisInfo(label=unit.unit.fullname)
        return None 
开发者ID:holzschu,项目名称:python3_ios,代码行数:23,代码来源:basic_units.py

示例2: _remove_labels_from_axis

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def _remove_labels_from_axis(axis):
    for t in axis.get_majorticklabels():
        t.set_visible(False)

    try:
        # set_visible will not be effective if
        # minor axis has NullLocator and NullFormattor (default)
        import matplotlib.ticker as ticker
        if isinstance(axis.get_minor_locator(), ticker.NullLocator):
            axis.set_minor_locator(ticker.AutoLocator())
        if isinstance(axis.get_minor_formatter(), ticker.NullFormatter):
            axis.set_minor_formatter(ticker.FormatStrFormatter(''))
        for t in axis.get_minorticklabels():
            t.set_visible(False)
    except Exception:   # pragma no cover
        raise
    axis.get_label().set_visible(False) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:_tools.py

示例3: visualization_init

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def visualization_init(self):
        fig = plt.figure(figsize=(12, 6), frameon=False, tight_layout=True)
        fig.canvas.set_window_title(self.servoing_pol.predictor.name)
        gs = gridspec.GridSpec(1, 2)
        plt.show(block=False)

        return_plotter = LossPlotter(fig, gs[0],
                                     format_dicts=[dict(linewidth=2)] * 2,
                                     labels=['mean returns / 10', 'mean discounted returns'],
                                     ylabel='returns')
        return_major_locator = MultipleLocator(1)
        return_major_formatter = FormatStrFormatter('%d')
        return_minor_locator = MultipleLocator(1)
        return_plotter._ax.xaxis.set_major_locator(return_major_locator)
        return_plotter._ax.xaxis.set_major_formatter(return_major_formatter)
        return_plotter._ax.xaxis.set_minor_locator(return_minor_locator)

        learning_plotter = LossPlotter(fig, gs[1], format_dicts=[dict(linewidth=2)] * 2, ylabel='mean evaluation values')
        return fig, return_plotter, learning_plotter 
开发者ID:alexlee-gk,项目名称:visual_dynamics,代码行数:21,代码来源:cem.py

示例4: plot_single_cross_section_3d

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def plot_single_cross_section_3d(data, select, subplot):
  data = data[:, select]
  # subplot.scatter(data[:, 0], data[:, 1], s=20, lw=0, edgecolors='none', alpha=1.0,
  # subplot.plot(data[:, 0], data[:, 1], data[:, 2], color='black', lw=1, alpha=0.4)

  d = data
  # subplot.plot(d[[-1, 0], 0], d[[-1, 0], 1], d[[-1, 0], 2], lw=1, alpha=0.8, color='red')
  # subplot.scatter(d[[-1, 0], 0], d[[-1, 0], 1], d[[-1, 0], 2], lw=10, alpha=0.3, marker=".", color='b')
  d = data
  subplot.scatter(d[:, 0], d[:, 1], d[:, 2], s=4, alpha=1.0, lw=0.5,
                  c=vis._build_radial_colors(len(d)),
                  marker=".",
                  cmap=plt.cm.hsv)
  subplot.plot(data[:, 0], data[:, 1], data[:, 2], color='black', lw=0.2, alpha=0.9)

  subplot.set_xlim([-0.01, 1.01])
  subplot.set_ylim([-0.01, 1.01])
  subplot.set_zlim([-0.01, 1.01])
  ticks = []
  subplot.xaxis.set_ticks(ticks)
  subplot.yaxis.set_ticks(ticks)
  subplot.zaxis.set_ticks(ticks)
  subplot.xaxis.set_major_formatter(ticker.FormatStrFormatter('%1.0f'))
  subplot.yaxis.set_major_formatter(ticker.FormatStrFormatter('%1.0f')) 
开发者ID:yselivonchyk,项目名称:TensorFlow_DCIGN,代码行数:26,代码来源:metrics.py

示例5: plot_single_cross_section_line

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def plot_single_cross_section_line(data, select, subplot):
  data = data[:, select]
  # subplot.scatter(data[:, 0], data[:, 1], s=20, lw=0, edgecolors='none', alpha=1.0,
  # subplot.plot(data[:, 0], data[:, 1], data[:, 2], color='black', lw=1, alpha=0.4)

  d = data
  # subplot.plot(d[[-1, 0], 0], d[[-1, 0], 1], d[[-1, 0], 2], lw=1, alpha=0.8, color='red')
  # subplot.scatter(d[[-1, 0], 0], d[[-1, 0], 1], d[[-1, 0], 2], lw=10, alpha=0.3, marker=".", color='b')
  d = data
  subplot.plot(data[:, 0], data[:, 1], data[:, 2], color='black', lw=1, alpha=0.4)

  subplot.set_xlim([-0.01, 1.01])
  subplot.set_ylim([-0.01, 1.01])
  subplot.set_zlim([-0.01, 1.01])
  ticks = []
  subplot.xaxis.set_ticks(ticks)
  subplot.yaxis.set_ticks(ticks)
  subplot.zaxis.set_ticks(ticks)
  subplot.xaxis.set_major_formatter(ticker.FormatStrFormatter('%1.0f'))
  subplot.yaxis.set_major_formatter(ticker.FormatStrFormatter('%1.0f')) 
开发者ID:yselivonchyk,项目名称:TensorFlow_DCIGN,代码行数:22,代码来源:metrics.py

示例6: _plot_single_cross_section

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def _plot_single_cross_section(data, select, subplot):
  data = data[:, select]
  # subplot.scatter(data[:, 0], data[:, 1], s=20, lw=0, edgecolors='none', alpha=1.0,
  subplot.plot(data[:, 0], data[:, 1], color='black', lw=1, alpha=0.4)
  subplot.plot(data[[-1, 0], 0], data[[-1, 0], 1], lw=1, alpha=0.8, color='red')
  subplot.scatter(data[:, 0], data[:, 1], s=4, alpha=1.0, lw=0.5,
                  c=_build_radial_colors(len(data)),
                  marker=".",
                  cmap=plt.cm.Spectral)
  # data = np.vstack((data, np.asarray([data[0, :]])))
  # subplot.plot(data[:, 0], data[:, 1], alpha=0.4)

  subplot.set_xlabel('feature %d' % select[0], labelpad=-12)
  subplot.set_ylabel('feature %d' % select[1], labelpad=-12)
  subplot.set_xlim([-0.05, 1.05])
  subplot.set_ylim([-0.05, 1.05])
  subplot.xaxis.set_ticks([0, 1])
  subplot.xaxis.set_major_formatter(ticker.FormatStrFormatter('%1.0f'))
  subplot.yaxis.set_ticks([0, 1])
  subplot.yaxis.set_major_formatter(ticker.FormatStrFormatter('%1.0f')) 
开发者ID:yselivonchyk,项目名称:TensorFlow_DCIGN,代码行数:22,代码来源:visualization.py

示例7: plot_model

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def plot_model(model, ax, cur_x, cur_y, pred_x, seen_x=None, seen_y=None):
    mx, vx = model.predict_f(pred_x)
    Zopt = model.Z.value
    mu, Su = model.predict_f_full_cov(Zopt)
    if len(Su.shape) == 3:
        Su = Su[:, :, 0]
        vx = vx[:, 0]
    ax.plot(cur_x, cur_y, 'kx', mew=1, alpha=0.8)
    if seen_x is not None:
        ax.plot(seen_x, seen_y, 'kx', mew=1, alpha=0.2)
    ax.plot(pred_x, mx, 'b', lw=2)
    ax.fill_between(
        pred_x[:, 0], mx[:, 0] -  2*np.sqrt(vx), 
        mx[:, 0] +  2*np.sqrt(vx), 
        color='b', alpha=0.3)
    ax.plot(Zopt, mu, 'ro', mew=1)
    ax.set_ylim([-2.4, 2])
    ax.set_xlim([np.min(pred_x), np.max(pred_x)])
    plt.subplots_adjust(hspace = .08)
    ax.set_ylabel('y')
    ax.yaxis.set_ticks(np.arange(-2, 3, 1))
    ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1f'))
    return mu, Su, Zopt 
开发者ID:thangbui,项目名称:streaming_sparse_gp,代码行数:25,代码来源:run_reg_toy.py

示例8: plot_radius

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def plot_radius(xcoords, exact_radius, radii):

    fig, ax = plt.subplots()
    plt.plot(xcoords, exact_radius, color='k', linestyle='--', linewidth=1, label='exact')

    for type, radius in radii.items():
        plt.plot(xcoords, radius, linestyle='-', linewidth=2, label=type)

    ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%1.2f'))
    ax.set_ylabel('radius')
    ax.set_xlabel('time')
    ax.grid()
    ax.legend(loc=3)
    fname = 'data/AC_contracting_circle_standard_integrators'
    plt.savefig('{}.pdf'.format(fname), rasterized=True, bbox_inches='tight')

    # plt.show() 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:19,代码来源:AllenCahn_contracting_circle_standard_integrators.py

示例9: plot_surface

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def plot_surface(x,y,z):
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm,
                           linewidth=0, antialiased=False)

    # Customize the z axis.
    ax.zaxis.set_major_locator(LinearLocator(10))
    ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

    # Add a color bar which maps values to colors.
    fig.colorbar(surf, shrink=0.5, aspect=5)
    if save_info:
        fig.tight_layout()
        fig.savefig('./gaussian'+ str(idx) + '.png')
    plt.show() 
开发者ID:limingwu8,项目名称:Image-Restoration,代码行数:18,代码来源:deforme.py

示例10: three_d_grid

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def three_d_grid():
    fig = plt.figure()
    ax = fig.gca(projection='3d')

    # Make data.
    X = np.arange(-5, 5, 0.25)
    Y = np.arange(-5, 5, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = (X**3 + Y**3)
    Z = R

    # Plot the surface.
    surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                        linewidth=0, antialiased=False)

    # Customize the z axis.
    #ax.set_zlim(-1.01, 1.01)
    #ax.zaxis.set_major_locator(LinearLocator(10))
    #ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

    # Add a color bar which maps values to colors.
    fig.colorbar(surf, shrink=0.5, aspect=5)
    plt.show() 
开发者ID:ryu577,项目名称:pyray,代码行数:25,代码来源:lagrange.py

示例11: wrap_formatter

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def wrap_formatter(formatter):
    """
    Wraps formatting function or string in
    appropriate matplotlib formatter type.
    """
    if isinstance(formatter, ticker.Formatter):
        return formatter
    elif callable(formatter):
        args = [arg for arg in _getargspec(formatter).args
                if arg != 'self']
        wrapped = formatter
        if len(args) == 1:
            def wrapped(val, pos=None):
                return formatter(val)
        return ticker.FuncFormatter(wrapped)
    elif isinstance(formatter, basestring):
        if re.findall(r"\{(\w+)\}", formatter):
            return ticker.StrMethodFormatter(formatter)
        else:
            return ticker.FormatStrFormatter(formatter) 
开发者ID:holoviz,项目名称:holoviews,代码行数:22,代码来源:util.py

示例12: set_plot

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def set_plot(amp, function):
    global figure_w, figure_h, fig
    fig=plt.figure()
    ax = fig.add_subplot(111)
    x = np.linspace(-np.pi*2, np.pi*2, 100)
    if function == 'sine':
        y= amp*np.sin(x)
        ax.set_title('sin(x)')
    else:
        y=amp*np.cos(x)
        ax.set_title('cos(x)')
    plt.plot(x/np.pi,y)

    
    #centre bottom and left axes to zero

    ax.spines['left'].set_position('zero')
    ax.spines['right'].set_color('none')
    ax.spines['bottom'].set_position('zero')
    ax.spines['top'].set_color('none')

    #Format axes - nicer eh!
    ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%g $\pi$'))

    figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:27,代码来源:10e PSG (Same Window).py

示例13: LDR

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def LDR(Time_Series):

    columns=['Consume diesel', 'Lost Load', 'Energy PV','Curtailment','Energy Diesel', 
             'Discharge energy from the Battery', 'Charge energy to the Battery', 
             'Energy_Demand',  'State_Of_Charge_Battery'  ]
    Sort_Values = Time_Series.sort('Energy_Demand', ascending=False)
    
    index_values = []
    
    for i in range(len(Time_Series)):
        index_values.append((i+1)/float(len(Time_Series))*100)
    
    Sort_Values = pd.DataFrame(Sort_Values.values/1000, columns=columns, index=index_values)
    
    plt.figure() 
    ax = Sort_Values['Energy_Demand'].plot(style='k-',linewidth=1)
    
    fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
    xticks = mtick.FormatStrFormatter(fmt)
    ax.xaxis.set_major_formatter(xticks)
    ax.set_ylabel('Load (kWh)')
    ax.set_xlabel('Percentage (%)')
    
    plt.savefig('Results/LDR.png', bbox_inches='tight')
    plt.show() 
开发者ID:squoilin,项目名称:MicroGrids,代码行数:27,代码来源:Results.py

示例14: init_graph

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def init_graph(self):
        plt.title("Franchise Earnings Comparison Over 20 Years", transform=None, x=self.width*0.10, y=self.height*0.90, ha='left')
        if TRACK_FRANCHISES:
            plt.subplots_adjust(left=0.1, right=0.75, top=0.8, bottom=0.1)
        else:
            plt.subplots_adjust(left=0.1, right=0.9, top=0.8, bottom=0.1)
        yformat = ticker.FormatStrFormatter("$%2.1fB")
        self.ax = plt.gca()
        self.ax.yaxis.set_major_formatter(yformat)
        self.ax.spines['top'].set_visible(False)
        self.ax.spines['bottom'].set_visible(False)
        self.ax.spines['left'].set_visible(False)
        self.ax.spines['right'].set_visible(False)
        for _ in self.franchise_data_array:
            line, = self.ax.step([], [], lw=1, where='post')
            self.lines.append(line)
        x_indent_2 = self.width*0.75
        y_indent_1 = self.height*0.88
        self.leaderboard['cur_date']    = self.ax.text(x_indent_2, y_indent_1, "", transform=None, fontsize=16, fontname='Monospace')
        self.ax.text(self.width*0.30, self.height*0.85, "(Adjusted for inflation)", transform=None, ha='left') 
开发者ID:itaidagan,项目名称:FranchiseRevenueComparison,代码行数:22,代码来源:FranchiseAnimation.py

示例15: DrawGridLine

# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import FormatStrFormatter [as 别名]
def DrawGridLine(products, m):
        pj = products.map.projection
        if m is plt:
            # 坐标轴
            plt.axis(pj.axis)

            # 设置坐标轴刻度值显示格式
            if pj.axis == 'on':
                x_majorFormatter = FormatStrFormatter(pj.axisfmt[0])
                y_majorFormatter = FormatStrFormatter(pj.axisfmt[1])
                plt.gca().xaxis.set_major_formatter(x_majorFormatter)
                plt.gca().yaxis.set_major_formatter(y_majorFormatter)
                xaxis = plt.gca().xaxis
                for label in xaxis.get_ticklabels():
                    label.set_fontproperties('DejaVu Sans')
                    label.set_fontsize(10)
                yaxis = plt.gca().yaxis
                for label in yaxis.get_ticklabels():
                    label.set_fontproperties('DejaVu Sans')
                    label.set_fontsize(10)

                xaxis.set_visible(pj.lonlabels[3] == 1)
                yaxis.set_visible(pj.latlabels[0] == 1)

            return
        else:
            # draw parallels and meridians.
            if pj.axis == 'on':
                m.drawparallels(np.arange(-80., 81., 10.), labels=pj.latlabels, family='DejaVu Sans', fontsize=10)
                m.drawmeridians(np.arange(-180., 181., 10.), labels=pj.lonlabels, family='DejaVu Sans', fontsize=10) 
开发者ID:flashlxy,项目名称:PyMICAPS,代码行数:32,代码来源:Map.py


注:本文中的matplotlib.ticker.FormatStrFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。