viewof schwelle = Inputs.range([15,25], {
  value: 20,
  step: 0.5,
  label: "Schwellenwert Tropennächte (°C)"
})
alle_jahre = d3.range(1945, 2027)

// Hitzetage pro Jahr zählen
raw = transpose(hw_data)

tropennaechte= alle_jahre.map(j => ({
  Jahr: j,
  Tropennächte: raw.filter(d => d.Jahr === j && d.tlmin >= schwelle).length
}))

Plot.plot({
  marks: [
    Plot.barY(tropennaechte, { x: "Jahr", y: "Tropennächte", fill: "firebrick" })
  ],
  x: { tickFormat: "d", label: "Jahr", ticks: [...d3.range(1950, 2026, 10), 2026] },
  y: { label: "Tropennächte" },
  width: 700
})