當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。