Grid lines inside bar chart

Hi,
I want to plot the bar charts on the web page. I am able to plot charts but the grids are not displaying in all the charts, it is displaying only in alternate charts as shown in the picture.

Below is the method that generates the charts.

def generate(safety_met,values):
            plt.bar(safety_met, values, color ='maroon',
                width = 0.4)
        
            plt.xlabel("Safety Factor")
            plt.ylabel("Values")
            plt.title("Safety Factor")
            plt.grid()
            #plt.show()
            st.pyplot(fig)
            
        expanders = []

        if 'expanders' not in st.session_state:
            st.session_state.expanders = expanders
        else:
            expanders = st.session_state.expanders

        num_expanders = 1
        

        
        for _ in range(num_expanders):
                expanders.append(True)

        for i, expander in enumerate(expanders):
            with st.expander(f'Expander {i+1}',expanded=True):
                st.write(generate(safety_met,values))
        print("exppp",expanders)
    else:
        st.warning("Limit exhausted")

See the docs for pyplot.grid() (bold mine):

Whether to show the grid lines. If any kwargs are supplied, it is assumed you want the grid on and visible will be set to True.

If visible is None and there are no kwargs, this toggles the visibility of the lines.

1 Like

Thank you @Goyo .,It resolved my issue.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.