@hyojoo.cho
Here is an example of setting a layout image for each subplot. You can use an image
from an online source or a local image. My example uses local images.
For online source see Plotly example: https://plotly.com/python/images/
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import base64
image1_filename = 'img_lights.png'
polar_light = base64.b64encode(open(image1_filename, 'rb').read())
image2_filename = 'img_snowtops.png'
snow = base64.b64encode(open(image2_filename, 'rb').read())
fig = make_subplots(
rows=2, cols=1, subplot_titles=("Title 1", "Title 2"),
vertical_spacing=0.075
)
fig.add_trace(go.Scatter(x= [1, 1.75, 2.5, 3.5], y=[-1, 3, 0, 3, 5],
mode='markers',
marker_size=20,
marker_color="#ffd700"),
row=1, col=1)
fig.add_trace(go.Scatter(x= [1, 1.75, 2.5, 3.5], y=[4, 2, 6, 3, 5], mode='markers',
marker_symbol='triangle-down',
marker_size=20, marker_color='red'),
row=2, col=1)
fig.update_layout(width=850, height=700,
images= [dict(
source='data:image/png;base64,{}'.format(polar_light.decode()),
xref="paper", yref="paper",
x=0, y=1, #position of the upper left corner of the image in subplot 1,1
sizex=1, sizey=0.46, #sizex, sizey are set by trial and error
xanchor="left",
yanchor="top",
sizing="stretch",
layer="below"),
dict(
source='data:image/png;base64,{}'.format(snow.decode()),
xref="paper", yref="paper",
x=0, y=0.46, #position of the upper left corner of the image in subplot 2,1
sizex=1, sizey=0.46,
xanchor="left",
yanchor="top",
sizing="stretch",
layer="below") ])
fig.update_xaxes(showgrid=False, zeroline=False)
fig.update_yaxes(showgrid=False, zeroline=False)