I may be doing something really stupid, but I've been using plotly offline in my jupyter notebook using
import plotly.offline as py
py.init_notebook_mode(connected=True)
from plotly.graph_objs import *
I'm trying to display a sequence of images that can be navigated with a slider. The entire numpy array with the image data is 50 images x 64 wide x 64 tall.
I put that into the following slider function I pieced together from code I found online. The Figure object itself that's returned is not very large. However, when plotly's iplot
is called, the size of my jupyter notebook on disk (as measured by ls -l
) is really big - like 15 MB, even though the numpy source data is like 1MB. This becomes unmanageable for larger/multiple figures. Does anyone know what's going on?
def slider_ims(imgs):
imgs = np.flip(imgs,1)
data = [dict(
type='heatmap',
z = imgs[step,:,:],
visible = False,
showscale=False,
xaxis="x",
yaxis="y",
name = 'z = '+str(step)) for step in np.arange(imgs.shape[0])]
data[0]['visible'] = True
steps = []
for i in range(len(data)):
step = dict(
method = 'restyle',
args = ['visible', [False] * len(data)],
label = str(i)
)
step['args'][1][i] = True # Toggle i'th trace to "visible"
steps.append(step)
sliders = [dict(
active = 0,
currentvalue = {"prefix": "Frame: "},
pad = {"t": 50},
steps = steps,
ticklen = 0,
minorticklen = 0
)]
layout = Layout(
sliders = sliders,
font=Font(family='Balto'),
width=800,
height=600,
)
fig=Figure(data=data, layout=layout)
py.iplot(fig)
return fig