diff --git a/Book4_Ch01_Python_Codes/Streamlit_Bk4_Ch1_01.py b/Book4_Ch01_Python_Codes/Streamlit_Bk4_Ch1_01.py index 47e898e..1445ef9 100644 --- a/Book4_Ch01_Python_Codes/Streamlit_Bk4_Ch1_01.py +++ b/Book4_Ch01_Python_Codes/Streamlit_Bk4_Ch1_01.py @@ -21,18 +21,24 @@ with st.sidebar: y_feature = st.radio('Vertical axis', features) -# Heatmap +#%% original data + +with st.expander('Original data'): + st.write(df) + + +#%% Heatmap with st.expander('Heatmap'): fig_1 = px.imshow(df.iloc[:,0:4], color_continuous_scale='RdYlBu_r') st.plotly_chart(fig_1) -# 2D scatter plot +#%% 2D scatter plot with st.expander('2D scatter plot'): fig_2 = px.scatter(df, x=x_feature, y=y_feature, color="species") st.plotly_chart(fig_2) -# 3D scatter plot +#%% 3D scatter plot with st.expander('3D scatter plot'): fig_3 = px.scatter_3d(df, x='sepal_length', diff --git a/Book4_Ch02_Python_Codes/Streamlit_Bk4_Ch2_13.py b/Book4_Ch02_Python_Codes/Streamlit_Bk4_Ch2_13.py index 7e44f10..ecec3ad 100644 --- a/Book4_Ch02_Python_Codes/Streamlit_Bk4_Ch2_13.py +++ b/Book4_Ch02_Python_Codes/Streamlit_Bk4_Ch2_13.py @@ -41,7 +41,7 @@ b = np.round(b,1) show_number = False with st.sidebar: - show_number = st.checkbox('Show values:') + show_number = st.checkbox('Display values') tensor_a_b = a@b.T diff --git a/Book4_Ch03_Python_Codes/Streamlit_Bk4_Ch3_01.py b/Book4_Ch03_Python_Codes/Streamlit_Bk4_Ch3_01.py index 586cfa0..6084678 100644 --- a/Book4_Ch03_Python_Codes/Streamlit_Bk4_Ch3_01.py +++ b/Book4_Ch03_Python_Codes/Streamlit_Bk4_Ch3_01.py @@ -37,9 +37,8 @@ fig_1.update_layout( margin=dict( l=50, r=50, - b=100, - t=100, - pad = 4)) + b=50, + t=50)) fig_2 = go.Figure( go.Surface( diff --git a/Book4_Ch04_Python_Codes/Streamlit_Bk4_Ch4_16.py b/Book4_Ch04_Python_Codes/Streamlit_Bk4_Ch4_16.py index c2f02c6..6ed4158 100644 --- a/Book4_Ch04_Python_Codes/Streamlit_Bk4_Ch4_16.py +++ b/Book4_Ch04_Python_Codes/Streamlit_Bk4_Ch4_16.py @@ -116,11 +116,11 @@ fig.add_trace(go.Scatter(x=A_times_square_array[0,:], fig.add_trace(go.Scatter(x=Txvyv[0], y=Txvyv[1], mode="lines", line_width=lw, - line_color = 'blue'), 1, 2) + line_color = 'red'), 1, 2) fig.add_trace(go.Scatter(x=Txhyh[0], y=Txhyh[1], mode="lines", line_width=lw, - line_color = 'red'), 1, 2) + line_color = 'blue'), 1, 2) fig.update_xaxes(range=[-4, 4]) fig.update_yaxes(range=[-4, 4]) fig.update_layout(width=800, height=500, showlegend=False, template="none", diff --git a/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_02.py b/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_02.py index 8165ff1..47cdaef 100644 --- a/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_02.py +++ b/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_02.py @@ -58,7 +58,7 @@ with st.sidebar: \sin(\theta) & \cos(\theta) \end{bmatrix}''') - theta = st.slider('Degree',-180, 180, step = 5, value = 0) + theta = st.slider('Theta degree: ',-180, 180, step = 5, value = 0) theta = theta/180*np.pi diff --git a/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_03.py b/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_03.py index c0ac083..527851c 100644 --- a/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_03.py +++ b/Book4_Ch08_Python_Codes/Streamlit_Bk4_Ch8_03.py @@ -61,7 +61,7 @@ with st.sidebar: a = st.slider('a',-2.0, 2.0, step = 0.1, value = 1.0) b = st.slider('b',-2.0, 2.0, step = 0.1, value = 0.0) c = st.slider('c',-2.0, 2.0, step = 0.1, value = 0.0) - d = st.slider('c',-2.0, 2.0, step = 0.1, value = 1.0) + d = st.slider('d',-2.0, 2.0, step = 0.1, value = 1.0) theta = np.pi/6 A = np.array([[a, b], diff --git a/Book4_Ch10_Python_Codes/Streamlit_Bk4_Ch10_01.py b/Book4_Ch10_Python_Codes/Streamlit_Bk4_Ch10_01.py index a11188e..0829ded 100644 --- a/Book4_Ch10_Python_Codes/Streamlit_Bk4_Ch10_01.py +++ b/Book4_Ch10_Python_Codes/Streamlit_Bk4_Ch10_01.py @@ -67,6 +67,9 @@ st.latex(r'G = ' + bmatrix(np.round(D,2)) + '@' + bmatrix(np.round(V.T,2))) +st.write('Mapped data:') +st.latex('Z = XV') + #%% Z = X@V @@ -79,25 +82,32 @@ df['species'] = df['species'].map(mapping_rule) #%% features = df.columns.to_list()[:-1] -with st.sidebar: - st.write('2D scatter plot') - x_feature = st.radio('Horizontal axis', - features) - y_feature = st.radio('Vertical axis', - features) -# Heatmap +#%% Table of mapped data + +with st.expander('Mapped data'): + st.write(df) + +#%% Heatmap with st.expander('Heatmap'): fig_1 = px.imshow(df.iloc[:,0:4], color_continuous_scale='RdYlBu_r') st.plotly_chart(fig_1) -# 2D scatter plot +#%% 2D scatter plot + +with st.sidebar: + st.write('2D scatter plot') + x_feature = st.radio('Horizontal axis', + features) + y_feature = st.radio('Vertical axis', + features) + with st.expander('2D scatter plot'): fig_2 = px.scatter(df, x=x_feature, y=y_feature, color="species") st.plotly_chart(fig_2) -# 3D scatter plot +#%% 3D scatter plot with st.expander('3D scatter plot'): fig_3 = px.scatter_3d(df, x='PC1', @@ -106,7 +116,7 @@ with st.expander('3D scatter plot'): color='species') st.plotly_chart(fig_3) -# Pairwise scatter plot +#%% Pairwise scatter plot with st.expander('Pairwise scatter plot'): fig_4 = px.scatter_matrix(df, dimensions=["PC1", diff --git a/Book4_Ch13_Python_Codes/Streamlit_Bk4_Ch13_04.py b/Book4_Ch13_Python_Codes/Streamlit_Bk4_Ch13_04.py index a4f01b6..e0e84a3 100644 --- a/Book4_Ch13_Python_Codes/Streamlit_Bk4_Ch13_04.py +++ b/Book4_Ch13_Python_Codes/Streamlit_Bk4_Ch13_04.py @@ -64,7 +64,7 @@ df = pd.DataFrame(X, columns=['z1','z2', 'color']) #%% Scatter -st.latex(bmatrix(A)) +st.latex('A = ' + bmatrix(A)) fig = px.scatter(df, x="z1", diff --git a/Book4_Ch20_Python_Codes/Streamlit_Bk4_Ch20_04.py b/Book4_Ch20_Python_Codes/Streamlit_Bk4_Ch20_04.py index 802d198..325db63 100644 --- a/Book4_Ch20_Python_Codes/Streamlit_Bk4_Ch20_04.py +++ b/Book4_Ch20_Python_Codes/Streamlit_Bk4_Ch20_04.py @@ -102,7 +102,8 @@ st.latex(bmatrix(Sigma) + '=' + fig_surface = go.Figure(go.Surface( x = x1, y = x2, - z = PDF_zz)) + z = PDF_zz, + colorscale= 'RdYlBu_r')) fig_surface.update_layout( autosize=False, width=500, @@ -115,7 +116,8 @@ fig_contour = go.Figure( go.Contour( z=PDF_zz, x=x1, - y=x2 + y=x2, + colorscale= 'RdYlBu_r' )) fig_contour.update_layout( diff --git a/Book4_Ch21_Python_Codes/Streamlit_Bk4_Ch21_02.py b/Book4_Ch21_Python_Codes/Streamlit_Bk4_Ch21_02.py index 188b257..a78ffd5 100644 --- a/Book4_Ch21_Python_Codes/Streamlit_Bk4_Ch21_02.py +++ b/Book4_Ch21_Python_Codes/Streamlit_Bk4_Ch21_02.py @@ -82,7 +82,9 @@ ff_x = f_x_fcn(xx1,xx2) fig_surface = go.Figure(go.Surface( x = x1_, y = x2_, - z = ff_x)) + z = ff_x, + colorscale= 'RdYlBu_r')) + fig_surface.update_layout( autosize=False, width=500, @@ -95,7 +97,8 @@ fig_contour = go.Figure( go.Contour( z=ff_x, x=x1_, - y=x2_ + y=x2_, + colorscale= 'RdYlBu_r' )) fig_contour.update_layout(