
You will need this additional code:
# Means and STD
distributions = [
{"mean":62.88, "std":18.2, "color":"#1f77b4","label":"Media 62.88"},
{"mean":68.39, "std":16.63, "color":"#ff7f0e","label":"Media 68.39"},
{"mean":71.56, "std":13.48, "color":"#2ca02c","label":"Media 71.56"},
{"mean":56.52, "std":14.24, "color":"#d67228","label":"Media 56.52"},
{"mean":72.75, "std":12.4, "color":"#9467bd","label":"Media 72.88"}
]
#Define x range
x= np.linspace(30, 100.500)
plt.figure(figsize=(10,6))
# Define normal distribution formula
def normal_pfd(x, mean, std):
return(1/(std*np.sqrt(2*np.pi)))*np.exp(-0.5*((x-mean)/std)**2)
You need this code for your Sankey Chart:
import pandas as pd
import plotly.graph_objects as go
df = pd.read_csv("DepartamentOfNotificationLeukaemias.csv")
df.columns = df.columns.str.strip().str.upper()
df['NUMBER OF PEOPLE'] = pd.to_numeric(df['NUMBER OF PEOPLE'], errors='coerce').fillna(0)
origins = df['HOUSEHOLD'].unique()
targets = df['NOTIFICATION FACILITY'].unique()
nodes = list(origins) + [t for t in targets if t not in origins]
node_dict = {node: idx for idx, node in enumerate(nodes)}
df['Source'] = df['HOUSEHOLD'].map(node_dict)
df['Target'] = df['NOTIFICATION FACILITY'].map(node_dict)
incoming = df.groupby('Target')['NUMBER OF PEOPLE'].sum()
outgoing = df.groupby('Source')['NUMBER OF PEOPLE'].sum()
node_colors = []
for node in nodes:
idx = node_dict[node]
in_flow = incoming.get(idx, 0)
out_flow = outgoing.get(idx, 0)
if in_flow > out_flow:
node_colors.append("rgba(214, 39, 40, 0.8)")
else:
node_colors.append("rgba(44, 160, 101, 0.8)")
x_positions = [0.01 if node in origins else 0.99 for node in nodes]
fig = go.Figure(data=[go.Sankey(
arrangement="snap",
node=dict(
pad=20,
thickness=20,
line=dict(color="black", width=0.5),
label=nodes,
color=node_colors,
x=x_positions
),
link=dict(
source=df['Source'],
target=df['Target'],
value=df['NUMBER OF PEOPLE'],
color="rgba(160,160,160,0.3)"
)
)])
fig.update_layout(
title_text="Notificación de casos de leucemia por departamento de origen y atención",
font=dict(size=12),
height=800,
margin=dict(l=30, r=30, t=60, b=30)
)
fig.show()
Data Visualization for Healthcare Professionals
Clear, impactful, and reproducible visualizations for health and life sciences.
In this course you’ll learn to create meaningful graphs tailored to healthcare, biological sciences, and related fields. We begin by setting up your environment step by step with Python, Jupyter Notebooks, and Visual Studio Code. You’ll work with two core libraries: Pandas for data preparation and Plotly for interactive, publication-quality visuals. We’ll also introduce GeoDa to build cartograms and other spatial analyses, giving you multiple approaches to explore geographic health data.
A basic familiarity with Python, R, Stata, or similar tools used in health data analysis is recommended so you can focus on visualization concepts while following the code.
Through hands-on exercises using real-world, anonymized datasets, you will:
Visualize cancer statistics, multimorbidity patterns, and epidemiologic trends.
Analyze COVID-19 data and health insurance population metrics.
Create clear, reproducible figures for articles, reports, and presentations.
Build geographic visualizations that reveal spatial relationships in health data.
We’ll emphasize reproducibility throughout: sharing the code behind your figures helps validate methods, fosters collaboration, and aligns with expectations of scientific publications.
By the end of the course, you’ll confidently prepare datasets, select effective visualization techniques, and turn complex health data into clear, actionable insights—ready for journals, stakeholders, or decision-makers.