Make sure you have Python installed on your system (Python 3.7 or higher recommended).
Open your terminal/command prompt and install the necessary packages:
pip install dash plotly pandas numpy- Download the
animals_info.csvfile from the Kaggle dataset - Place it in the same directory as your Python script
- Ensure your CSV has these columns (the app will adapt to your actual column names):
name: Animal nameclass: Animal class (Mammalia, Aves, Reptilia, etc.)habitat: Where the animal lives (Forest, Ocean, Desert, etc.)diet: What the animal eats (Carnivore, Herbivore, Omnivore)order: Taxonomic orderpopulation: Population count (numeric)
- Copy the Python code provided
- Save it as
animal_dashboard.pyin the same directory as your CSV file
- Open terminal/command prompt
- Navigate to the directory containing your files:
cd path/to/your/directory - Run the application:
python animal_dashboard.py
- After running the script, you'll see output like:
Dash is running on http://127.0.0.1:8050/ - Open your web browser and go to:
http://127.0.0.1:8050/ - You should see your interactive dashboard!
- Animals by Class: Bar chart showing count of animals in each taxonomic class
- Animals by Habitat: Bar chart showing distribution across different habitats
- Animals by Diet: Bar chart showing dietary preferences distribution
- Population by Order: Interactive chart that can switch between:
- Pie chart showing population percentages by taxonomic order
- Line chart showing population trends by order
- Dark/Light Mode Toggle: Click the moon/sun button in the top-right corner to switch themes
- Toggle between pie chart and line chart for population data
- Hover over charts to see detailed information
- Responsive design that works on different screen sizes
- Smooth transitions between theme changes
- The app includes sample data and will run even without the CSV file
- Make sure
animals_info.csvis in the same directory as the Python script - Check that the filename matches exactly (case-sensitive)
- Make sure all packages are installed:
pip install dash plotly pandas numpy - Try upgrading pip:
pip install --upgrade pip
- Check that no other application is using port 8050
- You can specify a different port by modifying the last line:
app.run_server(debug=True, port=8051)
If your CSV has different column names, modify the column references in the code:
- Replace
'class'with your class column name - Replace
'habitat'with your habitat column name - Replace
'diet'with your diet column name - Replace
'order'with your order column name - Replace
'population'with your population column name
- Modify
color_continuous_scaleparameters in the bar charts - Options include: 'Viridis', 'Plasma', 'Inferno', 'Magma', 'Cividis'
- Change the
height=400parameter in theupdate_layout()calls
You can modify the theme colors by changing the LIGHT_THEME and DARK_THEME dictionaries:
LIGHT_THEME = {
'backgroundColor': '#FFFFFF', # Main background
'color': '#000000', # Text color
'cardBackground': '#F8F9FA', # Chart backgrounds
'borderColor': '#E9ECEF' # Border colors
}
DARK_THEME = {
'backgroundColor': '#1E1E1E', # Main background
'color': '#FFFFFF', # Text color
'cardBackground': '#2D2D2D', # Chart backgrounds
'borderColor': '#404040' # Border colors
}- The population chart already demonstrates how to switch between chart types
- You can extend this pattern to other visualizations
your_project_folder/
├── animals_info.csv # Your data file
├── animal_dashboard.py # The dashboard code
└── README.md # Optional: documentation
Once you have the basic dashboard running, you can:
- Add more chart types and visualizations
- Include filtering capabilities
- Add data summary statistics
- Export charts as images
- Deploy to a web server for sharing
The dashboard is designed to be simple yet comprehensive, similar to Streamlit but with the power and flexibility of Dash/Plotly!