TidyTuesday (2026) Week 5: Edible Plants

This week we’re exploring edible plants! The Edible Plant Database (EPD) is an outcome of the GROW Observatory, a European Citizen Science project on growing food, soil moisture sensing and land monitoring. It contains information on 146 edible plant species, including their ideal growing conditions and time to harvest and germination.

TidyTuesday
Data Visualization
Python Programming
2026
Author

Peter Gray

Published

February 2, 2026

Chart Tree Plot of African Lnaguages

1. Python code

Show code
import pandas as pd
import numpy as np
import plotly.express as px

# Load data
edible_plants = pd.read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-02-03/edible_plants.csv')
df_clean = edible_plants[['cultivation', 'sunlight', 'water']].copy()

df_clean = df_clean[df_clean['cultivation'] != "Miscellaneous"]
df_clean['sunlight'] = df_clean['sunlight'].str.strip().str.title()
df_clean['water'] = df_clean['water'].str.title()


df_counts = df_clean.value_counts().reset_index(name='count')


df_counts['cultivation_labeled'] = '<b>Cultivation:</b> ' + df_counts['cultivation'] + '<br>(n=' + df_counts['count'].astype(str) + ')'
df_counts['sunlight_labeled'] = '<b>Sunlight:</b> ' + df_counts['sunlight'] + '<br>(n=' + df_counts['count'].astype(str) + ')'
df_counts['water_labeled'] = '<b>Water:</b> ' + df_counts['water'] + '<br>(n=' + df_counts['count'].astype(str) + ')'


fig = px.sunburst(
    df_counts,
    path=['cultivation', 'sunlight', 'water'], 
    values='count',
    title="Edible Plants: Requirements by Level",
    color='cultivation',
    color_discrete_sequence=px.colors.qualitative.Safe
)


fig.update_layout(
    annotations=[
        dict(text="<b>Level 1:</b> Cultivation", x=0.8, y=1.1, showarrow=False, font_size=14),
        dict(text="<b>Level 2:</b> Sunlight", x=0.8, y=1.05, showarrow=False, font_size=14),
        dict(text="<b>Level 3:</b> Water", x=0.8, y=1.0, showarrow=False, font_size=14)
    ],
    margin=dict(t=100) 
)


fig.update_traces(
    hovertemplate='<b>%{label}</b><br>Count: %{value}<br>Parent: %{parent}'
)

fig.show()
Back to top