Skip to content

Carpet

Overview

The carpet trace type is used to create carpet plots, which can be useful for visualizing data across irregular spaces or non-grid-like arrangements. Carpet plots are commonly employed in complex datasets that span two independent variables, such as pressure and temperature or other bivariate datasets.

Carpet traces provide you with control over the X and Y axes, as well as customization of the A and B axes (the independent variables). You can also use a variety of formatting options, including line, color, and axis ticks to enhance the visualization.

Common Uses

  • Distortion Analysis: Visualizing data across irregular spaces, such as in physics or engineering.
  • Bivariate Data Visualization: Displaying complex relationships between two independent variables.
  • Gridless Data Representation: Visualizing data that doesn't fit neatly into grid-like structures.

Check out the Attributes for the full set of configuration options

Examples

Common Configurations

Here's a simple(ish) carpet plot showing data across two independent variables (A and B):

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

models:
  - name: carpet-data-axes
    args:
      - echo
      - |
        a,b,x,y
        1,5,2,3
        2,6,3,4
        3,7,4,5
        4,8,5,6
        5,9,6,7
traces:
  - name: Carpet Plot with Custom Axes
    model: ${ref(carpet-data-axes)}
    props:
      type: carpet
      a: ?{a}
      b: ?{b}
      y: ?{y}
      aaxis:
        title:
          text: "Custom A Axis"
        tickprefix: "A-"
      baxis:
        title:
          text: "Custom B Axis"
        tickprefix: "B-"
charts:
  - name: Simple Carpet Chart
    traces:
      - ${ref(Carpet Plot with Custom Axes)}
    layout:
      title:
        text: Carpet Plot with Custom Axes<br><sub>With Customized A and B Axes</sub>
      xaxis:
        title:
          text: "X Axis"
      yaxis:
        title:
          text: "Y Axis"
      margin: 
        b: 0
        r: 70
        l: 70
        t: 50

A schema to validate plotly trace properties

Attributes

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

a: array
a0: number
aaxis:
  arraydtick: integer
  arraytick0: integer
  autorange: any
  autotypenumbers: any
  categoryarray: array
  categoryarraysrc: 'string' #(1)!
  categoryorder: any
  cheatertype: any
  color: any
  dtick: number
  endline: boolean
  endlinecolor: any
  endlinewidth: number
  exponentformat: any
  fixedrange: boolean
  gridcolor: any
  griddash: 'string' #(2)!
  gridwidth: number
  labelpadding: integer
  labelprefix: 'string' #(3)!
  labelsuffix: 'string' #(4)!
  linecolor: any
  linewidth: number
  minexponent: number
  minorgridcolor: any
  minorgridcount: integer
  minorgriddash: 'string' #(5)!
  minorgridwidth: number
  nticks: integer
  range: array
  rangemode: any
  separatethousands: boolean
  showexponent: any
  showgrid: boolean
  showline: boolean
  showticklabels: any
  showtickprefix: any
  showticksuffix: any
  smoothing: number
  startline: boolean
  startlinecolor: any
  startlinewidth: number
  tick0: number
  tickangle: number
  tickfont:
    color: any
    family: 'string' #(6)!
    lineposition: any
    shadow: 'string' #(7)!
    size: number
    style: any
    textcase: any
    variant: any
    weight: integer
  tickformat: 'string' #(8)!
  tickformatstops: array
  tickmode: any
  tickprefix: 'string' #(9)!
  ticksuffix: 'string' #(10)!
  ticktext: array
  ticktextsrc: 'string' #(11)!
  tickvals: array
  tickvalssrc: 'string' #(12)!
  title:
    font:
      color: any
      family: 'string' #(13)!
      lineposition: any
      shadow: 'string' #(14)!
      size: number
      style: any
      textcase: any
      variant: any
      weight: integer
    offset: number
    text: 'string' #(15)!
  type: any
asrc: 'string' #(16)!
b: array
b0: number
baxis:
  arraydtick: integer
  arraytick0: integer
  autorange: any
  autotypenumbers: any
  categoryarray: array
  categoryarraysrc: 'string' #(17)!
  categoryorder: any
  cheatertype: any
  color: any
  dtick: number
  endline: boolean
  endlinecolor: any
  endlinewidth: number
  exponentformat: any
  fixedrange: boolean
  gridcolor: any
  griddash: 'string' #(18)!
  gridwidth: number
  labelpadding: integer
  labelprefix: 'string' #(19)!
  labelsuffix: 'string' #(20)!
  linecolor: any
  linewidth: number
  minexponent: number
  minorgridcolor: any
  minorgridcount: integer
  minorgriddash: 'string' #(21)!
  minorgridwidth: number
  nticks: integer
  range: array
  rangemode: any
  separatethousands: boolean
  showexponent: any
  showgrid: boolean
  showline: boolean
  showticklabels: any
  showtickprefix: any
  showticksuffix: any
  smoothing: number
  startline: boolean
  startlinecolor: any
  startlinewidth: number
  tick0: number
  tickangle: number
  tickfont:
    color: any
    family: 'string' #(22)!
    lineposition: any
    shadow: 'string' #(23)!
    size: number
    style: any
    textcase: any
    variant: any
    weight: integer
  tickformat: 'string' #(24)!
  tickformatstops: array
  tickmode: any
  tickprefix: 'string' #(25)!
  ticksuffix: 'string' #(26)!
  ticktext: array
  ticktextsrc: 'string' #(27)!
  tickvals: array
  tickvalssrc: 'string' #(28)!
  title:
    font:
      color: any
      family: 'string' #(29)!
      lineposition: any
      shadow: 'string' #(30)!
      size: number
      style: any
      textcase: any
      variant: any
      weight: integer
    offset: number
    text: 'string' #(31)!
  type: any
bsrc: 'string' #(32)!
carpet: 'string' #(33)!
cheaterslope: number
color: any
customdata: array
customdatasrc: 'string' #(34)!
da: number
db: number
font:
  color: any
  family: 'string' #(35)!
  lineposition: any
  shadow: 'string' #(36)!
  size: number
  style: any
  textcase: any
  variant: any
  weight: integer
ids: array
idssrc: 'string' #(37)!
legend: string
legendgrouptitle:
  font:
    color: any
    family: 'string' #(38)!
    lineposition: any
    shadow: 'string' #(39)!
    size: number
    style: any
    textcase: any
    variant: any
    weight: integer
  text: 'string' #(40)!
legendrank: number
legendwidth: number
metasrc: 'string' #(41)!
name: 'string' #(42)!
opacity: number
stream:
  maxpoints: number
  token: 'string' #(43)!
type: carpet
uid: 'string' #(44)!
visible: any
x: array
xaxis: string
xsrc: 'string' #(45)!
y: array
yaxis: string
ysrc: 'string' #(46)!
zorder: integer
  1. Sets the source reference on Chart Studio Cloud for categoryarray.
  2. 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).
  3. Sets a axis label prefix.
  4. Sets a axis label suffix.
  5. 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).
  6. 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.
  7. 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.
  8. 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
  9. Sets a tick label prefix.
  10. Sets a tick label suffix.
  11. Sets the source reference on Chart Studio Cloud for ticktext.
  12. Sets the source reference on Chart Studio Cloud for tickvals.
  13. 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.
  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 title of this axis.
  16. Sets the source reference on Chart Studio Cloud for a.
  17. Sets the source reference on Chart Studio Cloud for categoryarray.
  18. 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).
  19. Sets a axis label prefix.
  20. Sets a axis label suffix.
  21. 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).
  22. 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.
  23. 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.
  24. 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
  25. Sets a tick label prefix.
  26. Sets a tick label suffix.
  27. Sets the source reference on Chart Studio Cloud for ticktext.
  28. Sets the source reference on Chart Studio Cloud for tickvals.
  29. 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.
  30. 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.
  31. Sets the title of this axis.
  32. Sets the source reference on Chart Studio Cloud for b.
  33. An identifier for this carpet, so that scattercarpet and contourcarpet traces can specify a carpet plot on which they lie
  34. Sets the source reference on Chart Studio Cloud for customdata.
  35. 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.
  36. 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.
  37. Sets the source reference on Chart Studio Cloud for ids.
  38. 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.
  39. 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.
  40. Sets the title of the legend group.
  41. Sets the source reference on Chart Studio Cloud for meta.
  42. Sets the trace name. The trace name appears as the legend item and on hover.
  43. The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
  44. Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
  45. Sets the source reference on Chart Studio Cloud for x.
  46. Sets the source reference on Chart Studio Cloud for y.