Skip to content

Scattercarpet

Overview

The scattercarpet trace type is used to create scatter plots on a 2D carpet axis, which allows for more complex and non-linear grids. This trace type is useful for visualizing relationships between variables when the x and y axes are not evenly spaced, such as in polar or distortion grids.

You can customize the marker size, color, and line connections, similar to standard scatter plots but on a carpet axis.

Common Uses

  • Non-Linear Grids: Visualizing data points on non-standard grids where the x and y axes are distorted or uneven.
  • Data Visualization with Carpet Axes: Displaying data points in cases where the relationships between variables are non-linear or require a more flexible grid.
  • Heatmap-Like Data: Scatter plots combined with other traces like carpet for advanced visualizations.

Check out the Attributes for the full set of configuration options

Examples

Common Configurations

This example shows a scattercarpet plot with a visible carpet grid. The carpet trace defines the non-linear grid, and the scattercarpet trace plots points on that grid:

models:
  - name: carpet-grid
    args:
      - echo
      - |
        a,b,y
        4,1,2
        4,2,3.5
        4,3,4
        4.5,1,3
        4.5,2,4.5
        4.5,3,5
        5,1,5.5
        5,2,6.5
        5,3,7.5
        6,1,8
        6,2,8.5
        6,3,10
  - name: scattercarpet-data
    args:
      - echo
      - |
        a,b,value
        4,1.5,15
        4.5,2.5,25
        5,1.5,30
        6,2.5,40
traces:
  - name: Carpet Grid
    model: ${ref(carpet-grid)}
    props:
      type: carpet
      a: ?{a}
      b: ?{b}
      y: ?{y}
      aaxis:
        tickprefix: 'a = '
        ticksuffix: 'm'
        smoothing: 1
        minorgridcount: 9
      baxis:
        tickprefix: 'b = '
        ticksuffix: 'Pa'
        smoothing: 1
        minorgridcount: 9
  - name: Simple Scattercarpet Plot
    model: ${ref(scattercarpet-data)}
    props:
      type: scattercarpet
      a: ?{a}
      b: ?{b}
      mode: "markers"
charts:
  - name: Simple Scattercarpet Chart
    traces:
      - ${ref(Carpet Grid)}
      - ${ref(Simple Scattercarpet Plot)}
    layout:
      title:
        text: Simple Scattercarpet Plot<br><sub>2D Data Points on Carpet Axis</sub>

This example shows a scattercarpet plot with lines+markers, using a unique carpet grid for context:

models:
  - name: carpet-grid-lines
    args:
      - echo
      - |
        a,b,y
        4,1,2
        4,2,3.5
        4,3,4
        4.5,1,3
        4.5,2,4.5
        4.5,3,5
        5,1,5.5
        5,2,6.5
        5,3,7.5
        6,1,8
        6,2,8.5
        6,3,10
  - name: scattercarpet-data-lines
    args:
      - echo
      - |
        a,b,value
        4,1,7
        4.5,2,12
        5,1.5,10
        6,2.5,18
        5,2,17
traces:
  - name: Carpet Grid Lines
    model: ${ref(carpet-grid-lines)}
    props:
      type: carpet
      a: ?{a}
      b: ?{b}
      y: ?{y}
      aaxis:
        tickprefix: 'a = '
        ticksuffix: 'm'
        smoothing: 1
        minorgridcount: 9
      baxis:
        tickprefix: 'b = '
        ticksuffix: 'Pa'
        smoothing: 1
        minorgridcount: 9
  - name: Scattercarpet Plot with Lines
    model: ${ref(scattercarpet-data-lines)}
    props:
      type: scattercarpet
      a: ?{a}
      b: ?{b}
      mode: "lines+markers"
charts:
  - name: Scattercarpet Chart with Lines
    traces:
      - ${ref(Carpet Grid Lines)}
      - ${ref(Scattercarpet Plot with Lines)}
    layout:
      title:
        text: Scattercarpet Plot with Lines<br><sub>Connecting Data Points on Carpet Axis</sub>

This example shows a scattercarpet plot with custom marker sizes and colors, using a unique carpet grid for context:

models:
  - name: carpet-grid-markers
    args:
      - echo
      - |
        a,b,y
        4,1,2
        4,2,3.5
        4,3,4
        4.5,1,3
        4.5,2,4.5
        4.5,3,5
        5,1,5.5
        5,2,6.5
        5,3,7.5
        6,1,8
        6,2,8.5
        6,3,10
  - name: scattercarpet-data-custom
    args:
      - echo
      - |
        a,b,size,color
        4,1,10,#1f77b4
        4.5,2,15,#ff7f0e
        5,1.5,20,#2ca02c
        6,2.5,25,#d62728
        5,2,30,#9467bd
traces:
  - name: Carpet Grid Markers
    model: ${ref(carpet-grid-markers)}
    props:
      type: carpet
      a: ?{a}
      b: ?{b}
      y: ?{y}
      aaxis:
        tickprefix: 'a = '
        ticksuffix: 'm'
        smoothing: 1
        minorgridcount: 9
      baxis:
        tickprefix: 'b = '
        ticksuffix: 'Pa'
        smoothing: 1
        minorgridcount: 9
  - name: Scattercarpet Plot with Custom Markers
    model: ${ref(scattercarpet-data-custom)}
    props:
      type: scattercarpet
      a: ?{a}
      b: ?{b}
      mode: "markers"
      marker:
        size: ?{size}
        color: ?{color}
charts:
  - name: Scattercarpet Chart with Custom Markers
    traces:
      - ${ref(Carpet Grid Markers)}
      - ${ref(Scattercarpet Plot with Custom Markers)}
    layout:
      title:
        text: Scattercarpet Plot with Custom Markers<br><sub>Custom Sizes and Colors for Carpet Axis Data Points</sub>

A schema to validate plotly trace properties

Attributes

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

a: array
asrc: 'string' #(1)!
b: array
bsrc: 'string' #(2)!
carpet: 'string' #(3)!
connectgaps: boolean
customdata: array
customdatasrc: 'string' #(4)!
fill: any
fillcolor: any
hoverinfo: array
hoverinfosrc: 'string' #(5)!
hoverlabel:
  align: array
  alignsrc: 'string' #(6)!
  bgcolor: array
  bgcolorsrc: 'string' #(7)!
  bordercolor: array
  bordercolorsrc: 'string' #(8)!
  font:
    color: array
    colorsrc: 'string' #(9)!
    family: 'string | array' #(10)!
    familysrc: 'string' #(11)!
    lineposition: array
    linepositionsrc: 'string' #(12)!
    shadow: 'string | array' #(13)!
    shadowsrc: 'string' #(14)!
    size: array
    sizesrc: 'string' #(15)!
    style: array
    stylesrc: 'string' #(16)!
    textcase: array
    textcasesrc: 'string' #(17)!
    variant: array
    variantsrc: 'string' #(18)!
    weight: array
    weightsrc: 'string' #(19)!
  namelength: array
  namelengthsrc: 'string' #(20)!
hoveron: string
hovertemplate: 'string | array' #(21)!
hovertemplatesrc: 'string' #(22)!
hovertext: 'string | array' #(23)!
hovertextsrc: 'string' #(24)!
ids: array
idssrc: 'string' #(25)!
legend: string
legendgroup: 'string' #(26)!
legendgrouptitle:
  font:
    color: any
    family: 'string' #(27)!
    lineposition: any
    shadow: 'string' #(28)!
    size: number
    style: any
    textcase: any
    variant: any
    weight: integer
  text: 'string' #(29)!
legendrank: number
legendwidth: number
line:
  backoff: array
  backoffsrc: 'string' #(30)!
  color: any
  dash: 'string' #(31)!
  shape: any
  smoothing: number
  width: number
marker:
  angle: array
  angleref: any
  anglesrc: 'string' #(32)!
  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' #(33)!
      lineposition: any
      shadow: 'string' #(34)!
      size: number
      style: any
      textcase: any
      variant: any
      weight: integer
    tickformat: 'string' #(35)!
    tickformatstops: array
    ticklabeloverflow: any
    ticklabelposition: any
    ticklabelstep: integer
    ticklen: number
    tickmode: any
    tickprefix: 'string' #(36)!
    ticks: any
    ticksuffix: 'string' #(37)!
    ticktext: array
    ticktextsrc: 'string' #(38)!
    tickvals: array
    tickvalssrc: 'string' #(39)!
    tickwidth: number
    title:
      font:
        color: any
        family: 'string' #(40)!
        lineposition: any
        shadow: 'string' #(41)!
        size: number
        style: any
        textcase: any
        variant: any
        weight: integer
      side: any
      text: 'string' #(42)!
    x: number
    xanchor: any
    xpad: number
    xref: any
    y: number
    yanchor: any
    ypad: number
    yref: any
  colorscale: any
  colorsrc: 'string' #(43)!
  gradient:
    color: array
    colorsrc: 'string' #(44)!
    type: array
    typesrc: 'string' #(45)!
  line:
    autocolorscale: boolean
    cauto: boolean
    cmax: number
    cmid: number
    cmin: number
    color: array
    coloraxis: string
    colorscale: any
    colorsrc: 'string' #(46)!
    reversescale: boolean
    width: array
    widthsrc: 'string' #(47)!
  maxdisplayed: number
  opacity: array
  opacitysrc: 'string' #(48)!
  reversescale: boolean
  showscale: boolean
  size: array
  sizemin: number
  sizemode: any
  sizeref: number
  sizesrc: 'string' #(49)!
  standoff: array
  standoffsrc: 'string' #(50)!
  symbol: array
  symbolsrc: 'string' #(51)!
metasrc: 'string' #(52)!
mode: any
name: 'string' #(53)!
opacity: number
selected:
  marker:
    color: any
    opacity: number
    size: number
  textfont:
    color: any
showlegend: boolean
stream:
  maxpoints: number
  token: 'string' #(54)!
text: 'string | array' #(55)!
textfont:
  color: array
  colorsrc: 'string' #(56)!
  family: 'string | array' #(57)!
  familysrc: 'string' #(58)!
  lineposition: array
  linepositionsrc: 'string' #(59)!
  shadow: 'string | array' #(60)!
  shadowsrc: 'string' #(61)!
  size: array
  sizesrc: 'string' #(62)!
  style: array
  stylesrc: 'string' #(63)!
  textcase: array
  textcasesrc: 'string' #(64)!
  variant: array
  variantsrc: 'string' #(65)!
  weight: array
  weightsrc: 'string' #(66)!
textposition: array
textpositionsrc: 'string' #(67)!
textsrc: 'string' #(68)!
texttemplate: 'string | array' #(69)!
texttemplatesrc: 'string' #(70)!
type: scattercarpet
uid: 'string' #(71)!
unselected:
  marker:
    color: any
    opacity: number
    size: number
  textfont:
    color: any
visible: any
xaxis: string
yaxis: string
zorder: integer
  1. Sets the source reference on Chart Studio Cloud for a.
  2. Sets the source reference on Chart Studio Cloud for b.
  3. An identifier for this carpet, so that scattercarpet and contourcarpet traces can specify a carpet plot on which they lie
  4. Sets the source reference on Chart Studio Cloud for customdata.
  5. Sets the source reference on Chart Studio Cloud for hoverinfo.
  6. Sets the source reference on Chart Studio Cloud for align.
  7. Sets the source reference on Chart Studio Cloud for bgcolor.
  8. Sets the source reference on Chart Studio Cloud for bordercolor.
  9. Sets the source reference on Chart Studio Cloud for color.
  10. 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.
  11. Sets the source reference on Chart Studio Cloud for family.
  12. Sets the source reference on Chart Studio Cloud for lineposition.
  13. 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.
  14. Sets the source reference on Chart Studio Cloud for shadow.
  15. Sets the source reference on Chart Studio Cloud for size.
  16. Sets the source reference on Chart Studio Cloud for style.
  17. Sets the source reference on Chart Studio Cloud for textcase.
  18. Sets the source reference on Chart Studio Cloud for variant.
  19. Sets the source reference on Chart Studio Cloud for weight.
  20. Sets the source reference on Chart Studio Cloud for namelength.
  21. 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>.
  22. Sets the source reference on Chart Studio Cloud for hovertemplate.
  23. Sets hover text elements associated with each (a,b) point. If a single string, the same string appears over all the data points. If an array of strings, the items are mapped in order to the the data points in (a,b). To be seen, trace hoverinfo must contain a text flag.
  24. Sets the source reference on Chart Studio Cloud for hovertext.
  25. Sets the source reference on Chart Studio Cloud for ids.
  26. 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.
  27. 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.
  28. 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.
  29. Sets the title of the legend group.
  30. Sets the source reference on Chart Studio Cloud for backoff.
  31. Sets the dash style of lines. Set to a dash type string (solid, dot, dash, longdash, dashdot, or longdashdot) or a dash length list in px (eg 5px,10px,2px,2px).
  32. Sets the source reference on Chart Studio Cloud for angle.
  33. 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.
  34. 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.
  35. 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
  36. Sets a tick label prefix.
  37. Sets a tick label suffix.
  38. Sets the source reference on Chart Studio Cloud for ticktext.
  39. Sets the source reference on Chart Studio Cloud for tickvals.
  40. 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.
  41. 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.
  42. Sets the title of the color bar.
  43. Sets the source reference on Chart Studio Cloud for color.
  44. Sets the source reference on Chart Studio Cloud for color.
  45. Sets the source reference on Chart Studio Cloud for type.
  46. Sets the source reference on Chart Studio Cloud for color.
  47. Sets the source reference on Chart Studio Cloud for width.
  48. Sets the source reference on Chart Studio Cloud for opacity.
  49. Sets the source reference on Chart Studio Cloud for size.
  50. Sets the source reference on Chart Studio Cloud for standoff.
  51. Sets the source reference on Chart Studio Cloud for symbol.
  52. Sets the source reference on Chart Studio Cloud for meta.
  53. Sets the trace name. The trace name appears as the legend item and on hover.
  54. The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
  55. Sets text elements associated with each (a,b) point. If a single string, the same string appears over all the data points. If an array of strings, the items are mapped in order to the the data points in (a,b). If trace hoverinfo contains a text flag and hovertext is not set, these elements will be seen in the hover labels.
  56. Sets the source reference on Chart Studio Cloud for color.
  57. 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.
  58. Sets the source reference on Chart Studio Cloud for family.
  59. Sets the source reference on Chart Studio Cloud for lineposition.
  60. 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.
  61. Sets the source reference on Chart Studio Cloud for shadow.
  62. Sets the source reference on Chart Studio Cloud for size.
  63. Sets the source reference on Chart Studio Cloud for style.
  64. Sets the source reference on Chart Studio Cloud for textcase.
  65. Sets the source reference on Chart Studio Cloud for variant.
  66. Sets the source reference on Chart Studio Cloud for weight.
  67. Sets the source reference on Chart Studio Cloud for textposition.
  68. Sets the source reference on Chart Studio Cloud for text.
  69. 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. Finally, the template string has access to variables a, b and text.
  70. Sets the source reference on Chart Studio Cloud for texttemplate.
  71. Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.