I’m running the following code to create a dash plotly app with an image created by matplotlib.
I’m getting the following error message.
“Aw. Snap! You’re gonna have to hold off on the selfies for now. Plotly can’t import images from matplotlib yet!”
Is there a workaround? I can use plotly imshow function, but it takes 10 times longer to create an image. I’m trying to reduce the lag time between the image updates for my interactive app.
This is just a sample code to indicate the problem.
from plotly.tools import mpl_to_plotly
from matplotlib import pyplot as plt
import dash
import dash_html_components as html
import dash_core_components as dcc
from jupyter_dash import JupyterDash
import dash_bootstrap_components as dbc
import numpy as np
app= JupyterDash(name, external_stylesheets=[dbc.themes.LUX], #[dbc.themes.BOOTSTRAP],
meta_tags=[{‘name’: ‘viewport’,
‘content’: ‘width=device-width, initial-scale=1.0’}],
)
fig= plt.figure()
ax= fig.add_subplot(111)
image = np.random.random([300, 5000])
ax.imshow(image, vmin=0, vmax=1, cmap=“gray_r”, aspect=“auto”)
ax.grid(True)
plotly_fig = mpl_to_plotly(fig)
app.layout= html.Div([
dcc.Graph(id= ‘matplotlib-graph’, figure=plotly_fig)
])
app.run_server(host=‘10.8.59.7’, port=3067, mode=‘external’)