plotly

package
v0.11.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: MIT, MIT Imports: 6 Imported by: 4

Documentation

Overview

Package plotly adds barebones support to Plotly (https://plotly.com/javascript/getting-started/) library.

It's a simple wrapper to execute javascript code, assuming the Plotly library is loaded.

It also offers a library around github.com/MetalBlueberry/go-plotly (itself a wrapper around Plotly) to integrate it in GoNB, see `DisplayFig` method.

API is a first stab at it (experimental), and `UpdateHtml` for dynamic plots is not yet supported. Ideas are welcome here.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PlotlyDarkTheme can be set to a `Fig.Layout.Template` field, to specify a theme for the figure.
	//
	// It was converted from the Python's plotly library, from the "plotly_dark" theme.
	PlotlyDarkTheme = map[string]any{"data": map[string]any{"bar": []any{map[string]any{"error_x": map[string]any{"color": "#f2f5fa"}, "error_y": map[string]any{"color": "#f2f5fa"}, "marker": map[string]any{"line": map[string]any{"color": "rgb(17,17,17)", "width": 0.5}, "pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "bar"}}, "barpolar": []any{map[string]any{"marker": map[string]any{"line": map[string]any{"color": "rgb(17,17,17)", "width": 0.5}, "pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "barpolar"}}, "carpet": []any{map[string]any{"aaxis": map[string]any{"endlinecolor": "#A2B1C6", "gridcolor": "#506784", "linecolor": "#506784", "minorgridcolor": "#506784", "startlinecolor": "#A2B1C6"}, "baxis": map[string]any{"endlinecolor": "#A2B1C6", "gridcolor": "#506784", "linecolor": "#506784", "minorgridcolor": "#506784", "startlinecolor": "#A2B1C6"}, "type": "carpet"}}, "choropleth": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "type": "choropleth"}}, "contour": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "colorscale": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}, "type": "contour"}}, "contourcarpet": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "type": "contourcarpet"}}, "heatmap": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "colorscale": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}, "type": "heatmap"}}, "histogram": []any{map[string]any{"marker": map[string]any{"pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "histogram"}}, "histogram2d": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "colorscale": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}, "type": "histogram2d"}}, "histogram2dcontour": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "colorscale": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}, "type": "histogram2dcontour"}}, "mesh3d": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "type": "mesh3d"}}, "parcoords": []any{map[string]any{"line": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "parcoords"}}, "pie": []any{map[string]any{"automargin": true, "type": "pie"}}, "scatter": []any{map[string]any{"marker": map[string]any{"line": map[string]any{"color": "#283442"}}, "type": "scatter"}}, "scatter3d": []any{map[string]any{"line": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scatter3d"}}, "scattercarpet": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scattercarpet"}}, "scattergeo": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scattergeo"}}, "scattergl": []any{map[string]any{"marker": map[string]any{"line": map[string]any{"color": "#283442"}}, "type": "scattergl"}}, "scattermap": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scattermap"}}, "scattermapbox": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scattermapbox"}}, "scatterpolar": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scatterpolar"}}, "scatterpolargl": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scatterpolargl"}}, "scatterternary": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "type": "scatterternary"}}, "surface": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}, "colorscale": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}, "type": "surface"}}, "table": []any{map[string]any{"cells": map[string]any{"fill": map[string]any{"color": "#506784"}, "line": map[string]any{"color": "rgb(17,17,17)"}}, "header": map[string]any{"fill": map[string]any{"color": "#2a3f5f"}, "line": map[string]any{"color": "rgb(17,17,17)"}}, "type": "table"}}}, "layout": map[string]any{"annotationdefaults": map[string]any{"arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1}, "autotypenumbers": "strict", "coloraxis": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "ticks": ""}}, "colorscale": map[string]any{"diverging": []any{[]any{0, "#8e0152"}, []any{0.1, "#c51b7d"}, []any{0.2, "#de77ae"}, []any{0.3, "#f1b6da"}, []any{0.4, "#fde0ef"}, []any{0.5, "#f7f7f7"}, []any{0.6, "#e6f5d0"}, []any{0.7, "#b8e186"}, []any{0.8, "#7fbc41"}, []any{0.9, "#4d9221"}, []any{1, "#276419"}}, "sequential": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}, "sequentialminus": []any{[]any{0, "#0d0887"}, []any{0.1111111111111111, "#46039f"}, []any{0.2222222222222222, "#7201a8"}, []any{0.3333333333333333, "#9c179e"}, []any{0.4444444444444444, "#bd3786"}, []any{0.5555555555555556, "#d8576b"}, []any{0.6666666666666666, "#ed7953"}, []any{0.7777777777777778, "#fb9f3a"}, []any{0.8888888888888888, "#fdca26"}, []any{1, "#f0f921"}}}, "colorway": []any{"#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52"}, "font": map[string]any{"color": "#f2f5fa"}, "geo": map[string]any{"bgcolor": "rgb(17,17,17)", "lakecolor": "rgb(17,17,17)", "landcolor": "rgb(17,17,17)", "showlakes": true, "showland": true, "subunitcolor": "#506784"}, "hoverlabel": map[string]any{"align": "left"}, "hovermode": "closest", "mapbox": map[string]any{"style": "dark"}, "paper_bgcolor": "rgb(17,17,17)", "plot_bgcolor": "rgb(17,17,17)", "polar": map[string]any{"angularaxis": map[string]any{"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "bgcolor": "rgb(17,17,17)", "radialaxis": map[string]any{"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}}, "scene": map[string]any{"xaxis": map[string]any{"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "gridwidth": 2, "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3"}, "yaxis": map[string]any{"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "gridwidth": 2, "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3"}, "zaxis": map[string]any{"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "gridwidth": 2, "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3"}}, "shapedefaults": map[string]any{"line": map[string]any{"color": "#f2f5fa"}}, "sliderdefaults": map[string]any{"bgcolor": "#C8D4E3", "bordercolor": "rgb(17,17,17)", "borderwidth": 1, "tickwidth": 0}, "ternary": map[string]any{"aaxis": map[string]any{"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "baxis": map[string]any{"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "bgcolor": "rgb(17,17,17)", "caxis": map[string]any{"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}}, "title": map[string]any{"x": 0.05}, "updatemenudefaults": map[string]any{"bgcolor": "#506784", "borderwidth": 0}, "xaxis": map[string]any{"automargin": true, "gridcolor": "#283442", "linecolor": "#506784", "ticks": "", "title": map[string]any{"standoff": 15}, "zerolinecolor": "#283442", "zerolinewidth": 2}, "yaxis": map[string]any{"automargin": true, "gridcolor": "#283442", "linecolor": "#506784", "ticks": "", "title": map[string]any{"standoff": 15}, "zerolinecolor": "#283442", "zerolinewidth": 2}}}

	// SeabornTheme can be set to a `Fig.Layout.Template` field, to specify a theme for the figure.
	//
	// It was converted from the Python's plotly library, from the "seaborn" theme.
	SeabornTheme = map[string]any{"data": map[string]any{"bar": []any{map[string]any{"error_x": map[string]any{"color": "rgb(36,36,36)"}, "error_y": map[string]any{"color": "rgb(36,36,36)"}, "marker": map[string]any{"line": map[string]any{"color": "rgb(234,234,242)", "width": 0.5}, "pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "bar"}}, "barpolar": []any{map[string]any{"marker": map[string]any{"line": map[string]any{"color": "rgb(234,234,242)", "width": 0.5}, "pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "barpolar"}}, "carpet": []any{map[string]any{"aaxis": map[string]any{"endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)"}, "baxis": map[string]any{"endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)"}, "type": "carpet"}}, "choropleth": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "type": "choropleth"}}, "contour": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}, "type": "contour"}}, "contourcarpet": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "type": "contourcarpet"}}, "heatmap": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}, "type": "heatmap"}}, "histogram": []any{map[string]any{"marker": map[string]any{"pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "histogram"}}, "histogram2d": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}, "type": "histogram2d"}}, "histogram2dcontour": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}, "type": "histogram2dcontour"}}, "mesh3d": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "type": "mesh3d"}}, "parcoords": []any{map[string]any{"line": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "parcoords"}}, "pie": []any{map[string]any{"automargin": true, "type": "pie"}}, "scatter": []any{map[string]any{"fillpattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}, "type": "scatter"}}, "scatter3d": []any{map[string]any{"line": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scatter3d"}}, "scattercarpet": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scattercarpet"}}, "scattergeo": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scattergeo"}}, "scattergl": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scattergl"}}, "scattermap": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scattermap"}}, "scattermapbox": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scattermapbox"}}, "scatterpolar": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scatterpolar"}}, "scatterpolargl": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scatterpolargl"}}, "scatterternary": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "type": "scatterternary"}}, "surface": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}, "type": "surface"}}, "table": []any{map[string]any{"cells": map[string]any{"fill": map[string]any{"color": "rgb(231,231,240)"}, "line": map[string]any{"color": "white"}}, "header": map[string]any{"fill": map[string]any{"color": "rgb(183,183,191)"}, "line": map[string]any{"color": "white"}}, "type": "table"}}}, "layout": map[string]any{"annotationdefaults": map[string]any{"arrowcolor": "rgb(67,103,167)"}, "autotypenumbers": "strict", "coloraxis": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "colorscale": map[string]any{"sequential": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}, "sequentialminus": []any{[]any{0, "rgb(2,4,25)"}, []any{0.06274509803921569, "rgb(24,15,41)"}, []any{0.12549019607843137, "rgb(47,23,57)"}, []any{0.18823529411764706, "rgb(71,28,72)"}, []any{0.25098039215686274, "rgb(97,30,82)"}, []any{0.3137254901960784, "rgb(123,30,89)"}, []any{0.3764705882352941, "rgb(150,27,91)"}, []any{0.4392156862745098, "rgb(177,22,88)"}, []any{0.5019607843137255, "rgb(203,26,79)"}, []any{0.5647058823529412, "rgb(223,47,67)"}, []any{0.6274509803921569, "rgb(236,76,61)"}, []any{0.6901960784313725, "rgb(242,107,73)"}, []any{0.7529411764705882, "rgb(244,135,95)"}, []any{0.8156862745098039, "rgb(245,162,122)"}, []any{0.8784313725490196, "rgb(246,188,153)"}, []any{0.9411764705882353, "rgb(247,212,187)"}, []any{1, "rgb(250,234,220)"}}}, "colorway": []any{"rgb(76,114,176)", "rgb(221,132,82)", "rgb(85,168,104)", "rgb(196,78,82)", "rgb(129,114,179)", "rgb(147,120,96)", "rgb(218,139,195)", "rgb(140,140,140)", "rgb(204,185,116)", "rgb(100,181,205)"}, "font": map[string]any{"color": "rgb(36,36,36)"}, "geo": map[string]any{"bgcolor": "white", "lakecolor": "white", "landcolor": "rgb(234,234,242)", "showlakes": true, "showland": true, "subunitcolor": "white"}, "hoverlabel": map[string]any{"align": "left"}, "hovermode": "closest", "paper_bgcolor": "white", "plot_bgcolor": "rgb(234,234,242)", "polar": map[string]any{"angularaxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "bgcolor": "rgb(234,234,242)", "radialaxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}}, "scene": map[string]any{"xaxis": map[string]any{"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white"}, "yaxis": map[string]any{"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white"}, "zaxis": map[string]any{"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white"}}, "shapedefaults": map[string]any{"fillcolor": "rgb(67,103,167)", "line": map[string]any{"width": 0}, "opacity": 0.5}, "ternary": map[string]any{"aaxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "baxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "bgcolor": "rgb(234,234,242)", "caxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}}, "xaxis": map[string]any{"automargin": true, "gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": "", "title": map[string]any{"standoff": 15}, "zerolinecolor": "white"}, "yaxis": map[string]any{"automargin": true, "gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": "", "title": map[string]any{"standoff": 15}, "zerolinecolor": "white"}}}

	// GGPlot2Theme can be set to a `Fig.Layout.Template` field, to specify a theme for the figure.
	//
	// It was converted from the Python's plotly library, from the "ggplot2" theme.
	GGPlot2Theme = map[string]any{"data": map[string]any{"bar": []any{map[string]any{"error_x": map[string]any{"color": "rgb(51,51,51)"}, "error_y": map[string]any{"color": "rgb(51,51,51)"}, "marker": map[string]any{"line": map[string]any{"color": "rgb(237,237,237)", "width": 0.5}, "pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "bar"}}, "barpolar": []any{map[string]any{"marker": map[string]any{"line": map[string]any{"color": "rgb(237,237,237)", "width": 0.5}, "pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "barpolar"}}, "carpet": []any{map[string]any{"aaxis": map[string]any{"endlinecolor": "rgb(51,51,51)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(51,51,51)"}, "baxis": map[string]any{"endlinecolor": "rgb(51,51,51)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(51,51,51)"}, "type": "carpet"}}, "choropleth": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "type": "choropleth"}}, "contour": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}, "type": "contour"}}, "contourcarpet": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "type": "contourcarpet"}}, "heatmap": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}, "type": "heatmap"}}, "histogram": []any{map[string]any{"marker": map[string]any{"pattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}}, "type": "histogram"}}, "histogram2d": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}, "type": "histogram2d"}}, "histogram2dcontour": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}, "type": "histogram2dcontour"}}, "mesh3d": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "type": "mesh3d"}}, "parcoords": []any{map[string]any{"line": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "parcoords"}}, "pie": []any{map[string]any{"automargin": true, "type": "pie"}}, "scatter": []any{map[string]any{"fillpattern": map[string]any{"fillmode": "overlay", "size": 10, "solidity": 0.2}, "type": "scatter"}}, "scatter3d": []any{map[string]any{"line": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scatter3d"}}, "scattercarpet": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scattercarpet"}}, "scattergeo": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scattergeo"}}, "scattergl": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scattergl"}}, "scattermap": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scattermap"}}, "scattermapbox": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scattermapbox"}}, "scatterpolar": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scatterpolar"}}, "scatterpolargl": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scatterpolargl"}}, "scatterternary": []any{map[string]any{"marker": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "type": "scatterternary"}}, "surface": []any{map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}, "type": "surface"}}, "table": []any{map[string]any{"cells": map[string]any{"fill": map[string]any{"color": "rgb(237,237,237)"}, "line": map[string]any{"color": "white"}}, "header": map[string]any{"fill": map[string]any{"color": "rgb(217,217,217)"}, "line": map[string]any{"color": "white"}}, "type": "table"}}}, "layout": map[string]any{"annotationdefaults": map[string]any{"arrowhead": 0, "arrowwidth": 1}, "autotypenumbers": "strict", "coloraxis": map[string]any{"colorbar": map[string]any{"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "colorscale": map[string]any{"sequential": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}, "sequentialminus": []any{[]any{0, "rgb(20,44,66)"}, []any{1, "rgb(90,179,244)"}}}, "colorway": []any{"#F8766D", "#A3A500", "#00BF7D", "#00B0F6", "#E76BF3"}, "font": map[string]any{"color": "rgb(51,51,51)"}, "geo": map[string]any{"bgcolor": "white", "lakecolor": "white", "landcolor": "rgb(237,237,237)", "showlakes": true, "showland": true, "subunitcolor": "white"}, "hoverlabel": map[string]any{"align": "left"}, "hovermode": "closest", "paper_bgcolor": "white", "plot_bgcolor": "rgb(237,237,237)", "polar": map[string]any{"angularaxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "bgcolor": "rgb(237,237,237)", "radialaxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}}, "scene": map[string]any{"xaxis": map[string]any{"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white"}, "yaxis": map[string]any{"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white"}, "zaxis": map[string]any{"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white"}}, "shapedefaults": map[string]any{"fillcolor": "black", "line": map[string]any{"width": 0}, "opacity": 0.3}, "ternary": map[string]any{"aaxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "baxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "bgcolor": "rgb(237,237,237)", "caxis": map[string]any{"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}}, "xaxis": map[string]any{"automargin": true, "gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "title": map[string]any{"standoff": 15}, "zerolinecolor": "white"}, "yaxis": map[string]any{"automargin": true, "gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "title": map[string]any{"standoff": 15}, "zerolinecolor": "white"}}}
)
View Source
var PlotlySrc = "https://cdn.plot.ly/plotly-2.34.0.min.js"

PlotlySrc is the source from where to download Plotly. If you have a local copy or an updated version of the library, change the value here.

Functions

func AppendFig added in v0.10.0

func AppendFig(htmlID string, fig *grob.Fig) error

AppendFig appends the figure to the HTML element with the given id. It uses dom.TransientJavascript so it won't be saved, exported to HTML, or even persistable with dom.Persist. See dom.CreateTransientDiv to create transient div and get its `htmlId`.

func AppendFigAsJSON added in v0.11.2

func AppendFigAsJSON(htmlID string, figAsJSON []byte) error

AppendFigAsJSON appends the figure (given as serialized JSON bytes) to the HTML element with the given id. It uses dom.TransientJavascript so it won't be saved, exported to HTML, or even persistable with dom.Persist. See dom.CreateTransientDiv to create transient div and get its `htmlId`.

func DisplayFig

func DisplayFig(fig *grob.Fig) error

DisplayFig as HTML output.

func DisplayFigAsJSON added in v0.11.2

func DisplayFigAsJSON(figAsJSON []byte) error

DisplayFigAsJSON as HTML output. It provides a mechanism to do arbitrary edits to whatever go-plotly generates.

figAsJSON is a grob.Fig object marshalled as JSON. E.g.:

figBytes, err := json.Marshal(fig)
// ... edit figBytes ...
plotly.DisplayFigAsJSON(figBytes)

Types

type ThemeObject added in v0.11.0

type ThemeObject struct {
	Layout *grob.Layout    `json:"layout,omitempty"`
	Data   json.RawMessage `json:"data,omitempty"` // Using json.RawMessage for the 'data' part

}

ThemeObject defines the structure for a Plotly template object. This will hold the 'layout' and 'data' definitions of the theme.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL