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


Python Axes.set_position方法代码示例

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


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

示例1: draw

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import set_position [as 别名]
  def draw( self ):

    prefs = self.prefs
    dpi = self.ax_contain.figure.get_dpi()

    # Update palette
    palette = prefs.get( 'colors', {} )
    if palette:
      self.palette.addPalette( palette )


    xlabel = prefs.get( 'xlabel', '' )
    ylabel = prefs.get( 'ylabel', '' )
    xticks_flag = prefs.get( 'xticks', True )
    yticks_flag = prefs.get( 'yticks', True )

    text_size = prefs['text_size']
    text_padding = prefs['text_padding']

    label_text_size = prefs.get( 'label_text_size', text_size )
    label_text_size_point = pixelToPoint( label_text_size, dpi )
    tick_text_size = prefs.get( 'tick_text_size', text_size )
    tick_text_size_point = pixelToPoint( tick_text_size, dpi )

    ytick_length = prefs.get( 'ytick_length', 7 * tick_text_size )

    plot_title = prefs.get( 'plot_title', '' )
    if not plot_title or plot_title == 'NoTitle':
      plot_title_size = 0
      plot_title_padding = 0
    else:
      plot_title_size = prefs.get( 'plot_title_size', text_size )
      plot_title_padding = prefs.get( 'plot_text_padding', text_padding )
    plot_title_size_point = pixelToPoint( plot_title_size, dpi )

    stats_flag = prefs.get( 'statistics_line', False )
    stats_line = ''
    stats_line_space = 0.
    if stats_flag:
      stats_line = self.gdata.getStatString()
      stats_line_size = label_text_size
      stats_line_padding = label_text_size * 2.
      stats_line_space = stats_line_size + stats_line_padding

    plot_padding = prefs['plot_padding']
    plot_left_padding = prefs.get( 'plot_left_padding', plot_padding )
    plot_right_padding = prefs.get( 'plot_right_padding', 0 )
    plot_bottom_padding = prefs.get( 'plot_bottom_padding', plot_padding )
    plot_top_padding = prefs.get( 'plot_top_padding', 0 )
    frame_flag = prefs['frame']

    # Create plot axes, and set properties
    left, bottom, width, height = self.ax_contain.get_window_extent().bounds
    l, b, f_width, f_height = self.figure.get_window_extent().bounds

    # Space needed for labels and ticks
    x_label_space = 0
    if xticks_flag:
      x_label_space += tick_text_size * 1.5
    if xlabel:
      x_label_space += label_text_size * 1.5
    y_label_space = 0
    if yticks_flag:
      y_label_space += ytick_length
    if ylabel:
      y_label_space += label_text_size * 1.5

    ax_plot_rect = ( float( plot_left_padding + left + y_label_space ) / f_width,
                     float( plot_bottom_padding + bottom + x_label_space + stats_line_space ) / f_height,
                     float( width - plot_left_padding - plot_right_padding - y_label_space ) / f_width,
                     float( height - plot_bottom_padding - plot_top_padding - x_label_space - \
                            plot_title_size - 2 * plot_title_padding - stats_line_space ) / f_height )
    ax = Axes( self.figure, ax_plot_rect )
    if prefs['square_axis']:
      l, b, a_width, a_height = ax.get_window_extent().bounds
      delta = abs( a_height - a_width )
      if a_height > a_width:
        a_height = a_width
        ax_plot_rect = ( float( plot_left_padding + left ) / f_width,
                         float( plot_bottom_padding + bottom + delta / 2. ) / f_height,
                         float( width - plot_left_padding - plot_right_padding ) / f_width,
                         float( height - plot_bottom_padding - plot_title_size - 2 * plot_title_padding - delta ) / f_height )
      else:
        a_width = a_height
        ax_plot_rect = ( float( plot_left_padding + left + delta / 2. ) / f_width,
                         float( plot_bottom_padding + bottom ) / f_height,
                         float( width - plot_left_padding - delta ) / f_width,
                         float( height - plot_bottom_padding - plot_title_size - 2 * plot_title_padding ) / f_height )
      ax.set_position( ax_plot_rect )


    self.figure.add_axes( ax )
    self.ax = ax
    frame = ax.patch
    frame.set_fill( False )

    if frame_flag.lower() == 'off':
      self.ax.set_axis_off()
      self.log_xaxis = False
      self.log_yaxis = False
#.........这里部分代码省略.........
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:103,代码来源:PlotBase.py


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