本文整理汇总了Python中matplotlib.axes.Axes.set_xlabel方法的典型用法代码示例。如果您正苦于以下问题:Python Axes.set_xlabel方法的具体用法?Python Axes.set_xlabel怎么用?Python Axes.set_xlabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.axes.Axes
的用法示例。
在下文中一共展示了Axes.set_xlabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_plot_config
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import set_xlabel [as 别名]
def apply_plot_config(cls, ax: axes.Axes, config):
# set label
ax.set_title(config['title'], fontsize=21)
ax.set_xlabel(config['xlabel'])
if isinstance(ax, Axes3D):
ax.set_zlabel(config['ylabel'])
ax.set_ylabel(config['x2label'])
else:
ax.set_ylabel(config['ylabel'])
# set limit
ax.set_xlim(config['xlim'])
if isinstance(ax, Axes3D):
ax.set_zlim(config['ylim'])
ax.set_ylim(config['x2lim'])
else:
ax.set_ylim(config['ylim'])
# set tick
if config['int_xaxis']:
ax.get_xaxis().set_major_locator(plt.MaxNLocator(integer=True))
if config['int_yaxis']:
if isinstance(ax, Axes3D):
ax.get_zaxis().set_major_locator(plt.MaxNLocator(integer=True))
else:
ax.get_yaxis().set_major_locator(plt.MaxNLocator(integer=True))
if config['int_x2axis']:
if isinstance(ax, Axes3D):
ax.get_yaxis().set_major_locator(plt.MaxNLocator(integer=True))
else:
pass
# line style
if config['linestyle'] is not None:
for line in ax.lines:
try:
line.set_linestyle(config['linestyle'])
except:
pass
# marker style
if config['marker'] is not None:
for line in ax.lines:
try:
line.set_marker(config['marker'])
except:
pass
# marker size
if config['markersize'] is not None:
for line in ax.lines:
try:
line.set_markersize(config['markersize'])
except:
pass
for line in ax.collections:
try:
line.set_lw(config['markersize'])
except:
pass
# markert edge
if config['marker_edge_width'] is not None and isinstance(config['marker_edge_width'], (float, int)):
marker_edge_width = config['marker_edge_width']
else:
marker_edge_width = 0.01
for line in ax.lines:
try:
line.set_markeredgewidth(marker_edge_width)
except:
pass
示例2: draw
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import set_xlabel [as 别名]
#.........这里部分代码省略.........
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
else:
# If requested, make x/y axis logarithmic
if prefs.get( 'log_xaxis', 'False' ).find( 'r' ) >= 0:
ax.semilogx()
self.log_xaxis = True
else:
self.log_xaxis = False
if prefs.get( 'log_yaxis', 'False' ).find( 'r' ) >= 0:
ax.semilogy()
self.log_yaxis = True
else:
self.log_yaxis = False
if xticks_flag:
setp( ax.get_xticklabels(), family = prefs['font_family'] )
setp( ax.get_xticklabels(), fontname = prefs['font'] )
setp( ax.get_xticklabels(), size = tick_text_size_point )
else:
setp( ax.get_xticklabels(), size = 0 )
if yticks_flag:
setp( ax.get_yticklabels(), family = prefs['font_family'] )
setp( ax.get_yticklabels(), fontname = prefs['font'] )
setp( ax.get_yticklabels(), size = tick_text_size_point )
else:
setp( ax.get_yticklabels(), size = 0 )
setp( ax.get_xticklines(), markeredgewidth = pixelToPoint( 0.5, dpi ) )
setp( ax.get_xticklines(), markersize = pixelToPoint( text_size / 2., dpi ) )
setp( ax.get_yticklines(), markeredgewidth = pixelToPoint( 0.5, dpi ) )
setp( ax.get_yticklines(), markersize = pixelToPoint( text_size / 2., dpi ) )
setp( ax.get_xticklines(), zorder = 4.0 )
line_width = prefs.get( 'line_width', 1.0 )
frame_line_width = prefs.get( 'frame_line_width', line_width )
grid_line_width = prefs.get( 'grid_line_width', 0.1 )
plot_line_width = prefs.get( 'plot_line_width', 0.1 )
setp( ax.patch, linewidth = pixelToPoint( plot_line_width, dpi ) )
#setp( ax.spines, linewidth=pixelToPoint(frame_line_width,dpi) )
#setp( ax.axvline(), linewidth=pixelToPoint(1.0,dpi) )
axis_grid_flag = prefs.get( 'plot_axis_grid', True )
if axis_grid_flag:
ax.grid( True, color = '#555555', linewidth = pixelToPoint( grid_line_width, dpi ) )
plot_axis_flag = prefs.get( 'plot_axis', True )
if plot_axis_flag:
# Set labels
if xlabel:
t = ax.set_xlabel( xlabel )
t.set_family( prefs['font_family'] )
t.set_fontname( prefs['font'] )
t.set_size( label_text_size )
if ylabel:
t = ax.set_ylabel( ylabel )
t.set_family( prefs['font_family'] )
t.set_fontname( prefs['font'] )
t.set_size( label_text_size )
else:
self.ax.set_axis_off()
# Create a plot title, if necessary
if plot_title:
self.ax.title = self.ax.text( 0.5,
1. + float( plot_title_padding ) / height,
plot_title,
verticalalignment = 'bottom',
horizontalalignment = 'center',
size = pixelToPoint( plot_title_size, dpi ),
family = prefs['font_family'],
fontname = prefs['font'])
self.ax.title.set_transform( self.ax.transAxes )
self.ax.title.set_family( prefs['font_family'] )
self.ax.title.set_fontname( prefs['font'] )
if stats_line:
self.ax.stats = self.ax.text( 0.5, ( -stats_line_space ) / height,
stats_line,
verticalalignment = 'top',
horizontalalignment = 'center',
size = pixelToPoint( stats_line_size, dpi ) )
self.ax.stats.set_transform( self.ax.transAxes )