Hello how do I do a chart with progress arrows between the bars I have included a screenshot of the chart.
Hi
this is an example that you can adapt to your needs
import streamlit as st
import matplotlib.pyplot as plt
import numpy as np
# Datos para las barras y las flechas de progreso
categories = ['A', 'B', 'C', 'D', 'E']
values = np.random.randint(1, 10, size=len(categories))
progress = np.random.rand(len(categories))
# Calcular la tendencia de las flechas
trend = np.sign(np.diff(values))
# Crear la figura y los ejes del gráfico
fig, ax = plt.subplots()
# Graficar las barras
ax.bar(categories, values)
# Dibujar las flechas de progreso
for i, (value, prog, tr) in enumerate(zip(values[:-1], progress[:-1], trend)):
x_start = i
x_end = i + 1
y_start = value
y_end = values[i + 1]
if tr > 0:
arrow_color = 'red'
else:
arrow_color = 'green'
ax.annotate("", xy=(x_end, y_end), xytext=(x_start, y_start),
arrowprops=dict(arrowstyle="-|>", color=arrow_color, lw=2))
# Configurar el título y las etiquetas de los ejes
ax.set_title('Gráfico con Flechas de Progreso')
ax.set_xlabel('Categorías')
ax.set_ylabel('Valores')
# Mostrar el gráfico
st.pyplot(fig)
Thank you so much oscar is there a way to make the arrows smaller meaning not so long and is there a way that I can have the arrows between the bars ?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.