|
@@ -9,6 +9,7 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
"""
|
|
"""
|
|
import os, sys
|
|
import os, sys
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.pyplot as plt
|
|
|
|
+from mpl_toolkits.mplot3d import Axes3D
|
|
|
|
|
|
plt.rcParams.update({'figure.max_open_warning': 0})
|
|
plt.rcParams.update({'figure.max_open_warning': 0})
|
|
|
|
|
|
@@ -38,10 +39,19 @@ class Collatz(object):
|
|
print(' - Tree =', self.tree)
|
|
print(' - Tree =', self.tree)
|
|
plt.figure()
|
|
plt.figure()
|
|
fig = plt.figure(1)
|
|
fig = plt.figure(1)
|
|
- ax = fig.add_subplot(111, facecolor='black')
|
|
|
|
|
|
+ ax = plt.gca(projection="3d")
|
|
|
|
+ xs = []
|
|
|
|
+ ys = []
|
|
|
|
+ zs = []
|
|
for t in self.tree:
|
|
for t in self.tree:
|
|
- ax.scatter(self.tree.index(t)+1, t, color="red", s=2)
|
|
|
|
- plt.clf() # removing matplot future warning
|
|
|
|
|
|
+ z = float(t)
|
|
|
|
+ y = z
|
|
|
|
+ x = y
|
|
|
|
+ xs.append(x)
|
|
|
|
+ ys.append(y)
|
|
|
|
+ zs.append(z)
|
|
|
|
+ ax.scatter(xs,ys,zs, c='red',s=100)
|
|
|
|
+ ax.plot(xs,ys,zs, color='green')
|
|
header = '"Tree" for number '+str(self.root)+' to becomes 1'
|
|
header = '"Tree" for number '+str(self.root)+' to becomes 1'
|
|
plt.title(header)
|
|
plt.title(header)
|
|
plt.ylabel('Number(s)')
|
|
plt.ylabel('Number(s)')
|
|
@@ -62,6 +72,7 @@ class Collatz(object):
|
|
if not self.mode == "l" or self.mode == "L" or self.mode == "Learn" or self.mode == "learn":
|
|
if not self.mode == "l" or self.mode == "L" or self.mode == "Learn" or self.mode == "learn":
|
|
print("\n[Info] You have this 'tree' secuence previously saved. Exiting...\n")
|
|
print("\n[Info] You have this 'tree' secuence previously saved. Exiting...\n")
|
|
ax.clear()
|
|
ax.clear()
|
|
|
|
+ plt.clf()
|
|
|
|
|
|
def generate_forest(self, rng):
|
|
def generate_forest(self, rng):
|
|
srng = rng.split('-')
|
|
srng = rng.split('-')
|