I am creating an extremely basic ASCII plotting module for Python. When I call my graph.plot() function, it ignores the Y and plots the icon for the X coordinate in all the lists within the main list.
class Plotsy():
def __init__(self):
self.config("#", [3, 3])
def config(self, icon, size):
#Choose the plotted icon
self.icon = icon
#Make "size" useable throughout the object for math
self.size = size
#Create the grid
self.graph = [["@"] * self.size[0]] * self.size[1]
def plot(self, coords):
self.graph[coords[1]][coords[0]] = self.icon
def draw(self):
pass
#A very short example to plot things
graph = Plotsy()
graph.plot([1, 2])
#After this problem is resolved, this will be replaced with my draw() function to print it correctly
print graph.graph
The graph variable works like this - the lists within the outermost list is the Y (these lists will be printed on their own lines), and the values in those lists are for the X coordinate. plot() takes one parameter, which is a list of the X and Y coordinates.
Why does it do this, and how can I fix it?