Public
Edited
Apr 11
Insert cell
Insert cell
repos = await FileAttachment("repositorios_con_clusters.csv").csv({typed: true})
Insert cell
Plot.plot({
title: "Distribución de Repositorios por Cluster de Actividad",
marks: [
Plot.barY(
repos,
Plot.groupX(
{y: "count"},
{x: "activity_cluster", thresholds: 3}
)
),
Plot.text(
repos,
Plot.groupX(
{y: "count", text: "count"},
{x: "activity_cluster", thresholds: 3, textAnchor: "middle", dy: -10, fill: "white"}
)
)
],
x: {label: "Cluster de Actividad"},
y: {label: "Número de Repositorios"}
})
Insert cell
// Transformación de datos
reposConLabels = repos.map(d => ({
...d,
cluster_label: ["Baja", "Media", "Alta"][d.activity_cluster]
}))
Insert cell
// Visualización
Plot.plot({
title: "Distribución por Nivel de Actividad",
marks: [
Plot.barY(
reposConLabels,
Plot.groupX(
{y: "count"},
{x: "cluster_label"}
)
),
Plot.text(
reposConLabels,
Plot.groupX(
{y: "count", text: "count"},
{x: "cluster_label", textAnchor: "middle", dy: -10, fill: "white"}
)
)
],
x: {label: "Nivel de Actividad"},
y: {label: "Cantidad de Repositorios"}
})
Insert cell
// Histograma
Plot.plot({
marks: [
Plot.rectY(
repos,
Plot.binX(
{y: "count"},
{x: "activity_cluster", thresholds: 3}
)
)
]
})
Insert cell
// Relación entre stars y forks
Plot.plot({
title: "Relación entre Popularidad (Estrellas) y Adopción (Forks)",
grid: true,
x: {type: "log", label: "Estrellas (log scale)"},
y: {type: "log", label: "Forks (log scale)"},
color: {legend: true},
marks: [
Plot.dot(repos, {
x: "stargazers_count",
y: "forks_count",
fill: "activity_cluster",
tip: ["name", "owner", "stargazers_count", "forks_count"]
})
]
})
Insert cell
// Relación entre clusters y lenguajes de programación
Plot.plot({
marks: [
Plot.barY(
repos,
Plot.groupX(
{ y: "count" },
{
x: "language",
fill: d => `Cluster ${d.activity_cluster}`,
title: d => `${d.language} (Cluster ${d.activity_cluster})`
}
)
)
],
x: {
label: "",
tickRotate: -90,
fontSize: 10
},
color: {
legend: true,
domain: ["Cluster 0", "Cluster 1", "Cluster 2"],
range: ["#4e79a7", "#f28e2b", "#e15759"]
},
width: 1500,
marginLeft: 70,
marginBottom: 100
})
Insert cell
// Distribución de issues abiertos por cluster
Plot.plot({
marks: [
Plot.boxY(repos, {
x: "activity_cluster",
y: "open_issues_count",
fill: "activity_cluster"
})
],
y: {label: "Cantidad de issues abiertos"},
x: {label: "Cluster de actividad"},
color: {legend: true}
})

Insert cell
//Compara la cantidad de repositorios según owner_type dentro de cada cluster.
Plot.plot({
marks: [
Plot.barY(repos, Plot.stackY({x: "activity_cluster", y: 1, fill: "owner_type"}))
],
y: {label: "Cantidad de repositorios"},
x: {label: "Cluster de actividad"},
color: {legend: true}
})

Insert cell
//Relaciona watchers_count con forks_count según cluster.
Plot.plot({
marks: [
Plot.dot(repos, {
x: "watchers_count",
y: "forks_count",
fill: "activity_cluster",
r: 3,
opacity: 0.7
})
],
x: {label: "Watchers"},
y: {label: "Forks"},
color: {legend: true}
})

Insert cell
//Agrupa los repositorios según el tiempo desde la última actualización.
Plot.plot({
marks: [
Plot.rectY(
d3.bin()
.value(d => d.days_since_last_push)
.thresholds([0, 7, 30, 90, 180, 365])
(repos),
{x: d => d.x0, y: d => d.length, fill: "steelblue"}
)
],
x: {label: "Días desde la última actualización"},
y: {label: "Cantidad de repositorios"}
})
Insert cell
//Distribución de estrellas por cluster
Plot.plot({
marks: [
Plot.boxY(repos, {x: "activity_cluster", y: "stargazers_count", fill: "activity_cluster"})
],
y: {label: "Cantidad de estrellas (log)", type: "log"},
x: {label: "Cluster de Actividad"},
color: {legend: true, scheme: "category10"},
width: 800,
height: 500
})

Insert cell
//Relación entre Issues abiertos y Popularidad
Plot.plot({
marks: [
Plot.dot(repos, {x: "stargazers_count", y: "open_issues_count", fill: "activity_cluster", r: 3})
],
x: {label: "Cantidad de estrellas (log)", type: "log"},
y: {label: "Cantidad de issues abiertos (log)", type: "log"},
color: {legend: true, scheme: "category10"},
width: 800,
height: 500
})

Insert cell
//Evolución del tiempo desde la última actualización por cluster
Plot.plot({
marks: [
Plot.rectY(repos, Plot.binX({y: "count"}, {x: "days_since_last_push", fill: "activity_cluster", thresholds: 30})),
Plot.ruleY([0]) // Línea base en Y = 0
],
x: {label: "Días desde la última actualización"},
y: {label: "Cantidad de repositorios"},
color: {
domain: [0, 1, 2],
range: ["#1f77b4", "#ff7f0e", "#2ca02c"], // Azul, Naranja, Verde
legend: true,
label: "Clusters de Actividad"
},
width: 800,
height: 500
})

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more