|
import plotly.graph_objects as go |
|
|
|
def Intelligibility_Plot(Int_Score, fair_thre=30, good_thre = 70, Upper=100, Lower=0): |
|
''' |
|
Int_Score: a float number between 0 and 100 |
|
Upper: the upper bound of the plot |
|
Lower: the lower bound of the plot |
|
''' |
|
|
|
assert isinstance(Int_Score, float|int) |
|
assert Int_Score >= Lower |
|
assert Int_Score <= Upper |
|
|
|
|
|
|
|
color = "#75DA99" |
|
if Int_Score <= fair_thre: |
|
color = "#F2ADA0" |
|
elif Int_Score <= good_thre: |
|
color = "#e8ee89" |
|
else: |
|
color = "#75DA99" |
|
|
|
fig = go.Figure(go.Indicator( |
|
mode="number+gauge", |
|
gauge={'shape': "bullet", |
|
'axis':{'range': [Lower, Upper+10]}, |
|
'bgcolor': 'white', |
|
'bar': {'color': color}, |
|
}, |
|
value=Int_Score, |
|
domain = {'x': [0, 1], 'y': [0, 1]}, |
|
) |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fig.update_layout( |
|
autosize=False, |
|
width=650, |
|
height=250, |
|
margin=dict( |
|
l=10, |
|
r=10, |
|
b=10, |
|
t=10, |
|
pad=4 |
|
),) |
|
return fig |
|
|
|
def Naturalness_Plot(Nat_Score, fair_thre=2, good_thre = 4, Upper=5, Lower=0): |
|
''' |
|
Nat_Score: a float number between 0 and 100 |
|
Upper: the upper bound of the plot |
|
Lower: the lower bound of the plot |
|
''' |
|
|
|
assert isinstance(Nat_Score, float) |
|
assert Nat_Score >= Lower |
|
assert Nat_Score <= Upper |
|
|
|
color = "#75DA99" |
|
if Nat_Score <= fair_thre: |
|
color = "#F2ADA0" |
|
elif Nat_Score <= good_thre: |
|
color = "#e8ee89" |
|
else: |
|
color = "#75DA99" |
|
fig = go.Figure(go.Indicator( |
|
mode = "number+gauge", |
|
gauge = {'shape': "bullet", |
|
'axis':{'range': [Lower, Upper+0.4]}, |
|
"bar":{'color': color}}, |
|
value = Nat_Score, |
|
domain = {'x': [0, 1], 'y': [0, 1]}, |
|
) |
|
) |
|
fig.update_layout( |
|
autosize=False, |
|
width=650, |
|
height=250, |
|
margin=dict( |
|
l=10, |
|
r=10, |
|
b=10, |
|
t=10, |
|
pad=4 |
|
),) |
|
return fig |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|