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


Python pyplot.subplot2grid方法代码示例

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


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

示例1: __init__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def __init__(self, df):
        self.df = df

        # Create a figure on screen and set the title
        self.fig = plt.figure()

        # Create top subplot for net worth axis
        self.net_worth_ax = plt.subplot2grid((6, 1), (0, 0), rowspan=2, colspan=1)

        # Create bottom subplot for shared price/volume axis
        self.price_ax = plt.subplot2grid((6, 1), (2, 0), rowspan=8,
                                         colspan=1, sharex=self.net_worth_ax)

        # Create a new axis for volume which shares its x-axis with price
        self.volume_ax = self.price_ax.twinx()

        # Add padding to make graph easier to view
        plt.subplots_adjust(left=0.11, bottom=0.24, right=0.90, top=0.90, wspace=0.2, hspace=0)

        # Show the graph without blocking the rest of the program
        plt.show(block=False) 
开发者ID:tensortrade-org,项目名称:tensortrade,代码行数:23,代码来源:matplotlib_trading_chart.py

示例2: __init__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def __init__(self, df):
        self.df = df

        # Create a figure on screen and set the title
        self.fig = plt.figure()

        # Create top subplot for net worth axis
        self.net_worth_ax = plt.subplot2grid((6, 1), (0, 0), rowspan=2, colspan=1)

        # Create bottom subplot for shared price/volume axis
        self.price_ax = plt.subplot2grid((6, 1), (2, 0), rowspan=8, colspan=1, sharex=self.net_worth_ax)

        # Create a new axis for volume which shares its x-axis with price
        self.volume_ax = self.price_ax.twinx()

        # Add padding to make graph easier to view
        plt.subplots_adjust(left=0.11, bottom=0.24, right=0.90, top=0.90, wspace=0.2, hspace=0)

        # Show the graph without blocking the rest of the program
        plt.show(block=False) 
开发者ID:notadamking,项目名称:RLTrader,代码行数:22,代码来源:TradingChart.py

示例3: plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def plot(self):
        """
        Create plot!
        """
        nrow = len(self.magnitudes)
        # Get means and standard deviations
        gmvs = self.get_ground_motion_values()
        fig = plt.figure(figsize=self.figure_size)
        fig.set_tight_layout({"pad":0.5})
        for rowloc in range(nrow):
            for colloc in range(self.nsites):
                self._build_plot(
                    plt.subplot2grid((nrow, self.nsites), (rowloc, colloc)), 
                    gmvs,
                    rowloc,
                    colloc)
        # Add legend
        lgd = plt.legend(self.lines,
                         self.labels,
                         loc=3.,
                         bbox_to_anchor=(1.1, 0.0),
                         fontsize=self.legend_fontsize)

        _save_image_tight(fig, lgd, self.filename, self.filetype, self.dpi)
        plt.show() 
开发者ID:GEMScienceTools,项目名称:gmpe-smtk,代码行数:27,代码来源:trellis_plots.py

示例4: setup_plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def setup_plot(figure_width, plot_len):
  spp = subplot_params(plot_len)

  plt.figure(figsize=(figure_width, 6))

  axes_list = []
  axes_list.append(plt.subplot2grid(
      (4, spp['heat_cols']), (0, spp['logo_start']),
      colspan=spp['logo_span']))
  axes_list.append(plt.subplot2grid(
      (4, spp['heat_cols']), (1, 0), colspan=spp['heat_cols']))
  axes_list.append(plt.subplot2grid(
      (4, spp['heat_cols']), (2, spp['logo_start']),
      colspan=spp['logo_span']))
  axes_list.append(plt.subplot2grid(
      (4, spp['heat_cols']), (3, 0), colspan=spp['heat_cols']))

  return axes_list 
开发者ID:calico,项目名称:basenji,代码行数:20,代码来源:basenji_sat_plot2.py

示例5: test_demonstration

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def test_demonstration():
    # change stdout
    print("\nStart plot,please wait!!!")
    sys.stdout = open(os.devnull, "w")

    ax1 = plt.subplot2grid((2, 2), (0, 0))
    ax2 = plt.subplot2grid((2, 2), (0, 1))
    ax3 = plt.subplot2grid((2, 2), (1, 0))
    ax4 = plt.subplot2grid((2, 2), (1, 1))
    ax1.set_title("linear svm,cost:0.1")
    test_linear_kernel(ax1, cost=0.1)
    ax2.set_title("linear svm,cost:500")
    test_linear_kernel(ax2, cost=500)
    ax3.set_title("rbf kernel svm,cost:0.1")
    test_rbf_kernel(ax3, cost=0.1)
    ax4.set_title("rbf kernel svm,cost:500")
    test_rbf_kernel(ax4, cost=500)

    sys.stdout = sys.__stdout__
    print("Plot done!!!") 
开发者ID:TheAlgorithms,项目名称:Python,代码行数:22,代码来源:sequential_minimum_optimization.py

示例6: test_tight_layout4

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def test_tight_layout4():
    'Test tight_layout for subplot2grid'

    fig = plt.figure()

    ax1 = plt.subplot2grid((3, 3), (0, 0))
    ax2 = plt.subplot2grid((3, 3), (0, 1), colspan=2)
    ax3 = plt.subplot2grid((3, 3), (1, 0), colspan=2, rowspan=2)
    ax4 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)

    example_plot(ax1)
    example_plot(ax2)
    example_plot(ax3)
    example_plot(ax4)

    plt.tight_layout() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:18,代码来源:test_tightlayout.py

示例7: __init__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def __init__(self):
        '''

        '''

        self.fig = pl.figure(figsize=(8.5, 11))
        self.fig.subplots_adjust(
            left=0.025 * (11 / 8.5), right=1 - 0.025 * (11 / 8.5),
            top=0.975, bottom=0.025)

        def GetFrame(y, x, dx, dy):
            return Frame(self.fig, pl.subplot2grid((160, 160), (y, x),
                         colspan=dx, rowspan=dy))
        self.title_left = GetFrame(0, 6, 44, 10)
        self.title_center = GetFrame(0, 50, 66, 10)
        self.title_right = GetFrame(0, 116, 44, 10)
        self._body = [GetFrame(12, 6, 148, 42),
                      GetFrame(62, 6, 148, 42),
                      GetFrame(112, 6, 148, 42)]
        for ax in self.fig.get_axes():
            ax.axis('off')
        self.bcount = 0 
开发者ID:rodluger,项目名称:everest,代码行数:24,代码来源:dvs.py

示例8: graphRawFX

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def graphRawFX():
    
    fig=plt.figure(figsize=(10,7))
    ax1 = plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)
    ax1.plot(date,bid)
    ax1.plot(date,ask)
    
    #ax1.plot(date,((bid+ask)/2))
    #ax1.plot(date,percentChange(ask[0],ask),'r')
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))
    #####
    plt.grid(True)
    for label in ax1.xaxis.get_ticklabels():
            label.set_rotation(45)
    plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)
    #######
    ax1_2 = ax1.twinx()
    #ax1_2.plot(date, (ask-bid))
    ax1_2.fill_between(date, 0, (ask-bid), facecolor='g',alpha=.3)
    #ax1_2.set_ylim(0, 3*ask.max())
    #######
    plt.subplots_adjust(bottom=.23)
    #plt.grid(True)
    plt.show() 
开发者ID:PythonProgramming,项目名称:Pattern-Recognition-for-Forex-Trading,代码行数:26,代码来源:machFX7.py

示例9: graphRawFX

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def graphRawFX():
    date,bid,ask = np.loadtxt('GBPUSD1d.txt', unpack=True,
                              delimiter=',',
                              converters={0:mdates.strpdate2num('%Y%m%d%H%M%S')})

    fig=plt.figure(figsize=(10,7))

    ax1 = plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)
    ax1.plot(date,bid)
    ax1.plot(date,ask)

    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))

    for label in ax1.xaxis.get_ticklabels():
            label.set_rotation(45)
    plt.subplots_adjust(bottom=.23)
    plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)
    plt.grid(True)
    plt.show() 
开发者ID:PythonProgramming,项目名称:Pattern-Recognition-for-Forex-Trading,代码行数:21,代码来源:machFX2.py

示例10: graphRawFX

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def graphRawFX():
    
    fig=plt.figure(figsize=(10,7))
    ax1 = plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)
    ax1.plot(date,bid)
    ax1.plot(date,ask)
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))
    plt.grid(True)
    for label in ax1.xaxis.get_ticklabels():
            label.set_rotation(45)
    plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)
    ax1_2 = ax1.twinx()
    ax1_2.fill_between(date, 0, (ask-bid), facecolor='g',alpha=.3)

    plt.subplots_adjust(bottom=.23)
    plt.show() 
开发者ID:PythonProgramming,项目名称:Pattern-Recognition-for-Forex-Trading,代码行数:18,代码来源:machFX14.py

示例11: showSlice

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def showSlice(dataMatrix, title, color, subplotRow, referenceImName, slice_nr=-1):
    """Display a 2D slice within a given figure."""
    try:
        import matplotlib.pyplot as plt
    except ImportError:
        print "ShowSlice not supported - matplotlib not available"
        return
    im_ref = sitk.ReadImage(referenceImName)
    im_ref_array = sitk.GetArrayFromImage(im_ref)  # get numpy array
    z_dim, x_dim, y_dim = im_ref_array.shape  # get 3D volume shape
    if slice_nr == -1:
        slice_nr = z_dim / 2
    num_of_data = dataMatrix.shape[1]
    for i in range(num_of_data):
        plt.subplot2grid((3, num_of_data), (subplotRow, i))
        im = np.array(dataMatrix[:, i]).reshape(z_dim, x_dim, y_dim)
        implot = plt.imshow(np.fliplr(np.flipud(im[slice_nr, :, :])), color)
        plt.axis('off')
        plt.title(title + ' ' + str(i))
        # plt.colorbar()
    del im_ref, im_ref_array
    return 
开发者ID:KitwareMedical,项目名称:pyLAR,代码行数:24,代码来源:images.py

示例12: __init__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def __init__(self, grid_space, objects, evaluator, figsize, sleep=0.001):
        super(ScaleMonitor, self).__init__(evaluator, 'score_monitor')
        self._network = self.evaluator.network
        self._axes = {}
        self._tplot_axes = {}
        self._vplot_axes = {}
        self._fig = plt.figure(figsize=figsize)
        self._sleep = sleep
        for r_loc, name in enumerate(objects):
            r_span, c_span = 1, grid_space[1]
            self._axes[name] = plt.subplot2grid(grid_space, (r_loc, 0), colspan=c_span, rowspan=r_span)
            if name != objects[-1]:
                plt.setp(self._axes[name].get_xticklabels(), visible=False)
            self._axes[name].set_ylabel(r'$%s$' % name.replace(' ', r'\ ').capitalize())
        self._fig.subplots_adjust(hspace=0.1)
        plt.ion()
        plt.show() 
开发者ID:MorvanZhou,项目名称:tfnn,代码行数:19,代码来源:scalar_monitor.py

示例13: view_init

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def view_init(self):
        self.frame = tk.LabelFrame(self.browser.workframe, text=" Image ")
        self.frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=7, pady=7)
        self.figure = plt.figure(figsize=(8, 12), dpi=70)
        self.ax1 = plt.subplot2grid((50,40), (0, 0), rowspan=40, colspan=40)
        self.ax2 = plt.subplot2grid((50,40), (42, 0), rowspan=8, colspan=40, sharex=self.ax1)
        plt.subplots_adjust(left=0.1, bottom=0.05, right=0.95, top=0.97, wspace=0.2, hspace=0.2)
        self.view_plot_image()
        self.canvas = FigureCanvasTkAgg(self.figure, self.frame)

        if self.mpltlib3:
            self.canvas.draw()
            toolbar = NavigationToolbar2Tk(self.canvas, self.frame).update()
        else:
            self.canvas.show()
            toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame).update()

        self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, padx=2, pady=2, expand=True)
        self.frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=7, pady=7) 
开发者ID:aizquier,项目名称:voyagerimb,代码行数:23,代码来源:voyagerimb.py

示例14: __init__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def __init__(self, df, title=None):
        self.df = df
        self.net_worths = np.zeros(len(df['Date']))

        # Create a figure on screen and set the title
        fig = plt.figure()
        fig.suptitle(title)

        # Create top subplot for net worth axis
        self.net_worth_ax = plt.subplot2grid(
            (6, 1), (0, 0), rowspan=2, colspan=1)

        # Create bottom subplot for shared price/volume axis
        self.price_ax = plt.subplot2grid(
            (6, 1), (2, 0), rowspan=8, colspan=1, sharex=self.net_worth_ax)

        # Create a new axis for volume which shares its x-axis with price
        self.volume_ax = self.price_ax.twinx()

        # Add padding to make graph easier to view
        plt.subplots_adjust(left=0.11, bottom=0.24,
                            right=0.90, top=0.90, wspace=0.2, hspace=0)

        # Show the graph without blocking the rest of the program
        plt.show(block=False) 
开发者ID:notadamking,项目名称:Stock-Trading-Visualization,代码行数:27,代码来源:StockTradingGraph.py

示例15: plot_summary

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import subplot2grid [as 别名]
def plot_summary(self, show: bool=True):
        """Plot a summary figure showing the gantry sag and wobble plots of the three axes."""
        plt.figure(figsize=(11, 9))
        grid = (3, 6)
        gantry_sag_ax = plt.subplot2grid(grid, (0, 0), colspan=3)
        self._plot_deviation(GANTRY, gantry_sag_ax, show=False)
        epid_sag_ax = plt.subplot2grid(grid, (0, 3), colspan=3)
        self._plot_deviation(EPID, epid_sag_ax, show=False)
        if self._get_images((COLLIMATOR, REFERENCE))[0] > 1:
            coll_sag_ax = plt.subplot2grid(grid, (1, 0), colspan=3)
            self._plot_deviation(COLLIMATOR, coll_sag_ax, show=False)
        if self._get_images((COUCH, REFERENCE))[0] > 1:
            couch_sag_ax = plt.subplot2grid(grid, (1, 3), colspan=3)
            self._plot_deviation(COUCH, couch_sag_ax, show=False)

        for axis, axnum in zip((GANTRY, COLLIMATOR, COUCH), (0, 2, 4)):
            if self._get_images((axis, REFERENCE))[0] > 1:
                ax = plt.subplot2grid(grid, (2, axnum), colspan=2)
                self.plot_axis_images(axis=axis, ax=ax, show=False)
        if show:
            plt.tight_layout()
            plt.show() 
开发者ID:jrkerns,项目名称:pylinac,代码行数:24,代码来源:winston_lutz.py


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