hussain786110 commited on
Commit
cc41388
·
verified ·
1 Parent(s): 4e680ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -55,5 +55,43 @@ def main():
55
  # Run the app
56
  if __name__ == "__main__":
57
  main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
 
 
55
  # Run the app
56
  if __name__ == "__main__":
57
  main()
58
+ import dash
59
+ from dash import dcc, html
60
+ import plotly.express as px
61
+ import pandas as pd
62
+
63
+ # Load data
64
+ df = pd.read_csv('your_data.csv')
65
+
66
+ # Create Dash app
67
+ app = dash.Dash(__name__)
68
+
69
+ # Generate a plotly chart
70
+ fig = px.scatter(df, x='column_x', y='column_y', color='category_column', title="Interactive Scatter Plot")
71
+
72
+ # Define the layout with a dropdown for filtering
73
+ app.layout = html.Div([
74
+ html.H1("Interactive Data Visualization"),
75
+ dcc.Dropdown(
76
+ id='category-dropdown',
77
+ options=[{'label': i, 'value': i} for i in df['category_column'].unique()],
78
+ value=df['category_column'].unique()[0] # Default value
79
+ ),
80
+ dcc.Graph(id='scatter-plot', figure=fig)
81
+ ])
82
+
83
+ # Callback to update figure based on dropdown selection
84
+ @app.callback(
85
+ dash.dependencies.Output('scatter-plot', 'figure'),
86
+ [dash.dependencies.Input('category-dropdown', 'value')]
87
+ )
88
+ def update_graph(selected_category):
89
+ filtered_df = df[df['category_column'] == selected_category]
90
+ return px.scatter(filtered_df, x='column_x', y='column_y', color='category_column', title="Filtered Scatter Plot")
91
+
92
+ # Run the app
93
+ if __name__ == '__main__':
94
+ app.run_server(debug=True)
95
+
96
 
97