pandas 流线型图像循环

vktxenjb  于 2023-03-16  发布在  其他
关注(0)|答案(1)|浏览(87)

有人能帮我把这个变成一个循环吗?或者它可以是一个循环?我只是想检查它是否可以是循环。

c1,c2,c3,c4,c5,c6,c7 = st.beta_columns(7)

with c1:
    fig1 = plt.figure(figsize=(14,8))
    fig1.suptitle("Gray Eqhist")
    plt.imshow(gray_eqhist, 'gray')        
    st.pyplot(fig1)
with c2:
    fig2 = plt.figure(figsize=(14,8))
    fig2.suptitle("Applied Clahe")
    plt.imshow(applied_clahe, 'gray')        
    st.pyplot(fig2)
with c3:
    fig3 = plt.figure(figsize=(14,8))
    fig3.suptitle("Binary")
    plt.imshow(thresh1, 'gray')        
    st.pyplot(fig3)
with c4:
    fig4 = plt.figure(figsize=(14,8))
    fig4.suptitle("Binary Threshold Inverted")
    plt.imshow(thresh2, 'gray')        
    st.pyplot(fig4)
with c5:
    fig5 = plt.figure(figsize=(14,8))
    fig5.suptitle("Truncated Threshold")
    plt.imshow(thresh3, 'gray')        
    st.pyplot(fig5)
with c6:
    fig6 = plt.figure(figsize=(14,8))
    fig6.suptitle("Set to 0")
    plt.imshow(thresh4, 'gray')        
    st.pyplot(fig6)
with c7:
    fig7 = plt.figure(figsize=(14,8))
    fig7.suptitle("Set to 0 Inverted")
    plt.imshow(thresh5, 'gray')        
    st.pyplot(fig7)
fwzugrvs

fwzugrvs1#

是的。试试这个。

configurations = [dict(title = "Gray Eqhist",               image = gray_eqhist),
                  dict(title = "Applied Clahe",             image = applied_clahe),
                  dict(title = "Binary",                    image = thresh1),
                  dict(title = "Binary Threshold Inverted", image = thresh2),
                  dict(title = "Truncated Threshold",       image =  thresh3),
                  dict(title = "Set to 0",                  image = thresh4),
                  dict(title = "Set 0 to Invernted",        image = thresh5)]

columns = st.beta_columns(len(configurations))

for column, configuration in zip(columns, configurations):
    fig = plt.figure(figsize=(14,8))
    fig.suptitle(configuration["title"])
    plt.imshow(configuration["image"], 'gray')
    column.pyplot(fig)

你通常可以用列名来替换st,比如c1st是对主页面的引用。c1是对子页面的引用。所以你可以在没有with块的情况下执行c1.text("Hello World")

相关问题