Python Figure Reference: layout.shapes

  • shapes
    Code: fig.update_shapes(...)
    Type: list of dict where each dict has one or more of the keys listed below.
    • editable
      Code: fig.update_shapes(editable=<VALUE>)
      Type: boolean

      Determines whether the shape could be activated for edit or not. Has no effect when the older editable shapes mode is enabled via `config.editable` or `config.edits.shapePosition`.

    • fillcolor
      Code: fig.update_shapes(fillcolor=<VALUE>)
      Type: color
      Default: "rgba(0,0,0,0)"

      Sets the color filling the shape's interior. Only applies to closed shapes.

    • fillrule
      Code: fig.update_shapes(fillrule=<VALUE>)
      Type: enumerated , one of ( "evenodd" | "nonzero" )
      Default: "evenodd"

      Determines which regions of complex paths constitute the interior. For more info please visit https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule

    • label
      Code: fig.update_shapes(label=dict(...))
      Type: dict containing one or more of the keys listed below.
      • font
        Code: fig.update_shapes(label_font=dict(...))
        Type: dict containing one or more of the keys listed below.

        Sets the shape label text font.

        • color
          Code: fig.update_shapes(label_font_color=<VALUE>)
          Type: color
        • family
          Code: fig.update_shapes(label_font_family=<VALUE>)
          Type: string

          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.

        • lineposition
          Code: fig.update_shapes(label_font_lineposition=<VALUE>)
          Type: flaglist string. Any combination of "under", "over", "through" joined with a "+" OR "none".
          Examples: "under", "over", "under+over", "under+over+through", "none"
          Default: "none"

          Sets the kind of decoration line(s) with text, such as an "under", "over" or "through" as well as combinations e.g. "under+over", etc.

        • shadow
          Code: fig.update_shapes(label_font_shadow=<VALUE>)
          Type: string
          Default: "none"

          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.

        • size
          Code: fig.update_shapes(label_font_size=<VALUE>)
          Type: number greater than or equal to 1
        • style
          Code: fig.update_shapes(label_font_style=<VALUE>)
          Type: enumerated , one of ( "normal" | "italic" )
          Default: "normal"

          Sets whether a font should be styled with a normal or italic face from its family.

        • textcase
          Code: fig.update_shapes(label_font_textcase=<VALUE>)
          Type: enumerated , one of ( "normal" | "word caps" | "upper" | "lower" )
          Default: "normal"

          Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.

        • variant
          Code: fig.update_shapes(label_font_variant=<VALUE>)
          Type: enumerated , one of ( "normal" | "small-caps" | "all-small-caps" | "all-petite-caps" | "petite-caps" | "unicase" )
          Default: "normal"

          Sets the variant of the font.

        • weight
          Code: fig.update_shapes(label_font_weight=<VALUE>)
          Type: integer between or equal to 1 and 1000
          Default: normal

          Sets the weight (or boldness) of the font.

      • padding
        Code: fig.update_shapes(label_padding=<VALUE>)
        Type: number greater than or equal to 0
        Default: 3

        Sets padding (in px) between edge of label and edge of shape.

      • text
        Code: fig.update_shapes(label_text=<VALUE>)
        Type: string
        Default: ""

        Sets the text to display with shape. It is also used for legend item if `name` is not provided.

      • textangle
        Code: fig.update_shapes(label_textangle=<VALUE>)
        Type: angle
        Default: "auto"

        Sets the angle at which the label text is drawn with respect to the horizontal. For lines, angle "auto" is the same angle as the line. For all other shapes, angle "auto" is horizontal.

      • textposition
        Code: fig.update_shapes(label_textposition=<VALUE>)
        Type: enumerated , one of ( "top left" | "top center" | "top right" | "middle left" | "middle center" | "middle right" | "bottom left" | "bottom center" | "bottom right" | "start" | "middle" | "end" )

        Sets the position of the label text relative to the shape. Supported values for rectangles, circles and paths are "top left", "top center", "top right", "middle left", "middle center", "middle right", "bottom left", "bottom center", and "bottom right". Supported values for lines are "start", "middle", and "end". Default: "middle center" for rectangles, circles, and paths; "middle" for lines.

      • texttemplate
        Code: fig.update_shapes(label_texttemplate=<VALUE>)
        Type: string
        Default: ""

        Template string used for rendering the shape's label. Note that this will override `text`. Variables are inserted using %{variable}, for example "x0: %{x0}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{x0:$.2f}". See 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: %{x0|%m %b %Y}". See https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. A single multiplication or division operation may be applied to numeric variables, and combined with d3 number formatting, for example "Length in cm: %{x0"2.54}", "%{slope"60:.1f} meters per second." For log axes, variable values are given in log units. For date axes, x/y coordinate variables and center variables use datetimes, while all other variable values use values in ms. Finally, the template string has access to variables `x0`, `x1`, `y0`, `y1`, `slope`, `dx`, `dy`, `width`, `height`, `length`, `xcenter`, `ycenter`, `simpleXVariables` and `simpleYVariables`. Variables that can't be found will be replaced with the specifier. For example, a template of "data: %{x}, %{y}" will result in a value of "data: 1, %{y}" if x is 1 and y is missing. Variables with an undefined value will be replaced with the fallback value.

      • texttemplatefallback
        Code: fig.update_shapes(label_texttemplatefallback=<VALUE>)
        Type: number or categorical coordinate string
        Default: -

        Fallback string that's displayed when a variable referenced in a template is missing. If the boolean value 'False' is passed in, the specifier with the missing variable will be displayed.

      • xanchor
        Code: fig.update_shapes(label_xanchor=<VALUE>)
        Type: enumerated , one of ( "auto" | "left" | "center" | "right" )
        Default: "auto"

        Sets the label's horizontal position anchor This anchor binds the specified `textposition` to the "left", "center" or "right" of the label text. For example, if `textposition` is set to "top right" and `xanchor` to "right" then the right-most portion of the label text lines up with the right-most edge of the shape.

      • yanchor
        Code: fig.update_shapes(label_yanchor=<VALUE>)
        Type: enumerated , one of ( "top" | "middle" | "bottom" )

        Sets the label's vertical position anchor This anchor binds the specified `textposition` to the "top", "middle" or "bottom" of the label text. For example, if `textposition` is set to "top right" and `yanchor` to "top" then the top-most portion of the label text lines up with the top-most edge of the shape.

    • layer
      Code: fig.update_shapes(layer=<VALUE>)
      Type: enumerated , one of ( "below" | "above" | "between" )
      Default: "above"

      Specifies whether shapes are drawn below gridlines ("below"), between gridlines and traces ("between") or above traces ("above").

    • legend
      Code: fig.update_shapes(legend=<VALUE>)
      Type: subplotid
      Default: legend

      Sets the reference to a legend to show this shape in. References to these legends are "legend", "legend2", "legend3", etc. Settings for these legends are set in the layout, under `layout.legend`, `layout.legend2`, etc.

    • legendgroup
      Code: fig.update_shapes(legendgroup=<VALUE>)
      Type: string
      Default: ""

      Sets the legend group for this shape. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items.

    • legendgrouptitle
      Code: fig.update_shapes(legendgrouptitle=dict(...))
      Type: dict containing one or more of the keys listed below.
      • font
        Code: fig.update_shapes(legendgrouptitle_font=dict(...))
        Type: dict containing one or more of the keys listed below.

        Sets this legend group's title font.

        • color
          Code: fig.update_shapes(legendgrouptitle_font_color=<VALUE>)
          Type: color
        • family
          Code: fig.update_shapes(legendgrouptitle_font_family=<VALUE>)
          Type: string

          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.

        • lineposition
          Code: fig.update_shapes(legendgrouptitle_font_lineposition=<VALUE>)
          Type: flaglist string. Any combination of "under", "over", "through" joined with a "+" OR "none".
          Examples: "under", "over", "under+over", "under+over+through", "none"
          Default: "none"

          Sets the kind of decoration line(s) with text, such as an "under", "over" or "through" as well as combinations e.g. "under+over", etc.

        • shadow
          Code: fig.update_shapes(legendgrouptitle_font_shadow=<VALUE>)
          Type: string
          Default: "none"

          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.

        • size
          Code: fig.update_shapes(legendgrouptitle_font_size=<VALUE>)
          Type: number greater than or equal to 1
        • style
          Code: fig.update_shapes(legendgrouptitle_font_style=<VALUE>)
          Type: enumerated , one of ( "normal" | "italic" )
          Default: "normal"

          Sets whether a font should be styled with a normal or italic face from its family.

        • textcase
          Code: fig.update_shapes(legendgrouptitle_font_textcase=<VALUE>)
          Type: enumerated , one of ( "normal" | "word caps" | "upper" | "lower" )
          Default: "normal"

          Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.

        • variant
          Code: fig.update_shapes(legendgrouptitle_font_variant=<VALUE>)
          Type: enumerated , one of ( "normal" | "small-caps" | "all-small-caps" | "all-petite-caps" | "petite-caps" | "unicase" )