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


Python GridSpec.new_subplotspec方法代码示例

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


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

示例1: get_stereo_two_rose

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def get_stereo_two_rose(self):
        """
        Resets the figure and returns a stereonet two rose diagrams axis.

        When the view in the main window is changed to this setting, this
        function is called and sets up a plot with a stereonet and two
        rose diagram axis. One axis is for azimuth, the other one for
        dip.
        """
        self.fig.clf()
        self.fig.patch.set_facecolor(self.props["canvas_color"])
        self.fig.set_dpi(self.props["pixel_density"])
        gridspec = GridSpec(2, 4)
        sp_stereo = gridspec.new_subplotspec((0, 0),
                                             rowspan=2, colspan=2)
        sp_cbar = gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
        sp_rose = gridspec.new_subplotspec((0, 3),
                                           rowspan=1, colspan=1)
        sp_drose = gridspec.new_subplotspec((1, 3),
                                           rowspan=1, colspan=1)
        ax_stereo = self.fig.add_subplot(sp_stereo,
                                         projection=self.get_projection())
        ax_rose = self.fig.add_subplot(sp_rose, projection="northpolar")
        ax_drose = self.fig.add_subplot(sp_drose, projection="dippolar")
        ax_cbar = self.fig.add_subplot(sp_cbar)
        ax_cbar.axis("off")
        ax_cbar.set_aspect(8)
        return ax_stereo, ax_rose, ax_drose, ax_cbar
开发者ID:gbtami,项目名称:innstereo,代码行数:30,代码来源:plot_control.py

示例2: create_canvas

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
 def create_canvas(self):  # pragma: no cover
     self.fig = Figure()
     canvas = FigureCanvas(self.fig)
     self.ui.mainLayout.addWidget(canvas)
     canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
     # Add subplots
     gridspec = GridSpec(2, 4)
     self.map_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((0, 0), rowspan=2, colspan=2)
     )
     self.spectrum_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((0, 2), rowspan=1, colspan=2)
     )
     self.hist_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
     )
     self.edge_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((1, 3), rowspan=1, colspan=1)
     )
     # Create the colorbar on the histogram axes
     self.cbar = plots.draw_histogram_colorbar(ax=self.hist_ax,
                                               cmap="viridis",
                                               norm=Normalize(0, 1))
     self.cbar.ax.set_xlabel("Map Value")
     # Adjust the margins
     self.fig.tight_layout(pad=0)
     self.fig.canvas.draw_idle()
开发者ID:m3wolf,项目名称:xanespy,代码行数:29,代码来源:qt_map_view.py

示例3: create_canvas

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
 def create_canvas(self):
     # Add the canvas to the UI
     self.fig = Figure()
     canvas = FigureCanvas(self.fig)
     self.ui.mainLayout.addWidget(canvas)
     # Add subplots
     gridspec = GridSpec(2, 4)
     self.img_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((0, 0), rowspan=2, colspan=2)
     )
     self.spectrum_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((0, 2), rowspan=1, colspan=2)
     )
     self.hist_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
     )
     self.edge_ax = self.fig.add_subplot(
         gridspec.new_subplotspec((1, 3), rowspan=1, colspan=1)
     )
     # Create the colorbar on the histogram axes
     self.cbar = plots.draw_histogram_colorbar(ax=self.hist_ax,
                                               cmap="viridis",
                                               norm=Normalize(0, 1))
     self.cbar.ax.set_xlabel("Intensity")
     # Adjust the margins
     self.fig.tight_layout(pad=0)
     self.fig.canvas.draw_idle()
开发者ID:m3wolf,项目名称:xanespy,代码行数:29,代码来源:qt_frame_view.py

示例4: get_stereo_rose

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def get_stereo_rose(self):
        """
        Resets the figure and returns a stereonet and rose diagram axis.

        When the view in the main window is changed to stereonet and rose
        diagram, the figure is reset. The current settings are applied and
        two subplots for the stereonet and rose diagram are created. The
        axis of the stereonet and rose diagram are returned. This method is
        called by the MainWindow "redraw_plot"-method.
        """
        self.fig.clf()
        self.fig.patch.set_facecolor(self.props["canvas_color"])
        self.fig.set_dpi(self.props["pixel_density"])
        gridspec = GridSpec(2, 5)
        sp_stereo = gridspec.new_subplotspec((0, 0),
                                             rowspan=2, colspan=2)
        sp_cbar = gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
        sp_rose = gridspec.new_subplotspec((0, 3),
                                           rowspan=2, colspan=2)
        ax_stereo = self.fig.add_subplot(sp_stereo,
                                         projection=self.get_projection())
        ax_rose = self.fig.add_subplot(sp_rose, projection="northpolar")

        ax_cbar = self.fig.add_subplot(sp_cbar)
        ax_cbar.axis("off")
        ax_cbar.set_aspect(8)
        return ax_stereo, ax_rose, ax_cbar
开发者ID:gbtami,项目名称:innstereo,代码行数:29,代码来源:plot_control.py

示例5: __init__

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def __init__(self, main_window, settings, data, add_layer_dataset, add_feature, redraw_main):
        """
        Initializes the RotationDialog class.

        Requires the main_window object, the settings object (PlotSettings
        class) and the data rows to initialize. All the necessary widgets are
        loaded from the Glade file. A matplotlib figure is set up and added
        to the scrolledwindow. Two axes are set up that show the original and
        rotated data.
        """
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(i18n().get_ts_domain())
        script_dir = os.path.dirname(__file__)
        rel_path = "gui_layout.glade"
        abs_path = os.path.join(script_dir, rel_path)
        self.builder.add_objects_from_file(abs_path,
            ("dialog_rotation", "adjustment_rotation_dipdir",
             "adjustment_rotation_dip", "adjustment_rotation_angle"))
        self.dialog = self.builder.get_object("dialog_rotation")
        self.dialog.set_transient_for(main_window)
        self.settings = settings
        self.data = data
        self.trans = self.settings.get_transform()
        self.add_layer_dataset = add_layer_dataset
        self.add_feature = add_feature
        self.redraw_main = redraw_main

        self.adjustment_rotation_dipdir = self.builder.get_object("adjustment_rotation_dipdir")
        self.adjustment_rotation_dip = self.builder.get_object("adjustment_rotation_dip")
        self.adjustment_rotation_angle = self.builder.get_object("adjustment_rotation_angle")

        self.spinbutton_rotation_dipdir = self.builder.get_object("spinbutton_rotation_dipdir")
        self.spinbutton_rotation_dip = self.builder.get_object("spinbutton_rotation_dip")
        self.spinbutton_rotation_angle = self.builder.get_object("spinbutton_rotation_angle")

        self.scrolledwindow_rotate = self.builder.get_object("scrolledwindow_rotate")

        self.fig = Figure(dpi=self.settings.get_pixel_density())
        self.canvas = FigureCanvas(self.fig)
        self.scrolledwindow_rotate.add_with_viewport(self.canvas)

        gridspec = GridSpec(1, 2)
        original_sp = gridspec.new_subplotspec((0, 0),
                                             rowspan=1, colspan=1)
        rotated_sp = gridspec.new_subplotspec((0, 1),
                                           rowspan=1, colspan=1)
        self.original_ax = self.fig.add_subplot(original_sp,
                                         projection=self.settings.get_projection())
        self.rotated_ax = self.fig.add_subplot(rotated_sp,
                                         projection=self.settings.get_projection())

        self.canvas.draw()
        self.redraw_plot()
        self.dialog.show_all()
        self.builder.connect_signals(self)
        if sys.platform == "win32":
            translate_gui(self.builder)
开发者ID:gbtami,项目名称:innstereo,代码行数:59,代码来源:rotation_dialog.py

示例6: gridplot

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
def gridplot (grid, loc, rowspan=1, colspan=1):
    '''
    Returns a matplotlib.gridspec.SubplotSpec for a subplot.
    The resulting object can then be added to a matplotlib.figure
    using the add_subplot() method.
    '''
    gridspec = GridSpec (grid[0], grid[1])
    subplotspec = gridspec.new_subplotspec(loc, rowspan, colspan)
    return subplotspec
开发者ID:codedump,项目名称:paul,代码行数:11,代码来源:mpltrix.py

示例7: __init__

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def __init__(self,scale,imshape,interval=1):
        self.fig = plt.figure(dpi=100)
        self.axes = {}
        self.artists = []

        gridspec = GridSpec(2,2)
        self.axes['raw'] = gridspec.new_subplotspec((0, 0),rowspan=2)
        self.axes['draw'] = gridspec.new_subplotspec((0, 1))
        self.axes['match'] = gridspec.new_subplotspec((1, 1))
        for k,sp in self.axes.items(): self.axes[k] = self.fig.add_subplot(sp)

        self.axes['raw'].set_title('raw')
        self.axes['raw'].set_xticklabels([])
        self.axes['raw'].set_yticklabels([])
        self.axes['match'].grid(which='both')

        self.lines = {}
        self.lines['template'] = self.axes['match'].plot((),(),marker='x',color='g')[0]
        self.lines['query'] = self.axes['match'].plot((),(),marker='o',color='b')[0]
        self.lines['draw'] = self.axes['draw'].plot((),(),color='b',linewidth=5)[0]

        self.axes['match'].set_ylim(-scale//2-10,scale//2+10)
        self.axes['match'].set_xlim(-scale//2-10,scale//2+10)
        self.axes['draw'].set_ylim(imshape[0],0)
        self.axes['draw'].set_xlim(imshape[1],0)
        self.axes['draw'].xaxis.tick_top()
        self.axes['draw'].yaxis.tick_right()

        self.imdisp = self.axes['raw'].imshow(np.zeros(imshape,dtype=np.uint8))

        self.fig.tight_layout()
        self.bg_cache = {ax:self.fig.canvas.copy_from_bbox(ax.bbox) for ax in self.fig.axes}

        self.draw_state = 0
        self.drawcount = 0
        self.fig.canvas.mpl_connect('button_press_event', self.onclick)
        self.fig.canvas.mpl_connect('key_press_event', self.onkey)

        self.timer = self.fig.canvas.new_timer(interval=interval)
        self.timer.add_callback(self._update)
        self.queuelen = 0
开发者ID:baojiwei,项目名称:gestures,代码行数:43,代码来源:gui.py

示例8: get_pt_view

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def get_pt_view(self):
        """
        Resets the canvas and returns the 3 axis of the paleostress view.

        When the view in the main window is changed to paleostress the figure
        is reset. The current settings are applied and 3 subplots are created.
        The 3 axis of the subplots are returned. This method is called by the
        MainWindow "redraw_plot"-method when the view has been changed.
        """
        self.fig.clf()
        self.fig.patch.set_facecolor(self.props["canvas_color"])
        self.fig.set_dpi(self.props["pixel_density"])
        gridspec = GridSpec(2, 5)
        sp_stereo = gridspec.new_subplotspec((0, 0), colspan=3, rowspan=2)
        sp_fluc = gridspec.new_subplotspec((0, 3), colspan=2)
        sp_mohr = gridspec.new_subplotspec((1, 3), colspan=2)
        ax_stereo = self.fig.add_subplot(sp_stereo,
                                         projection=self.get_projection())
        ax_fluc = self.fig.add_subplot(sp_fluc, aspect="equal")
        ax_mohr = self.fig.add_subplot(sp_mohr, aspect="equal")
        return ax_stereo, ax_fluc, ax_mohr
开发者ID:gbtami,项目名称:innstereo,代码行数:23,代码来源:plot_control.py

示例9: get_stereonet

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def get_stereonet(self):
        """
        Resets the figure and returns the stereonet axis.

        When the view in the main window is changed to only stereoent. The
        figure is reset. Then the current settings are applied and one subplot
        for the stereonet is created. This method is called when the
        MainWindow "__init__"-method and the "redraw_plot"-method. 
        """
        self.fig.clf()
        self.fig.patch.set_facecolor(self.props["canvas_color"])
        self.fig.set_dpi(self.props["pixel_density"])
        gridspec = GridSpec(2, 3)
        sp_stereo = gridspec.new_subplotspec((0, 0), rowspan=2, colspan=2)
        sp_cbar = gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
        ax_stereo = self.fig.add_subplot(sp_stereo,
                                         projection=self.get_projection())
        ax_cbar = self.fig.add_subplot(sp_cbar)
        ax_cbar.axis("off")
        ax_cbar.set_aspect(8)
        return ax_stereo, ax_cbar
开发者ID:gbtami,项目名称:innstereo,代码行数:23,代码来源:plot_control.py

示例10: get_rose_diagram

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def get_rose_diagram(self):
        """
        Resets the figure and returns the rose diagram axis.

        When the view in the main window is changed to rose-diagram-only the
        figure is reset. The current settings are applied and one subplot
        for the rose diagram is created. The axis of the rose-diagram is
        returned. This method is called by the MainWindow "redraw_plot"-method.
        """
        self.fig.clf()
        self.fig.patch.set_facecolor(self.props["canvas_color"])
        self.fig.set_dpi(self.props["pixel_density"])
        gridspec = GridSpec(1, 1)
        sp_rose = gridspec.new_subplotspec((0, 0))
        ax_rose = self.fig.add_subplot(sp_rose, projection="northpolar")
        return ax_rose
开发者ID:gbtami,项目名称:innstereo,代码行数:18,代码来源:plot_control.py

示例11: get_stereonet

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
    def get_stereonet(self):
        """
        Resets the figure and returns the stereonet axis.

        When the view in the main window is changed to only stereoent. The
        figure is reset. Then the current settings are applied and one subplot
        for the stereonet is created. This method is called when the
        MainWindow "__init__"-method and the "redraw_plot"-method. 
        """
        self.fig.clf()
        self.fig.patch.set_facecolor(self.canvas_color)
        self.fig.set_dpi(self.pixel_density)
        gridspec = GridSpec(1, 1)
        sp_stereo = gridspec.new_subplotspec((0, 0))
        ax_stereo = self.fig.add_subplot(sp_stereo,
                                         projection=self.get_projection())
        return ax_stereo
开发者ID:akositz,项目名称:innstereo,代码行数:19,代码来源:plot_control.py

示例12: add_subplot

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
	def add_subplot(location, rowspan=1, colspan=1):
		gridspec = GridSpec(2, 3)
		subplotspec = gridspec.new_subplotspec(location, rowspan, colspan)
		return fig.add_subplot(subplotspec)
开发者ID:delarosatrevin,项目名称:resmap,代码行数:6,代码来源:ResMap_spectrumTools.py

示例13: plot_cplap_ternary

# 需要导入模块: from matplotlib.gridspec import GridSpec [as 别名]
# 或者: from matplotlib.gridspec.GridSpec import new_subplotspec [as 别名]
def plot_cplap_ternary(output='plot-2d.pdf',
                       grid_file='grid.dat', txt_file='2Dplot.txt',
                       xmin=None, ymin=None,
                       style=['ggplot'], cmap='viridis',
                       width=6, height=4, ratio=[4],
                       gridlines=None):
    # Set Truetype PDF/PS fonts unless overruled by style file
    matplotlib.rcParams['pdf.fonttype'] = 42
    matplotlib.rcParams['ps.fonttype'] = 42
    if len(style) > 0:
        matplotlib.style.use(style)

    fig = plt.figure(figsize=(width, height))

    if len(ratio) == 1:
        ratio += [1]
    elif len(ratio) > 2:
        raise ValueError('Ratio can be given as one or two integers. '
                         '{} is too many!'.format(len(ratio)))
    gs = GridSpec(1, ratio[0] + ratio[1])
    ax = fig.add_subplot(gs.new_subplotspec((0, ratio[1]), colspan=ratio[0]))
    cax = fig.add_subplot(gs.new_subplotspec((0, 0), colspan=ratio[1]))

    with open('grid.dat', 'rt') as f:

        # Scroll to formula and read
        for _ in range(3):
            line = f.readline()
            el_matches = re.findall(r'\d+ (\w+)', line)

        # Scroll to number of points and read
        for _ in range(4):
            line = f.readline()
        npts = 5
        npts_matches = re.findall(r'first\s+(\d+) points', line)

        if len(npts_matches) == 1:
            npts = int(npts_matches[0])
        else:
            raise Exception("Couldn't read number of polyhedron corners")

        # Scroll to data lines and read coordinates from npts lines
        for _ in range(5):
            f.readline()
        region = np.zeros((npts, 2))

        for i in range(npts):
            line = f.readline().split()
            x, y = float(line[0]), float(line[1])
            region[i, :] = x, y

    # # Use convex hull solver to draw polyhedron edges in correct order
    # hull = np.array([region[i] for i in ConvexHull(region).vertices])
    # region_patch = Polygon(hull, facecolor=(0.6, 0.6, 0.6))
    # ax.add_patch(region_patch)

    # Read in rest of mesh, skipping header, region and '|' column
    mesh = np.genfromtxt('grid.dat', skip_header=(12 + npts),
                         usecols=(0, 1, 3))
    mesh_x = sorted(set(mesh[:, 0]))
    mesh_y = sorted(set(mesh[:, 1]))
    mesh_z = np.zeros((len(mesh_y), len(mesh_x))) * np.NaN
    for x, y, z in mesh:
        ix = mesh_x.index(x)
        iy = mesh_y.index(y)
        mesh_z[iy, ix] = z
    mesh_z = np.ma.masked_invalid(mesh_z)
    dep_mu = ax.pcolormesh(mesh_x, mesh_y, mesh_z, rasterized=True, cmap=cmap)
    cbar = fig.colorbar(dep_mu, cax=cax)
    cbar.set_label(r'$\mu$ ({}) / eV'.format(el_matches[2]))

    with open('2Dplot.txt', 'rt') as f:
        lines = f.readlines()

    data = OrderedDict()

    for i in range(len(lines) // 4 + 1):
        species = lines[i * 4][1:-1]

        x1, y1 = map(float, lines[i * 4 + 1].split())
        x2, y2 = map(float, lines[i * 4 + 2].split())

        data[species] = [[x1, x2], [y1, y2]]

    if xmin is None:
        xmin = ceil(min(min(coords[0]) for coords in data.values()))
    if ymin is None:
        ymin = ceil(min(min(coords[1]) for coords in data.values()))

    for species, (x, y) in data.items():
        ax.plot(x, y, '-', label=format_chem(species))

    ax.legend()
    ax.set_xlim(xmin, 0)
    ax.set_ylim(ymin, 0)
    ax.set_xlabel(r'$\mu$ ({}) / eV'.format(el_matches[0]))
    ax.xaxis.set_label_position('top')
    ax.xaxis.set_ticks_position('top')
    ax.set_ylabel(r'$\mu$ ({}) / eV'.format(el_matches[1]))
    ax.yaxis.set_label_position('right')
#.........这里部分代码省略.........
开发者ID:ajjackson,项目名称:mctools,代码行数:103,代码来源:plot_cplap_ternary.py


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