Bar Gradient

Edit pageLast modified: 05 August 2024
val cities by columnOf("London", "Paris", "Berlin", "Madrid", "Rome", "Amsterdam", "Prague")
val airPollution by columnOf(70, 65, 50, 60, 55, 45, 53)
val numberOfCars by columnOf(3000, 2800, 1800, 2500, 2100, 1300, 2000)

val dataset = dataFrameOf(cities, airPollution, numberOfCars)

dataset.plot {
    layout.title = "Air Pollution and Vehicle Count Analysis"
    bars {
        x(cities) { axis.name = "City" }
        y(numberOfCars) { axis.name = "Number of cars (thousands)" }
        fillColor(airPollution) {
            legend.name = "Air Pollution\n Level (AQI)"
            scale = continuous(Color.GREEN..Color.RED)
        }
        alpha = 0.8
    }
}
Bar Gradient