(Very new to python) So I've made a 3D scatterplot to which I would like to add dots of different "types". At the moment I would like to append values to X1, Y1, Z1 to create the points in question. If I type those in by hand, there doesn't seem to be any issue. However, when I try to use the append function outside of the class, the dots do not show on my plot. I would like to be able to externally append or add points on my scatterplot.
import numpy as np
import math
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
font = {'fontname': 'Franklin Gothic Demi'}
title = {'fontname': 'Bookman Old Style'}
diameter = 3500
width = 200
class world(object):
def __init__(self):
self.fig = plt.figure()
self.fig.add_subplot(111, projection="3d")
self.ax = plt.gca()
self.t = 0
self.X1 = []
self.Y1 = []
self.Z1 = []
self.ax.scatter(self.X1, self.Y1, self.Z1, c="r", marker="1", depthshade=True)
self.ax.set_xlabel("synaptic diameter (nm)", color = "navy", **font)
self.ax.set_ylabel("synaptic diameter (nm)", color = "navy", **font)
self.ax.set_zlabel("cleft width (nm)", color = "navy", **font)
self.ax.autoscale(enable=True)
self.ax.set_xlim(0, diameter)
self.ax.set_ylim(0, diameter)
self.ax.set_zlim(0, width)
plt.gca().invert_xaxis()
plt.title("Synapse", color = "black", size = 20, **title)
self.Serotonin = []
self.MAO = []
self.immobileAgents = []
#not yet relevant here
def showPlot(self):
self.showPlot = plt.show()
Here is (one of) the function(s) I used to append values to the lists
world = world()
tee = 0
while tee <= 100:
world.X1.append(tee)
world.Y1.append(tee)
world.Z1.append(tee)
tee = tee + 1
print (world.X1)
print (world.Y1)
print (world.Z1)
#just to be sure
world.showPlot()
Note that in this case, the prupose is merely to be able to see the dots on my plot. Their placement doesn't matter at all yet.