How to change the labels of an area chart on Streamlit?

Viewed 2159

I have deployed an area chart using Streamlit for Python. Is it possible to change the labels for the axis X, as well as the labels for each data point plotted?

import streamlit as st
import pandas as pd
st.write(""" My area chart """)
df = pd.read_csv("my_data.csv")
st.area_chart(df)
1 Answers

Let`s look on this example:

import numpy as np
chart_data = pd.DataFrame([[1, 2, 1], [0, 2, 1], [1, 3, 5]],
                          columns=['a', 'b', 'c'],
                          index=[1, 2, 3])
st.area_chart(chart_data)

enter image description here

For changing the x axis labels you can just change the index (it can be int/float or datetime for example). For changing the groups names you can change the columns names in your dataframe.

Related