Skip to main content

Bubble Plot

A bubble plot positions points by two quantitative values and uses the size of each circle to encode a third. It is a scatter plot with an added magnitude dimension.

  • Good for: comparing three numeric measures at once, spotting outliers, correlation with a magnitude (for example, revenue vs. profit sized by order count).
  • Not great for: part-to-whole composition (use a sunburst or treemap), category magnitudes without x/y coordinates (use a packed bubble chart), or time series.

Syntax

Use the following AML definition to add the Bubble Chart to your custom chart library.

Legacy syntax
CustomChart {
fields {
field x_axis {
type: "dimension"
label: "X axis"
}

field y_axis {
type: "dimension"
label: "Y axis"
}

field size {
type: "dimension"
label: "Size"
}

}

template: @vgl {
"data": {
"values": @{values}
},
"mark": {
"type": "circle",
"opacity": 0.8,
"stroke": "black",
"strokeWidth": 1
},
"encoding": {
"x": {
"field": @{fields.x_axis.name},
"type": "temporal",
"axis": {"grid": false}
},
"y": {
"field": @{fields.y_axis.name},
"type": "nominal",
"axis": {"title": ""}
},
"size": {
"field": @{fields.size.name},
"type": "quantitative",
"title": "Annual Global Deaths",
"legend": {"clipHeight": 30},
"scale": {"rangeMax": 5000}
},
"color": {"field": @{fields.y_axis.name}, "type": "nominal", "legend": null}
}
};;
}

Required fields

A Bubble Chart expects four fields. Each row of input is one bubble, identified by its category.

FieldLabelTypeRole
x_axisX-axisdimensionHorizontal position; read as a quantitative value. Sorted ascending (apply_order: 1).
y_axisY-axisdimensionVertical position; read as a quantitative value. Sorted ascending (apply_order: 2).
sizeSizedimensionBubble area; larger values render as larger circles. Sorted ascending (apply_order: 3).
categoryCategorydimensionNames each bubble, colors bubbles by category, and is the field a click cross-filters on.

Data requirements: Pre-aggregate to one row per bubble; the template does not aggregate, so each input row draws its own circle. Use numeric values for x, y, and size (all plotted as quantitative); category is a nominal label.

Sample data:

categoryx_axisy_axissize
Chairs120003200540
Tables85002100320
Phones210006400910
Binders4300900150
Accessories156004800720

Known limitations

  • X, Y, and size must be numeric. The template encodes X, Y, and size as quantitative, so non-numeric values for those fields will not plot correctly.

  • Rows are not aggregated. Duplicate x/y points each draw a separate overlapping circle, so pre-aggregate before charting.


Open Markdown
Let us know what you think about this document :)