I need help with the maths side for plotting my points on my graph, For my graphing software.
For example, I define my function here with the points I want to plot [[x, y], [x, y]], etc…
graph.plot([[1.52, 0.4], [1.86, 0.5], [2.32, 0.6]])
In the code for the function, the problem is that I am multiplying my x and y points from the 2d array by 100 to scale. It is not particularly nice, but it does scale to some extent. I am trying to achieve a way that scales any point to the graph and If I need to use different points instead of the ones provided above. It would scale to the size of the graph accordingly. So the points use advantage of the entire graph provided instead of plotting the points in a small scale area.
def plot(self, points):
for point in points:
x, y = point
plot_x = self.axis_x + (x * 100) # testing x
plot_y = self.axis_y - (y * 100) # testing y
pygame.draw.circle(screen, (255, 0, 0), (plot_x, plot_y), 5)
Here is the entire code, If needed: text
user25770302 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.