Skip to content

Scattergl

Overview

The scattergl trace type is used to create scatter plots with WebGL rendering, making it ideal for handling large datasets and providing high-performance rendering of millions of data points. It supports the same features as scatter, including markers and lines, but with optimized rendering for better performance.

You can customize the marker size, color, and add lines to connect points, similar to the scatter trace type, but with WebGL's performance advantages.

Common Uses

  • Large Datasets: Efficiently visualizing datasets with thousands or millions of points.
  • Performance Optimization: Use when scatter plots with standard rendering struggle with performance.
  • Real-Time Data: Useful for real-time visualizations with large or dynamic datasets.

Check out the Attributes for the full set of configuration options

Examples

Common Configurations

Here's a simple scattergl plot showing data points using WebGL rendering:

You can copy this code below to create this chart in your project:

models:
  - name: scattergl-data
    args:
      - echo
      - |
        x,y
        1,10
        2,20
        3,15
        4,25
        5,30
traces:
  - name: Simple Scattergl Plot
    model: ${ref(scattergl-data)}
    props:
      type: scattergl
      x: ?{x}
      y: ?{y}
      mode: "markers"
charts:
  - name: Simple Scattergl Chart
    traces:
      - ${ref(Simple Scattergl Plot)}
    layout:
      title:
        text: Simple Scattergl Plot<br><sub>High-Performance Scatter Plot with WebGL</sub>

This example demonstrates a scattergl plot with lines connecting the data points using WebGL rendering:

Here's the code:

models:
  - name: scattergl-data-lines
    args:
      - echo
      - |
        x,y
        1,5
        2,10
        3,8
        4,15
        5,12
traces:
  - name: Scattergl Plot with Lines
    model: ${ref(scattergl-data-lines)}
    props:
      type: scattergl
      x: ?{x}
      y: ?{y}
      mode: "lines+markers"
charts:
  - name: Scattergl Chart with Lines
    traces:
      - ${ref(Scattergl Plot with Lines)}
    layout:
      title:
        text: Scattergl Plot with Lines<br><sub>Connecting Data Points with WebGL</sub>

Here's a scattergl plot with custom marker sizes and colors, giving more visual weight to each data point, all rendered with WebGL:

Here's the code:

models:
  - name: scattergl-data-custom
    args:
      - echo
      - |
        x,y,size,color
        1,5,10,#1f77b4
        2,10,15,#ff7f0e
        3,8,20,#2ca02c
        4,15,25,#d62728
        5,12,30,#9467bd
traces:
  - name: Scattergl Plot with Custom Markers
    model: ${ref(scattergl-data-custom)}
    props:
      type: scattergl
      x: ?{x}
      y: ?{y}
      mode: "markers"
      marker:
        size: ?{size}
        color: ?{color}
charts:
  - name: Scattergl Chart with Custom Markers
    traces:
      - ${ref(Scattergl Plot with Custom Markers)}
    layout:
      title:
        text: Scattergl Plot with Custom Markers<br><sub>Custom Sizes and Colors for WebGL Data Points</sub>

A schema to validate plotly trace properties

Attributes

These attributes apply to traces where trace.props.type is set to scattergl. You would configure these attributes on the trace with the trace.props object.

connectgaps: boolean
customdata: array
customdatasrc: 'string' #(1)!
dx: number
dy: number
error_x:
  array: array
  arrayminus: array
  arrayminussrc: 'string' #(2)!
  arraysrc: 'string' #(3)!
  color: any
  copy_ystyle: boolean
  symmetric: boolean
  thickness: number
  traceref: integer
  tracerefminus: integer
  type: any
  value: number
  valueminus: number
  visible: boolean
  width: number
error_y:
  array: array
  arrayminus: array
  arrayminussrc: 'string' #(4)!
  arraysrc: 'string' #(5)!
  color: any
  symmetric: boolean
  thickness: number
  traceref: integer
  tracerefminus: integer
  type: any
  value: number
  valueminus: number
  visible: boolean
  width: number
fill: any
fillcolor: any
hoverinfo: array
hoverinfosrc: 'string' #(6)!
hoverlabel:
  align: array
  alignsrc: 'string' #(7)!
  bgcolor: array
  bgcolorsrc: 'string' #(8)!
  bordercolor: array
  bordercolorsrc: 'string' #(9)!
  font:
    color: array
    colorsrc: 'string' #(10)!
    family: 'string | array' #(11)!
    familysrc: 'string' #(12)!
    lineposition: array
    linepositionsrc: 'string' #(13)!
    shadow: 'string | array' #(14)!
    shadowsrc: 'string' #(15)!
    size: array
    sizesrc: 'string' #(16)!
    style: array
    stylesrc: 'string' #(17)!
    textcase: array
    textcasesrc: 'string' #(18)!
    variant: array
    variantsrc: 'string' #(19)!
    weight: array
    weightsrc: 'string' #(20)!
  namelength: array
  namelengthsrc: 'string' #(21)!
hovertemplate: 'string | array' #(22)!
hovertemplatesrc: 'string' #(23)!
hovertext: 'string | array' #(24)!
hovertextsrc: 'string' #(25)!
ids: array
idssrc: 'string' #(26)!
legend: string
legendgroup: 'string' #(27)!
legendgrouptitle:
  font:
    color: any
    family: 'string' #(28)!
    lineposition: any
    shadow: 'string' #(29)!
    size: number
    style: any
    textcase: any
    variant: any
    weight: integer
  text: 'string' #(30)!
legendrank: number
legendwidth: number
line:
  color: any
  dash: any
  shape: any
  width: number
marker:
  angle: array
  anglesrc: 'string' #(31)!
  autocolorscale: boolean
  cauto: boolean
  cmax: number
  cmid: number
  cmin: number
  color: array
  coloraxis: string
  colorbar:
    bgcolor: any
    bordercolor: any
    borderwidth: number
    exponentformat: any
    len: number
    lenmode: any
    minexponent: number
    nticks: integer
    orientation: any
    outlinecolor: any
    outlinewidth: number
    separatethousands: boolean
    showexponent: any
    showticklabels: boolean
    showtickprefix: any
    showticksuffix: any
    thickness: number
    thicknessmode: any
    tickangle: number
    tickcolor: any
    tickfont:
      color: any
      family: 'string' #(32)!
      lineposition: any
      shadow: 'string' #(33)!
      size: number
      style: any
      textcase: any
      variant: any
      weight: integer
    tickformat: 'string' #(34)!
    tickformatstops: array
    ticklabeloverflow: any
    ticklabelposition: any
    ticklabelstep: integer
    ticklen: number
    tickmode: any
    tickprefix: 'string' #(35)!
    ticks: any
    ticksuffix: 'string' #(36)!
    ticktext: array
    ticktextsrc: 'string' #(37)!
    tickvals: array
    tickvalssrc: 'string' #(38)!
    tickwidth: number
    title:
      font:
        color: any
        family: 'string' #(39)!
        lineposition: any
        shadow: 'string' #(40)!
        size: number
        style: any
        textcase: any
        variant: any
        weight: integer
      side: any
      text: 'string' #(41)!
    x: number
    xanchor: any
    xpad: number
    xref: any
    y: number
    yanchor: any
    ypad: number
    yref: any
  colorscale: any
  colorsrc: 'string' #(42)!
  line:
    autocolorscale: boolean
    cauto: boolean
    cmax: number
    cmid: number
    cmin: number
    color: array
    coloraxis: string
    colorscale: any
    colorsrc: 'string' #(43)!
    reversescale: boolean
    width: array
    widthsrc: 'string' #(44)!
  opacity: array
  opacitysrc: 'string' #(45)!
  reversescale: boolean
  showscale: boolean
  size: array
  sizemin: number
  sizemode: any
  sizeref: number
  sizesrc: 'string' #(46)!
  symbol: array
  symbolsrc: 'string' #(47)!
metasrc: 'string' #(48)!
mode: any
name: 'string' #(49)!
opacity: number
selected:
  marker:
    color: any
    opacity: number
    size: number
  textfont:
    color: any
showlegend: boolean
stream:
  maxpoints: number
  token: 'string' #(50)!
text: 'string | array' #(51)!
textfont:
  color: array
  colorsrc: 'string' #(52)!
  family: 'string | array' #(53)!
  familysrc: 'string' #(54)!
  size: array
  sizesrc: 'string' #(55)!
  style: array
  stylesrc: 'string' #(56)!
  variant: array
  variantsrc: 'string' #(57)!
  weight: array
  weightsrc: 'string' #(58)!
textposition: array
textpositionsrc: 'string' #(59)!
textsrc: 'string' #(60)!
texttemplate: 'string | array' #(61)!
texttemplatesrc: 'string' #(62)!
type: scattergl
uid: 'string' #(63)!
unselected:
  marker:
    color: any
    opacity: number
    size: number
  textfont:
    color: any
visible: any
x: array
xaxis: string
xcalendar: any
xhoverformat: 'string' #(64)!
xperiodalignment: any
xsrc: 'string' #(65)!
y: array
yaxis: string
ycalendar: any
yhoverformat: 'string' #(66)!
yperiodalignment: any
ysrc: 'string' #(67)!
  1. Sets the source reference on Chart Studio Cloud for customdata.
  2. Sets the source reference on Chart Studio Cloud for arrayminus.
  3. Sets the source reference on Chart Studio Cloud for array.
  4. Sets the source reference on Chart Studio Cloud for arrayminus.
  5. Sets the source reference on Chart Studio Cloud for array.
  6. Sets the source reference on Chart Studio Cloud for hoverinfo.
  7. Sets the source reference on Chart Studio Cloud for align.
  8. Sets the source reference on Chart Studio Cloud for bgcolor.
  9. Sets the source reference on Chart Studio Cloud for bordercolor.
  10. Sets the source reference on Chart Studio Cloud for color.
  11. HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
  12. Sets the source reference on Chart Studio Cloud for family.
  13. Sets the source reference on Chart Studio Cloud for lineposition.
  14. Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
  15. Sets the source reference on Chart Studio Cloud for shadow.
  16. Sets the source reference on Chart Studio Cloud for size.
  17. Sets the source reference on Chart Studio Cloud for style.
  18. Sets the source reference on Chart Studio Cloud for textcase.
  19. Sets the source reference on Chart Studio Cloud for variant.
  20. Sets the source reference on Chart Studio Cloud for weight.
  21. Sets the source reference on Chart Studio Cloud for namelength.
  22. Template string used for rendering the information that appear on hover box. Note that this will override hoverinfo. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%xother}, {%_xother}, {%xother_}. When showing info for several points, xother will be added to those with different x positions from the first point. An underscore before or after (x|y)other will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available in hovertemplate are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are arrayOk: true) are available. Anything contained in tag <extra> is displayed in the secondary box, for example "{fullData.name}". To hide the secondary box completely, use an empty tag <extra></extra>.
  23. Sets the source reference on Chart Studio Cloud for hovertemplate.
  24. Sets hover text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. To be seen, trace hoverinfo must contain a text flag.
  25. Sets the source reference on Chart Studio Cloud for hovertext.
  26. Sets the source reference on Chart Studio Cloud for ids.
  27. Sets the legend group for this trace. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items.
  28. HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
  29. Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
  30. Sets the title of the legend group.
  31. Sets the source reference on Chart Studio Cloud for angle.
  32. HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
  33. Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
  34. Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46
  35. Sets a tick label prefix.
  36. Sets a tick label suffix.
  37. Sets the source reference on Chart Studio Cloud for ticktext.
  38. Sets the source reference on Chart Studio Cloud for tickvals.
  39. HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
  40. Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
  41. Sets the title of the color bar.
  42. Sets the source reference on Chart Studio Cloud for color.
  43. Sets the source reference on Chart Studio Cloud for color.
  44. Sets the source reference on Chart Studio Cloud for width.
  45. Sets the source reference on Chart Studio Cloud for opacity.
  46. Sets the source reference on Chart Studio Cloud for size.
  47. Sets the source reference on Chart Studio Cloud for symbol.
  48. Sets the source reference on Chart Studio Cloud for meta.
  49. Sets the trace name. The trace name appears as the legend item and on hover.
  50. The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
  51. Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace hoverinfo contains a text flag and hovertext is not set, these elements will be seen in the hover labels.
  52. Sets the source reference on Chart Studio Cloud for color.
  53. HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
  54. Sets the source reference on Chart Studio Cloud for family.
  55. Sets the source reference on Chart Studio Cloud for size.
  56. Sets the source reference on Chart Studio Cloud for style.
  57. Sets the source reference on Chart Studio Cloud for variant.
  58. Sets the source reference on Chart Studio Cloud for weight.
  59. Sets the source reference on Chart Studio Cloud for textposition.
  60. Sets the source reference on Chart Studio Cloud for text.
  61. Template string used for rendering the information text that appear on points. Note that this will override textinfo. Variables are inserted using %{variable}, for example "y: %{y}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Every attributes that can be specified per-point (the ones that are arrayOk: true) are available.
  62. Sets the source reference on Chart Studio Cloud for texttemplate.
  63. Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
  64. Sets the hover text formatting rulefor x using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted using xaxis.hoverformat.
  65. Sets the source reference on Chart Studio Cloud for x.
  66. Sets the hover text formatting rulefor y using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted using yaxis.hoverformat.
  67. Sets the source reference on Chart Studio Cloud for y.