Пример #1
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()
Пример #2
0
fig = figure(figsize=(10, 6))
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_visible(True)
    ax.axis[direction].set_axisline_style("->")
for direction in ["top", "bottom", "left", "right"]:
    ax.axis[direction].set_visible(False)
ax.axis["yzero"].set_axis_direction("left")
ax.grid(True)
ax.minorticks_on()

ax.contour(x,
           y,
           x**2 + 2. * x * y + y**2 - 8. * x, [0],
           linewidths=1.5,
           colors='r')
ax.text(1.75, -4.5, r'$x^2+2xy+y^2-8x=0$', color='r')
ax.arrow(.5, -1, 0, 5, color='orange', head_width=.1, head_length=.2)
ax.text(.75, 4, r'$\bar{y}$', color='orange')
ax.arrow(-2.5, 1.5, 5.5, 0, color='orange', head_width=.1, head_length=.2)
ax.text(3, 1, r'$\bar{x}$', color='orange')
ax.plot(.5, 1.5, 'ko')
ax.text(.25, 1.75, r'V')

ax.arrow(-4.5, -4.5, 9, 9, color='m', ls='dashed', lw=.5), ax.text(-4,
                                                                   -4,
                                                                   r'$x=y$',
                                                                   color='m')
ax.arrow(-5.5, -4.5, 9, 9, color='grey', ls='dashed',