File size: 1,175 Bytes
cfcb110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from turtle import width
import streamlit as st
from pathlib import Path
from PIL import Image

from variables import MAPPING_LANG_CODE_TO_TEXT, PLOT_SIZES_PER_LANG

# Only need to set these here as we are add controls outside of Hydralit, to customise a run Hydralit!
st.set_page_config(page_title="Documents sizes", layout="wide")

plot_dir = Path("data/boxplot_per_ds_per_lang")
plot_paths = list(plot_dir.iterdir())

plot_paths = sorted(plot_paths)

with st.sidebar:
    st.write("Go to plot")
    for plot_path in plot_paths:
        plot_name = str(plot_path.name)
        if plot_name == "colorbar.png":
            continue
        lang_id = plot_name.split("_")[1][:-len(".png")]
        title = MAPPING_LANG_CODE_TO_TEXT[lang_id]
        st.markdown(f"[{title}](#{title.replace(' ', '-').lower()})", unsafe_allow_html=True)

for plot_path in plot_paths:
    plot_name = str(plot_path.name)
    if plot_name == "colorbar.png":
        continue
    lang_id = plot_name.split("_")[1][:-len(".png")]
    st.title(MAPPING_LANG_CODE_TO_TEXT[lang_id])
    image = Image.open(plot_path)
    st.image(image, width=int(round(float(PLOT_SIZES_PER_LANG[lang_id]['width'])*50)))