I teach myself about matplotlib and Python, and it's hard for me to plot for an elliptic curve. I have an equation but i don't do y^2
This is as much trouble as I was able to catch up with myself:
from mpl_toolkits.axes_grid.axislines import SubplotZero import matplotlib.pyplot as plt import numpy as np from pylab import * def plotGraph(): 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) a = 5; b = 25 x = np.arange(-50.0, 50.0, 1.0) y = pow(x,3) + a*x + b xmin = -50; xmax = 50; ymin = -50; ymax = 50 v = [xmin, xmax, ymin, ymax] ax.axis(v) ax.plot(x, pow(y,2))
axis() is because I was also trying to get a clearer diagram with grid lines, and I thought grid() take care of that too, but apparently not. I was also going to try to make it interactive when you click on the points you need, and it calculates, but looking at the documents, it seems that there are many options for interacting with the mouse, but I donโt see the interaction with the mouse that creates an event by clicking at a point on the graph (after I read it a third time, I'm still missing).
I am just switching from a resume summary to matplotlib , but I don't see what I'm doing wrong here. The graph of the elliptic curve leaves, does not even close.
This is probably a beginnerโs mistake, so a junior programmer who takes a second to read this will probably see very quickly why I donโt get the curve I want.
source share