This is similar to your second graph. You just need to decide the value for your horizontal lines.
import streamlit as st
import pandas as pd
import numpy as np
import plotly.graph_objects as go
d = {‘col1’: [100.02,100.06,100.01,99.99,100.02,100.01,100,99.99,100.03,100,99.99,100.01,100.02,100.04,99.98,100,100.02,100.03,100.02,100.01], ‘col2’:np.arange(1,21)}
df = pd.DataFrame(data=d)
#calculate your metrics and insert them as vars
ucl=100.065
lcl=99.98
mean_df=100.0125
ucl_array=np.ones(20)*ucl
lcl_array=np.ones(20)*lcl
mean_array=np.ones(20)*mean_df
fig=go.Figure()
fig = fig.add_trace(go.Scatter(x=df.col2,y=df.col1,mode=‘lines’,name=‘line1’))
fig = fig.add_trace(go.Scatter(x=df.col2,y=ucl_array,mode=‘lines’,name=‘ucl =’+str(ucl)))
fig = fig.add_trace(go.Scatter(x=df.col2,y=mean_array,mode=‘lines’,name=‘mean =’+str(mean_df)))
fig = fig.add_trace(go.Scatter(x=df.col2,y=lcl_array,mode=‘lines’,name=‘lcl =’+str(lcl)))
fig=fig.update_layout(showlegend=True)
st.plotly_chart(fig)