I would like to make a 3D plot using a function that returns a plot and the input argument it takes. This is my code for the function:
def cumulative(moment):
bins = np.zeros(32)
x = upper_bin
for i in range(32):
bins[i] = burst_average[moment, 0:i+1].sum()
plt.ylim(ymax = 1000)
plt.xlabel('grain size (um)')
plt.ylabel('concentration (uL/L)')
plt.title('grain size distribution over time')
plt.plot(x, bins, c = 'b', label=dates[i])
return
import ipywidgets as widgets
from ipywidgets import interact
interact(cumulative, moment=widgets.FloatSlider(min = int(0), max = int(nr_burst-1), step = 1, description = 'moment'));
where x
is a list of 32 values, bins
is an array of 32 values as well that changes for every moment
. In total, nr_burst plots are made, which is about 2017.
The widget works, however I want to include this in my report, so I would like a 3D plot instead.
I tried something like
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits import mplot3d
b0 = np.linspace(0, nr_burst-1, nr_burst)
b= []
for i in range(len(b0)):
b.append(int(b0[i]))
ax.scatter3D(cumulative(b), b)
This did not work, gave the error ValueError: Arguments 'xs' and 'ys' must be of same size.
I also tried the function to return x
and b
and plot
like
ax.scatter3D(cumulative(b)[0], b, cumulative(b)[1])
Which gave the error TypeError: 'NoneType' object is not subscriptable.