示例#1
0
def visualize_test_between_class(test, human, non_human):
    fig = plt.figure("Trajectories for Test, Human, and Non-Human")
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    line_style = ['r.-', 'gx-', 'bo-']

    # plotting test data
    x = [i.pose.position.x for i in test]
    y = [i.pose.position.y for i in test]
    ax.plot(x, y, line_style[0], label="Test")
    # plotting human data
    x = [i.pose.position.x for i in human]
    y = [i.pose.position.y for i in human]
    ax.plot(x, y, line_style[1], label="Human")
    # plotting non-human data
    x = [i.pose.position.x for i in non_human]
    y = [i.pose.position.y for i in non_human]
    ax.plot(x, y, line_style[2], label="Non-human")

    ax.margins(0.05)
    ax.legend(loc="lower right", fontsize=10)
    plt.title("Chunks of Trajectories")
    plt.xlabel("Axis")
    plt.ylabel("Ordinate")

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    pylab.grid()
    plt.show()
示例#2
0
def test_m_n_computation(obj_img, theta, Nx, Ny, dx, dy, Nt, Nr, dr):
    
    bx = -Nx/2 * dx 
    by = -Ny/2 * dy 
    xmin = -(Nx-1)/2.0*dx
    ymin = -(Ny-1)/2.0*dy
    
    legend_list = []
    fig = plt.figure(figsize=(8,8))
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    plt.imshow(obj_img, cmap=plt.cm.gray, interpolation='none', \
                        extent=[bx,-bx, by, -by], alpha=0.5)
    for t in np.arange(Nr):   
        if np.sin(theta) < 1.0/np.sqrt(2):
            data = test_n_computation(theta, t, Nx, Ny, dx, dy, Nt, Nr, dr)
        else:
            data = test_m_computation(theta, t, Nx, Ny, dx, dy, Nt, Nr, dr)
        #rdata = np.round(data)
        plt.plot(data[0,:]*dx+xmin, data[1,:]*dy+ymin,'*-', linewidth = 3 )  
        legend_list.append('(t=' + str(t) + ')')
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    ax.xaxis.set_ticks(np.arange(-Nx,Nx,2))
    ax.yaxis.set_ticks(np.arange(-Ny,Ny,2))
    plt.axis('equal')
    plt.grid(True)
    plt.legend(legend_list)
    plt.title('Angle: ' + str(theta*180/np.pi))
示例#3
0
def setup_two_axes_subplot(fig, m, n, curr_plot_num, invisible=["bottom", "top", "right"]):
    ax = SubplotZero(fig, m, n, curr_plot_num)
    fig.add_subplot(ax)
    ax.axis["xzero"].set_visible(True)
    for n in invisible:
        ax.axis[n].set_visible(False)
    return ax
示例#4
0
def plot_func(a, b, c, out_putline):
    '''Plot the line function in a coordinate axis

        Parameters:
        a -- The coefficient for y in the standard for Ay + Bx = C
        b -- The coefficient for x in the standard for Ay + Bx = C
        c -- The constanct C in the standard for Ay + Bx = C
        out_putline -- The string of the standard form Ay + Bx = C
    '''

    # Unable to plot if the coefficient of x or y equals to 0
    if b == 0:
        sys.stderr.write('Unable to plot a vertical line!!!\n')
        sys.exit(1)

    if a == 0:
        sys.stderr.write('Unable to plot a horizontal line!!!\n')
        sys.exit(1)

    # General steps to generate an axis
    try:
        fig = plt.figure(1)
        ax = SubplotZero(fig, 111)
        fig.add_subplot(ax)
    except Exception, e:
        sys.stderr.write('Unable to use matplotlib!!!\n')
        sys.exit(1)
示例#5
0
文件: axes.py 项目: antalcides/python
def mplot(sage_plot, equal_scale=False, edit_res=False):
    """
    This function convert sage_plot, created at sage, in matplotlib graph.
    """
    plt.clf()
    fig = plt.figure()
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    L = sage_plot.matplotlib().gca().lines
    for t in L:
        data = t.get_data()
        ax.add_line(mpl.lines.Line2D(data[0], data[1]))
    ax.autoscale_view()
    if equal_scale:
        ax.axis('equal')
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>", size=2)
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    ax.axis["yzero"].set_axis_direction("left")
    ax.minorticks_on()
    ax.grid()
    if edit_res:
        return (fig)
    else:
        plt.savefig('')
        plt.show()
        plt.close()
示例#6
0
文件: plot.py 项目: o2edu/MathsExams
def _blank_plot(domain, ran):
    # make the plot
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    # thicken the axis lines
    ax.axhline(linewidth=1.7, color="k")
    ax.axvline(linewidth=1.7, color="k")

    x_lower, x_upper = int(domain.left), int(
        domain.right)  # needs to be changed, is just a temporary type changer
    y_lower, y_upper = int(ran.left), int(ran.right)

    # remove tick lines on the axes
    plt.xticks([])
    plt.yticks([])
    plt.ylim(y_lower, y_upper)
    plt.xlim(x_lower, x_upper)

    # add axes labels
    ax.text(1.05,
            0,
            r'$x$',
            transform=BlendedGenericTransform(ax.transAxes, ax.transData),
            va='center')
    ax.text(0,
            1.05,
            r'$y$',
            transform=BlendedGenericTransform(ax.transData, ax.transAxes),
            ha='center')

    # end-of-axis arrows
    x_width = (abs(plt.xlim()[0]) + abs(plt.xlim()[1]))
    y_width = (abs(plt.ylim()[0]) + abs(plt.ylim()[1]))
    plt.arrow(plt.xlim()[1],
              -0.003,
              0.00000000001,
              0,
              width=x_width * 0.0015 * 0.5,
              color="k",
              clip_on=False,
              head_width=y_width * 0.12 / 7,
              head_length=x_width * 0.024 * 0.5)
    plt.arrow(0.003,
              plt.ylim()[1],
              0,
              0.00000000001,
              width=y_width * 0.0015 * 0.5,
              color="k",
              clip_on=False,
              head_width=x_width * 0.12 / 7,
              head_length=y_width * 0.024 * 0.5)

    # only show cartesian axes
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
示例#7
0
 def plot_L(self):
     fig = plt.figure(1)
     ax = SubplotZero(fig, 111)
     fig.add_subplot(ax)
     for el in self.L:
         self.plot_box(X=el, index=0, this_color='blue', canvas=ax)
     ax.set_xlim(-15., 15.)
     ax.set_ylim(-15., 15.)
     ax.axis('equal')
     plt.show()
示例#8
0
def subplots():
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    return fig, ax
示例#9
0
	def __init__(self):
		self.fig = plt.figure(1)
		self.ax = SubplotZero(self.fig,111)
		self.fig.add_subplot(self.ax)

		for direction in ["xzero","yzero"]:
			self.ax.axis[direction].set_axisline_style("-|>")
			self.ax.axis[direction].set_visible(True)

		for direction in ["left","right","bottom","top"]:
			self.ax.axis[direction].set_visible(False)
    def renderGraph(self):  # pylint: disable=R0914
        assert len(self._oData.aoSeries) == 1
        oSeries = self._oData.aoSeries[0]

        # hacking
        #self.setWidth(512);
        #self.setHeight(128);
        # end

        oFigure = self._createFigure()
        from mpl_toolkits.axes_grid.axislines import SubplotZero
        # pylint: disable=E0401
        oAxis = SubplotZero(oFigure, 111)
        oFigure.add_subplot(oAxis)

        # Disable all the normal axis.
        oAxis.axis['right'].set_visible(False)
        oAxis.axis['top'].set_visible(False)
        oAxis.axis['bottom'].set_visible(False)
        oAxis.axis['left'].set_visible(False)

        # Use the zero axis instead.
        oAxis.axis['yzero'].set_axisline_style('-|>')
        oAxis.axis['yzero'].set_visible(True)
        oAxis.axis['xzero'].set_axisline_style('-|>')
        oAxis.axis['xzero'].set_visible(True)

        if oSeries.aoYValues[-1] == 100:
            sColor = 'green'
        elif oSeries.aoYValues[-1] > 75:
            sColor = 'yellow'
        else:
            sColor = 'red'
        oAxis.plot(oSeries.aoXValues,
                   oSeries.aoYValues,
                   '.-',
                   color=sColor,
                   linewidth=3)
        oAxis.fill_between(oSeries.aoXValues,
                           oSeries.aoYValues,
                           facecolor=sColor,
                           alpha=0.5)

        oAxis.set_xlim(left=-0.01)
        oAxis.set_xticklabels([])
        oAxis.set_xmargin(1)

        oAxis.set_ylim(bottom=0, top=100)
        oAxis.set_yticks([0, 50, 100])
        oAxis.set_ylabel('%')
        #oAxis.set_yticklabels([]);
        oAxis.set_yticklabels(['', '%', ''])

        return self._produceSvg(oFigure, False)
示例#11
0
def plot(points):
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    plt.ylim([-10, 10])
    plt.xlim([-10, 10])
    ax.plot(*zip(*points), marker='o', color='r', ls='')
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    plt.show()
示例#12
0
 def plot_subpaving(self):
     fig = plt.figure(1)
     ax = SubplotZero(fig, 111)
     fig.add_subplot(ax)
     for el in self.outside:
         self.plot_box(X=el, index=0, this_color='red', canvas=ax)
     for el in self.boundary:
         self.plot_box(X=el, index=0, this_color='yellow', canvas=ax)
     for el in self.inside:
         self.plot_box(X=el, index=0, this_color='green', canvas=ax)
     ax.set_xlim(-12., 12.)
     ax.set_ylim(-12., 12.)
     ax.axis('equal')
     plt.show()
     return
示例#13
0
def setup_two_axes(fig, labelpad=1, invisible=["bottom", "top", "right"]):
    plt.rcParams['xtick.major.pad'] = 0.1
    plt.rcParams['xtick.minor.pad'] = 0.1
    plt.rcParams['ytick.major.pad'] = 2
    plt.rcParams['ytick.minor.pad'] = 2
    ax = SubplotZero(fig, 1, 1, 1)
    ax.yaxis.labelpad = labelpad
    fig.add_subplot(ax)
    # make xzero axis (horizontal axis line through y=0) visible.
    ax.axis["xzero"].set_visible(True)
    ax.xaxis.labelpad = labelpad    
    # make other axis (bottom, top, right) invisible.
    for n in invisible:
        ax.axis[n].set_visible(False)
    return ax
示例#14
0
def initplot(size):
    """
    Inicializa o desenho de gráficos.
    """
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    ax.set_xlim(-10, size)
    ax.set_ylim(-10, size)

    return (fig, ax)
示例#15
0
def test():
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    x = np.linspace(-0.5, 1., 100)
    ax.plot(x, np.sin(x * np.pi))

    plt.show()
示例#16
0
def open_window_and_show_results(points, curve, bezier_points):

    # Generate the curve
    curve_begin = min(points, key=lambda p: p.x)
    curve_end = max(points, key=lambda p: p.x)

    curve_begin = floor(curve_begin.x)
    curve_end = ceil(curve_end.x)

    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    curve_points = []

    if (len(curve) == 3):
        curve_points = generate_curve_points_quadratic(
            [x * 0.1 for x in range(curve_begin * 10, curve_end * 10)],
            curve[0], curve[1], curve[2])  # values for x²
    elif (len(curve) == 4):
        curve_points = generate_curve_points_cubic(
            [x * 0.1 for x in range(curve_begin * 10, curve_end * 10)],
            curve[0], curve[1], curve[2], curve[3])  # values for x²
    else:
        raise "Length of curve has to be 3 or 4"

    # plot_points(plt, curve_points, 'blue')

    # plot_points(plt, points, 'ro')
    plot_points(plt, points, 'red')

    plot_points(plt, bezier_points, 'go')

    plot_points(
        plt,
        draw_bezier_curve(bezier_points[0], bezier_points[1], bezier_points[2],
                          bezier_points[3]), 'orange')

    plt.show()
示例#17
0
def test_min_max_plane_indices(obj_img, Nx, Ny, dx, dy, Nt, Nr, dr):

    bx = -Nx / 2 * dx
    by = -Ny / 2 * dy
    fovx = Nx * dx
    fovy = Ny * dy
    r = np.ceil(np.sqrt((fovx)**2 + (fovy)**2))
    xc = dx / 2
    yc = -dy / 2
    sdd = 2 * r

    p1x = np.zeros(Nt, dtype=TYPE)
    p1y = np.zeros(Nt, dtype=TYPE)
    p2x = np.zeros(Nt, dtype=TYPE)
    p2y = np.zeros(Nt, dtype=TYPE)
    for angle in np.arange(Nt):
        text = ''
        legend_list = []
        fig = plt.figure(figsize=(8, 8))
        ax = SubplotZero(fig, 111)
        fig.add_subplot(ax)
        plt.imshow(obj_img, cmap=plt.cm.gray, interpolation='none', \
                            extent=[bx,-bx, by, -by], alpha=0.5)
        for t in np.arange(-Nr / 2, Nr / 2):
            # find p1-detector and p2-source coordinates
            p1x[angle], p1y[angle] = get_p1(angle * np.pi / Nt, t, r, xc, yc,
                                            dr)
            p2x[angle], p2y[angle] = get_p2(angle*np.pi/Nt, sdd, p1x[angle], \
                                            p1y[angle])
            plt.plot( [p1x[angle], p2x[angle]] ,[p1y[angle], p2y[angle]], ':',\
                      linewidth = 3 )
            imin, imax, jmin, jmax = min_max_plane_indices(Nx, Ny, \
                p1x[angle], p1y[angle], p2x[angle], p2y[angle], bx, by, dx, dy)
            text += '(t=' + str(t) + ') imin:' + str(imin) + ', imax:' + \
                    str(imax) + ' ,jmin:' + str(jmin) + ' ,jmax:' + \
                    str(jmax) + '\n'
            legend_list.append('(t=' + str(t) + ')')
        for direction in ["xzero", "yzero"]:
            ax.axis[direction].set_axisline_style("-|>")
            ax.axis[direction].set_visible(True)
        ax.xaxis.set_ticks(np.arange(-Nx, Nx, 2))
        ax.yaxis.set_ticks(np.arange(-Ny, Ny, 2))
        plt.axis('equal')
        plt.grid(True)
        plt.legend(legend_list)
        plt.title(text, fontsize=10)
示例#18
0
def make_zerocross_axes(figsize, loc):
    from matplotlib import pyplot as plt
    from mpl_toolkits.axes_grid.axislines import SubplotZero

    fig = plt.figure(figsize=figsize)
    ax = SubplotZero(fig, loc)
    ax.set_aspect("equal")
    fig.add_subplot(ax)

    for direction in ["xzero", "yzero"]:
        axis = ax.axis[direction]
        axis.set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    return ax
示例#19
0
def make_plot_ax():
    fig = figure(figsize=(6, 5))
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    xlim(-0.1, 2.1)
    ylim(xlim())
    ticks = [0.5 * i for i in range(1, 5)]
    labels = [str(i) if i == int(i) else "" for i in ticks]
    ax.set_xticks(ticks)
    ax.set_yticks(ticks)
    ax.set_xticklabels(labels)
    ax.set_yticklabels(labels)
    ax.axis["yzero"].set_axis_direction("left")
    return ax
示例#20
0
def plot_points_helper(x, y, x_poly, y_poly, scale_plot=True):

    figure = plt.figure(figsize=(12, 8))
    ax = SubplotZero(figure, 111)
    figure.add_subplot(ax)

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    scale = np.mean(x[x > 0]) + np.mean(y[y > 0]) if scale_plot else 0
    plt.xlim([min(x) - scale, max(x) + scale])
    plt.ylim([min(y) - scale, max(y) + scale])

    plt.scatter(x, y)
    plt.plot(x_poly, y_poly, color='r')
    plt.show()
示例#21
0
    def plotUnitCircle(p):
        """ plot some 2D vectors with p-norm < 1 """
        fig = plt.figure(1)
        ax = SubplotZero(fig, 111)
        fig.add_subplot(ax)

        for direction in ["xzero", "yzero"]:
            ax.axis[direction].set_axisline_style("-|>")
            ax.axis[direction].set_visible(True)

        for direction in ["left", "right", "bottom", "top"]:
            ax.axis[direction].set_visible(False)

        x = np.linspace(-1.0, 1.0, 1000)
        y = np.linspace(-1.0, 1.0, 1000)
        X, Y = np.meshgrid(x, y)
        F = (((abs(X) ** p + abs(Y) ** p) ** (1.0 / p)) - 1)
        ax.contour(X, Y, F, [0])
        plt.savefig('UnitCircle.pdf', facecolor='w', edgecolor='w',
                    papertype=None, format='pdf', transparent=False,
                    bbox_inches='tight', pad_inches=0.1)
        plt.show()
示例#22
0
    def create_plot(self, scale, y_bounds, points=None, file_name=None):
        """
        Using matplotlib, graphs the given points on a Cartesian plane.

        Adapted from the matplotlib documentation:
        https://matplotlib.org/examples/axes_grid/demo_axisline_style.html.

        args:
            scale: Numpy array of increments for the x-axis.
            points: Numpy array of points' Y-values to be plotted.
            y_bounds: integer determining scale of y axis
            file_name: name for plot to be serialized under.
        """

        import matplotlib
        matplotlib.use('Agg')
        import matplotlib.pyplot as plt

        fig = plt.figure(1)
        subplot = SubplotZero(fig, 111)
        fig.add_subplot(subplot)

        for direction in ['xzero', 'yzero']:
            subplot.axis[direction].set_axisline_style('-|>')
            subplot.axis[direction].set_visible(True)

        for direction in ['left', 'right', 'bottom', 'top']:
            subplot.axis[direction].set_visible(False)

        subplot.set_ylim([-y_bounds, y_bounds])

        if points is not None:
            subplot.plot(scale, points)

        if file_name:
            plt.savefig(file_name)
        else:
            plt.show()
示例#23
0
ax0.axis('off')
ax0.set_title('extracellular potential')
ax1 = fig.add_subplot(gs[:6, 1], aspect='equal')  # dipole moment ill.
ax1.axis('off')
ax1.set_title('extracellular potential')
ax2 = fig.add_subplot(gs[:6, 2], aspect='equal')  # dipole moment ill.
ax2.axis('off')
ax2.set_title('magnetic field')
# ax3 = fig.add_subplot(gs[0, 3], aspect='equal')             # spherical shell model ill.
# ax3.set_title('4-sphere volume conductor')
# ax4 = fig.add_subplot(gs[1, 3],
# aspect='equal'
# )                 # MEG/EEG forward model ill.
# ax4.set_title('EEG and MEG signal detection')

ax3 = SubplotZero(fig, gs[7:, 0])
fig.add_subplot(ax3)
ax3.set_title('4-sphere volume conductor', verticalalignment='bottom')
ax4 = fig.add_subplot(gs[7:, 1])  # EEG
ax4.set_title('scalp electric potential $\phi_\mathbf{p}(\mathbf{r})$')
ax5 = fig.add_subplot(gs[7:, 2], sharey=ax4)  # MEG
# ax5.set_title('scalp magnetic field')

#morphology - line sources for panels A and B
zips = []
xz = cell.get_idx_polygons()
for x, z in xz:
    zips.append(zip(x, z))
for ax in [ax0]:
    polycol = PolyCollection(zips,
                             linewidths=(0.5),
示例#24
0
文件: figure_5.py 项目: tfiers/LFPy
                    alphabet[4],
                    horizontalalignment='center',
                    verticalalignment='center',
                    fontsize=16,
                    fontweight='demibold',
                    transform=ax.transAxes)

        plotting.remove_axis_junk(ax)
        t = np.arange(p_net.shape[1]) * PSET.dt * PSET.decimate_q
        inds = (t >= T[0]) & (t <= T[1])
        ax.plot(t[inds], p_net[i, inds], 'k', lw=1)
        ax.set_ylabel(ylabel)
        ax.set_xticklabels([])

    # panel F. Illustration of 4-sphere volume conductor model geometry
    ax = SubplotZero(fig, gs[2, 1])
    fig.add_subplot(ax)
    ax.set_title('four-sphere volume conductor model')

    for direction in ["xzero"]:
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    theta = np.linspace(0, np.pi, 31)

    # draw some circles:
    for i, r, label in zip(range(4), PSET.foursphereParams['radii'],
                           ['brain', 'CSF', 'skull', 'scalp']):
        ax.plot(np.cos(theta) * r,
示例#25
0
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 15 23:07:24 2017

@author: Lenovo-Y430p
"""
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero
import numpy as np
width = 1  # 两条柱之间的距离
num = 5  #柱的个数
ind = np.arange(num)

fig = plt.figure(figsize=(15, 4))
ax = SubplotZero(fig, 1, 3, 1)
ax1 = fig.add_subplot(ax)

means = [0.6481, 0.6215, 0.58, 0.56, 0.442]
stds = [0.0129, 0.0119, 0.01, 0.009, 0.003]

plt.bar(0.2 + ind,
        means,
        0.6 * width,
        color=['k', 'r', 'c', 'y', 'r'],
        linewidth=0.1,
        yerr=stds,
        error_kw=dict(elinewidth=1.5, ecolor='green'))
plt.axis([0, 5, 0, 1])
plt.ylabel(u'wPrecision')
plt.grid()
plt.xticks([])
示例#26
0
#!/usr/bin/env python3

from mpl_toolkits.axes_grid.axislines import SubplotZero
from matplotlib.transforms import BlendedGenericTransform
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np


if __name__ == '__main__':

    fig = plt.figure(1)
    ax = SubplotZero(fig, 1, 1, 1)
    # fig.autofmt_xdate(bottom=0.2, rotation=30, ha='right')

    fig.add_subplot(ax)



    ax.text(-1.15, 0.99, 'y', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center')
    ax.text(1., -0.25, 'x', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center')
    #
    for direction in ["xzero", "left"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    x = np.linspace(-1., +1., 1000) # x < 0
    # print(x)
示例#27
0
# ########################
Sigma=np.array([[S11,S12,S13],[S12,S22, S23 ],[S13,S23, S33 ]],float)
print("Sigma=", Sigma)
VP=np.linalg.eigvals(Sigma)
Sig_max= np.max((VP)) + 5
Sig_min= np.min((VP)) - 5 


# ########################
# Set up the figure, the axis, and the plot element we want to animate
# ########################
fig = plt.figure(1)

# Espace x,y
# Espace Snn,Snt
ax2 = SubplotZero(fig, 111)
fig.add_subplot(ax2)
#
for direction in ["xzero", "yzero"]:
    ax2.axis[direction].set_axisline_style("-|>")
    ax2.axis[direction].set_visible(True)
#
for direction in ["left", "right", "bottom", "top"]:
    ax2.axis[direction].set_visible(False)
    
ax2.set_aspect('equal')

ax2.set_xlim(Sig_min, Sig_max)
ax2.set_ylim(-(Sig_max-Sig_min)/2, (Sig_max-Sig_min)/2)
ax2.text(0., 1.05, '$\sigma_{nt}$',size=20, transform=BlendedGenericTransform(ax2.transData, ax2.transAxes))
ax2.text(1.05, -0.15, '$\sigma_{nn}$',size=20, transform=BlendedGenericTransform(ax2.transAxes, ax2.transData))
示例#28
0
"""
Created on Fri Jun 23 10:19:29 2017

@author: Lenovo-Y430p
"""

from pylab import mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
#from numpy import *
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import math
from mpl_toolkits.axes_grid.axislines import SubplotZero
fig = plt.figure()
ax = SubplotZero(fig, 2, 2, 1)
ax1 = fig.add_subplot(ax)
#rect=[0.1,0.1,0.8,0.8]
#axprops = dict(xticks=[], yticks=[])

#ax0=fig.add_axes(rect, label='ax0',**axprops)
imgP = plt.imread("面积11.jpg")
ax1.imshow(imgP / 256)
#ax1=fig.add_axes(rect, label='ax1',frameon=False)
#x = np.linspace(0,10,100)
#y = math.sin(x)
#ax1.plot(x,y)
ax1.set_title(" 10mm2 in 0.5h")
#ax1.set_ylim([-5,12])
ax = SubplotZero(fig, 2, 2, 2)
ax2 = fig.add_subplot(ax)
#!/bin/env python
from mpl_toolkits.axes_grid.axislines import SubplotZero
import matplotlib.pyplot as plt
import numpy as np

if 1:
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    x = np.linspace(-0.5, 1., 100)
    ax.plot(x, np.sin(x * np.pi))

    plt.show()
    plt.savefig("foo.png")
    plt.savefig("foo.eps")
    plt.savefig("foo.pdf")
示例#30
0
##Input : the stress tensor
##Output : anmiation

# ########################
# INPUT : Stress tensor ! must be a plan stress state !
# ########################
Sigma = np.array([[400, 100, 0], [100, -200, 0], [0, 0, 0]], float)
print("Sigma=", Sigma)

# ########################
# Set up the figure, the axis, and the plot element we want to animate
# ########################
fig = plt.figure(1)
Sig_max = 500.0
# Espace x,y
ax1 = SubplotZero(fig, 121)
fig.add_subplot(ax1)
#
for direction in ["xzero", "yzero"]:
    ax1.axis[direction].set_axisline_style("-|>")
    ax1.axis[direction].set_visible(True)
#
for direction in ["left", "right", "bottom", "top"]:
    ax1.axis[direction].set_visible(False)

ax1.set_aspect('equal')

ax1.set_xlim(-Sig_max, Sig_max)
ax1.set_ylim(-Sig_max, Sig_max)
ax1.text(0.,
         1.05,