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


Python pylab.setp方法代码示例

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


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

示例1: generate_box_plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import setp [as 别名]
def generate_box_plot(dataset, methods, position_rmses, orientation_rmses):

  num_methods = len(methods)
  x_ticks = np.linspace(0., 1., num_methods)

  width = 0.3 / num_methods
  spacing = 0.3 / num_methods
  fig, ax1 = plt.subplots()
  ax1.set_ylabel('RMSE position [m]', color='b')
  ax1.tick_params('y', colors='b')
  fig.suptitle(
      "Hand-Eye Calibration Method Error {}".format(dataset), fontsize='24')
  bp_position = ax1.boxplot(position_rmses, 0, '',
                            positions=x_ticks - spacing, widths=width)
  plt.setp(bp_position['boxes'], color='blue', linewidth=line_width)
  plt.setp(bp_position['whiskers'], color='blue', linewidth=line_width)
  plt.setp(bp_position['fliers'], color='blue',
           marker='+', linewidth=line_width)
  plt.setp(bp_position['caps'], color='blue', linewidth=line_width)
  plt.setp(bp_position['medians'], color='blue', linewidth=line_width)
  ax2 = ax1.twinx()
  ax2.set_ylabel('RMSE Orientation [$^\circ$]', color='g')
  ax2.tick_params('y', colors='g')
  bp_orientation = ax2.boxplot(
      orientation_rmses, 0, '', positions=x_ticks + spacing, widths=width)
  plt.setp(bp_orientation['boxes'], color='green', linewidth=line_width)
  plt.setp(bp_orientation['whiskers'], color='green', linewidth=line_width)
  plt.setp(bp_orientation['fliers'], color='green',
           marker='+')
  plt.setp(bp_orientation['caps'], color='green', linewidth=line_width)
  plt.setp(bp_orientation['medians'], color='green', linewidth=line_width)

  plt.xticks(x_ticks, methods)
  plt.xlim(x_ticks[0] - 2.5 * spacing, x_ticks[-1] + 2.5 * spacing)

  plt.show() 
开发者ID:ethz-asl,项目名称:hand_eye_calibration,代码行数:38,代码来源:generate_plots.py

示例2: generate_time_plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import setp [as 别名]
def generate_time_plot(methods, datasets, runtimes_per_method, colors):
  num_methods = len(methods)
  num_datasets = len(datasets)
  x_ticks = np.linspace(0., 1., num_methods)

  width = 0.6 / num_methods / num_datasets
  spacing = 0.4 / num_methods / num_datasets
  fig, ax1 = plt.subplots()
  ax1.set_ylabel('Time [s]', color='b')
  ax1.tick_params('y', colors='b')
  ax1.set_yscale('log')
  fig.suptitle("Hand-Eye Calibration Method Timings", fontsize='24')
  handles = []
  for i, dataset in enumerate(datasets):
    runtimes = [runtimes_per_method[dataset][method] for method in methods]
    bp = ax1.boxplot(
        runtimes, 0, '',
        positions=(x_ticks + (i - num_datasets / 2. + 0.5) *
                   spacing * 2),
        widths=width)
    plt.setp(bp['boxes'], color=colors[i], linewidth=line_width)
    plt.setp(bp['whiskers'], color=colors[i], linewidth=line_width)
    plt.setp(bp['fliers'], color=colors[i],
             marker='+', linewidth=line_width)
    plt.setp(bp['medians'], color=colors[i],
             marker='+', linewidth=line_width)
    plt.setp(bp['caps'], color=colors[i], linewidth=line_width)
    handles.append(mpatches.Patch(color=colors[i], label=dataset))
  plt.legend(handles=handles, loc=2)

  plt.xticks(x_ticks, methods)
  plt.xlim(x_ticks[0] - 2.5 * spacing * num_datasets,
           x_ticks[-1] + 2.5 * spacing * num_datasets)

  plt.show() 
开发者ID:ethz-asl,项目名称:hand_eye_calibration,代码行数:37,代码来源:generate_plots.py

示例3: draw_heatmap

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import setp [as 别名]
def draw_heatmap(data, row_labels=None, col_labels=None, ax=None,
                 cbar_kw=None, cbar_label="", **kwargs):
    """
    Create a draw_heatmap from a numpy array and two lists of labels.

    .. seealso:: https://matplotlib.org/gallery/images_contours_and_fields/image_annotated_heatmap.html

    :param data: A 2D numpy array of shape (N,M)
    :param row_labels: A list or array of length N with the labels for the rows
    :param col_labels: A list or array of length M with the labels for the columns
    :param ax: A matplotlib.axes.Axes instance to which the draw_heatmap is plotted.
     If not provided, use current axes or create a new one.
    :param cbar_kw: A dictionary with arguments to :meth:`matplotlib.Figure.colorbar`.
    :param cbar_label: The label for the colorbar

    """
    cbar_kw = {} if cbar_kw is None else cbar_kw
    ax = plt.figure(figsize=data.shape[::-1]).gca() if ax is None else ax
    # Plot the draw_heatmap
    im = ax.imshow(data, **kwargs)

    # Create colorbar
    cbar = ax.figure.colorbar(im, ax=ax, **cbar_kw)
    cbar.ax.set_ylabel(cbar_label, rotation=-90, va='bottom')

    # We want to show all ticks and label them with the respective list entries.
    if col_labels is not None:
        ax.set_xticks(np.arange(data.shape[1]))
        ax.set_xticklabels(col_labels, va='center')
    else:
        ax.set_xticks([])

    if row_labels is not None:
        ax.set_yticks(np.arange(data.shape[0]))
        ax.set_yticklabels(row_labels, va='center')
    else:
        ax.set_yticks([])

    # Let the horizontal axes labeling appear on top.
    ax.tick_params(top=True, bottom=False, labeltop=True, labelbottom=False)

    # Rotate the tick labels and set their alignment.
    plt.setp(ax.get_xticklabels(), rotation=90, ha='left', rotation_mode='anchor')

    # Turn spines off and create white grid.
    for _, spine in ax.spines.items():
        spine.set_visible(False)

    ax.grid(False)  # for the general grid
    # grid splitting particular color-box, kind of padding
    ax.set_xticks(np.arange(data.shape[1] + 1) - 0.5, minor=True)
    ax.set_yticks(np.arange(data.shape[0] + 1) - 0.5, minor=True)
    ax.grid(which='minor', color='w', linestyle='-', linewidth=3)
    ax.tick_params(which='minor', bottom=False, left=False)

    return im, cbar 
开发者ID:Borda,项目名称:BIRL,代码行数:58,代码来源:drawing.py

示例4: OnCreateResidualPlot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import setp [as 别名]
def OnCreateResidualPlot(self,fig,canvas):
		"""
		Create a plot with main data, residuals and (optionally) histogram of residuals, using
		subplot2grid in matplotlib 
		"""
		
		fig.clf()
		
		print('Debugging...')
		print(self.fit_datatype)
		print(self.y_optimised)
		
		#normalised_residuals = False
		if self.normalised_residuals:
			### not done yet! -- requires error bars in imported data
			residuals = 100*(self.y_fit_array-self.y_optimised)
		else:
			residuals = 100*(self.y_fit_array-self.y_optimised)
		
		fig = plt.figure(2)
		yy = 4
		xx = 6
		if self.residual_histogram:
			ax_main = plt.subplot2grid((yy,xx),(0,0),colspan=xx-1,rowspan=yy-1)
			ax_residual = plt.subplot2grid((yy,xx),(yy-1,0),colspan=xx-1,sharex=ax_main)
			ax_hist = plt.subplot2grid((yy,xx), (yy-1,xx-1), sharey=ax_residual)

			plt.setp(ax_hist.get_yticklabels(),visible=False)
			ax_hist.set_xticklabels([])

		else:
			ax_main = plt.subplot2grid((yy,xx),(0,0),colspan=xx,rowspan=yy-1)
			ax_residual = plt.subplot2grid((yy,xx),(yy-1,0),colspan=xx,sharex=ax_main)
			
		plt.setp(ax_main.get_xticklabels(),visible=False)
		
		ax_residual.set_xlabel('Detuning (GHz)')
		ax_residual.set_ylabel('Residuals (%)')

		ax_main.set_ylabel(self.expt_type)
		
		ax_main.plot(self.x_fit_array,self.y_fit_array,color=d_olive)
		print(len(self.x_fit_array), len(self.y_optimised))
		ax_main.plot(self.x_fit_array,self.y_optimised)
		ax_residual.plot(self.x_fit_array,residuals,lw=1.25)
		ax_residual.axhline(0,color='k',linestyle='dashed')
		
		if self.residual_histogram:
			bins = 25
			ax_hist.hist(residuals, bins=bins, orientation='horizontal')
			ax_hist.axhline(0,color='k', linestyle='dashed')

		ax_main.autoscale_view(tight=True)
		
		self._draw_fig(fig,canvas) 
开发者ID:jameskeaveney,项目名称:ElecSus,代码行数:57,代码来源:elecsus_gui.py


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