I`m trying to plot 2 sets of data on a single 3D plot.
What I expect to see is these two images on the same plot:
The plot I am looking for is this:
I use Anaconda and Jupiter, matplotlib 1.5.1.
This is my code so far:
from mpl_toolkits.mplot3d import Axes3D
import mpl_toolkits.mplot3d as a3
import matplotlib.pyplot as plt
import cop
class var1:
def __init__(self,b1, b2):
self.pt1 = copy.deepcopy(b1)
self.pt2 = copy.deepcopy(b2)
self.cords = (
list(self.pt1 + [high]), # top-left
list(self.pt2 + [high]), # top-right
list(self.pt2 + [low]), # bottom-right
list(self.pt1 + [low]), # bottom-left
)
def drawFunction(self):
dataSet1 = a3.art3d.Poly3DCollection([self.cords])
dataSet1.set_color('firebrick')
dataSet1.set_edgecolor('k')
ax.add_collection3d(dataSet1) #If you comment out this line- var2 will be shown. I`m trying to show one on top of the other
var2(self.pt1, self.pt2, high, low).drawFunction()
class var2:
def __init__(self,b1, b2, high, low):
self.pt1 = copy.deepcopy(b1)
self.pt2 = copy.deepcopy(b2)
self.cords = (
list(self.pt1 + [(high/2) + (high/4)]), # top-left
list(self.pt2 + [(high/2) + (high/4)]), # top-right
list(self.pt2 + [(high/2) - (high/4)]), # bottom-right
list(self.pt1 + [(high/2) - (high/4)]), # bottom-left
)
def drawFunction(self):
dataSet2 = a3.art3d.Poly3DCollection([self.cords])
dataSet2.set_color('cornflowerblue')
dataSet2.set_edgecolor('k')
ax.add_collection3d(dataSet2)
high = 500
low = 0
fig = plt.figure()
ax = Axes3D(fig)
i = 0
while i<4:
if (i==0):
p1 = [0,200]
p2 = [0,0]
if (i==1):
p1 = [0,0]
p2 = [200,0]
if (i==2):
p1 = [200,0]
p2 = [200,200]
if (i==3):
p1 = [200,200]
p2 = [0,200]
var1(p1, p2).drawFunction()
i = i+1
ax.set_xlim(0,200)
ax.set_ylim(0, 200)
ax.set_zlim(0, 1000)
plt.show()