fruitpicker01's picture
Update app.py
17c86fb verified
raw
history blame
1.16 kB
import gradio as gr
import plotly.graph_objects as go
# Function to create a speedometer gauge
def success_rate_gauge(success_value):
fig = go.Figure(go.Indicator(
mode="gauge+number",
value=success_value,
gauge={'axis': {'range': [0, 100]},
'bar': {'color': "green"},
'steps': [
{'range': [0, 50], 'color': "red"},
{'range': [50, 75], 'color': "yellow"},
{'range': [75, 100], 'color': "green"}],
'threshold': {'line': {'color': "black", 'width': 4}, 'thickness': 0.75, 'value': 76}}
))
fig.update_layout(height=400, width=500)
return fig
# Gradio interface
with gr.Blocks() as demo:
gr.Markdown("## Улучшенный спидометр с вероятностью успеха")
# Add a plot output widget
plot = gr.Plot(label="Success Rate Gauge")
# Function to update the plot
def update_plot():
return success_rate_gauge(76)
# Button to trigger the update
with gr.Row():
plot.render(update_plot())
# Launch Gradio interface
demo.launch()