Esempio n. 1
0
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()
Esempio n. 2
0
X = linspace(0, 10, 25)
Y = linspace(-5, 5, 25)
x, y = meshgrid(X, Y)

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,