Is it possible to create an interactive histogram with multi filters?

Hello my friends !

i want to create an interactive histogram (like in excel where i can choose filters )
the user will control the filters he want to plot on the histogram
is it possible ?
Note : (BU,Métier ,…) are the name of columns
Like this from excel ==>

Hey @firas , welcome to the forum.

You can create interactive histogram with dash. I created an example below.

I used an earthquake catalogue. Columns are “depth”, “magnitude” and “date”.

import pandas as pd
import numpy as np
import dash
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go

# Read Data
data = pd.read_csv('dat.txt', sep='\t', names=['depth','magnitude', 'date'])

fig = go.Figure()

app = dash.Dash(__name__)
server = app.server

app.layout = html.Div([


                            options=[{"label": "Magnitude", "value": 0},
                                     {"label": "Depth", "value": 1,},
                                     {"label":  "Date", "value": 2},




    Output('bar_graph', 'figure'),
    Input('radio_input', 'value'),

def update_bar(radio_input):

    #Magnitude vs Number
    if radio_input == 0: 

        a = data.groupby(['magnitude']).size()
        b = a.to_frame(name='occur').reset_index()

        fig = go.Figure(go.Bar(x=b['magnitude'],
                               marker_color = 'green'


    #Depth vs Number
    elif radio_input == 1: 
        a = data.groupby(['depth']).size()
        b = a.to_frame(name='occur').reset_index()

        fig = go.Figure(go.Bar(x=b['depth'],
                               marker_color = 'blue'

    #Date vs Number        
    elif radio_input == 2:

        a = data.groupby(['date']).size()
        b = a.to_frame(name='occur').reset_index()

        fig = go.Figure(go.Bar(x=b['date'],
                               marker_color = 'red'

    return fig

if __name__ == "__main__":


Have a nice day.

1 Like

Thank you for response !
i have 4 columns and the values are categorical !
i want to choose some filter from each column and change it !
Example : column 1 : sexe : Male or female ( you can choose both)
column 2 : familial statut : divorced married …
column 3 : Bussiness unit : there are 12 categories
and i want to create interactive histogram where the user see the result if he choose female married who works on specific bussiness unit

NOTE : it is like dynamic cross histogram in excel