diff --git a/ch-plotly/basiccharts.ipynb b/ch-plotly/basiccharts.ipynb new file mode 100644 index 0000000..4935c5e --- /dev/null +++ b/ch-plotly/basiccharts.ipynb @@ -0,0 +1,5483 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 基本图表" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import plotly.graph_objects as go\n", + "#import plotly.express as px\n", + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "在 Matplotlib 章节中,我们介绍了散点图、柱状条形图、饼图、直方图、箱线图等基本图表的作图方法,它们在 Plotly 库中也有对应的函数来作出 `trace` 。\n", + "## 散点图\n", + "\n", + "`go.Scatter` 是 Plotly 中用于创建散点图(scatter plot)的类。以下是一些常用的参数:\n", + "\n", + "- `x`: 用于指定数据点在 x 轴上的坐标,可以是单个值、列表或数组。\n", + "- `y`: 用于指定数据点在 y 轴上的坐标,可以是单个值、列表或数组。\n", + "- `mode`: 定义散点图的模式,常见的包括 'markers'(仅显示标记)、'lines'(仅显示线)、'lines+markers'(同时显示线和标记)等,因此该类也可以作出折线图。\n", + "- `name`: 为 `trace` 指定一个名称,用于图例等,默认名称为“trace x”,x从0开始计数。\n", + "- `marker`: 一个字典,包含有关标记的属性,例如颜色、大小等。\n", + "- `line`: 一个字典,包含有关线的属性,例如颜色、宽度等。\n", + "\n", + "例:向图形对象添加一个 mode 为 'markers' 的散点图。 x 值为 [1, 2, 3, 4],对应的 y 值为 [10, 11, 12, 13]。" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 10, + 11, + 12, + 13 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# 创建一个空的图形对象\n", + "fig = go.Figure()\n", + "fig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[10, 11, 12, 13], mode='markers'))\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "例:在上图中添加一个点线图,命名为 Scatter Plot,用字典传入marker参数,具体设置点的格式为蓝色、10号大小、为圆形,线的格式为红色、宽度为2。" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 10, + 11, + 12, + 13 + ] + }, + { + "line": { + "color": "red", + "width": 2 + }, + "marker": { + "color": "blue", + "size": 10, + "symbol": "circle" + }, + "mode": "markers", + "name": "Scatter Plot", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 8, + 9, + 10, + 11 + ] + }, + { + "line": { + "color": "red", + "width": 2 + }, + "marker": { + "color": "blue", + "size": 10, + "symbol": "circle" + }, + "mode": "markers+lines", + "name": "Scatter Plot", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 8, + 9, + 10, + 11 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "x_values = [1, 2, 3, 4]\n", + "y_values = [8, 9, 10, 11]\n", + "\n", + "trace = go.Scatter(\n", + " x=x_values,\n", + " y=y_values,\n", + " mode='markers+lines',\n", + " name='Scatter Plot',\n", + " marker=dict(\n", + " color='blue',\n", + " size=10,\n", + " symbol='circle'\n", + " ),\n", + " line=dict(\n", + " color='red',\n", + " width=2\n", + " )\n", + ")\n", + "\n", + "fig.add_trace(trace)\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 条形图\n", + "`go.Bar` 是 Plotly 中用于创建条形图(Bar chart)的类。以下是一些常用的参数:\n", + "\n", + "`x`: 用于指定条形的位置,可以是单个值、列表或数组。每个位置上都会绘制一条条形。\n", + "`y`: 用于指定条形的高度,可以是单个值、列表或数组。每个高度值对应一个位置上的条形。\n", + "`name`: 为 trace 指定一个名称,用于图例等。\n", + "`orientation`: 指定条形图的方向,可以是 'v'(垂直)或 'h'(水平),默认为垂直型条形图。\n", + "`marker`: 一个字典,包含有关条形的属性,例如颜色、透明度等。\n", + "`text`: 用于在条形上显示的文本,可以是单个值、列表或数组;可以用来在图中展示具体的类别。\n", + "\n", + "例:作出条形图,条形的颜色为蓝色,透明度为0.7,同时在每个条形上显示对应的 A、B、C、D 类别。" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": "blue", + "opacity": 0.7 + }, + "name": "Bar Chart", + "orientation": "v", + "text": [ + "A", + "B", + "C", + "D" + ], + "type": "bar", + "x": [ + "A", + "B", + "C", + "D" + ], + "y": [ + 10, + 11, + 12, + 13 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "x_values = [\"A\",\"B\",\"C\",\"D\"]\n", + "y_values = [10, 11, 12, 13]\n", + "\n", + "trace = go.Bar(\n", + " x=x_values,\n", + " y=y_values,\n", + " name='Bar Chart',\n", + " orientation='v',\n", + " marker=dict(\n", + " color='blue',\n", + " opacity=0.7\n", + " ),\n", + " text=['A', 'B', 'C', 'D']\n", + ")\n", + "\n", + "fig = go.Figure(trace)\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 饼图\n", + "\n", + "`go.Pie` 是 Plotly 中用于创建饼图(Pie chart)的类。以下是一些常用的参数:\n", + "\n", + "- `labels`: 用于指定每个扇形的标签,可以是单个值、列表或数组。\n", + "- `values`: 用于指定每个扇形的数值,表示占比或数量,可以是单个值、列表或数组。\n", + "- `textinfo`: 用于控制在每个扇形上显示的文本信息,例如百分比、数值等。\n", + "- `hoverinfo`: 指定饼图上鼠标悬停时显示的信息。\n", + "- `hole`: 设置饼图中心的空洞大小,取值范围为 [0, 1],默认为0,通过调整该参数,可以作出环形图。\n", + "- `name`: 为 trace 指定一个名称,用于图例等。\n", + "- `marker`: 一个字典,包含有关扇形的属性,例如颜色、透明度等。\n", + "\n", + "例:对给定的数据作饼图。\n", + "\n", + "1. 控制饼图中每个部分上显示的文本信息,这里设置为显示百分比和标签。\n", + "\n", + "2. 设置悬停(hover)信息,当鼠标悬停在饼图的某个部分时显示的信息,这里设置为显示标签和百分比。\n", + "\n", + "3. 控制饼图中间的空洞的大小,取值范围为 [0, 1],这里设置为 0.3,表示空洞占整个饼图的 30%(即变为环形图)。\n", + "\n", + "4. 配置饼图的颜色和边界线样式:在`marker`中用`colors`参数包含四种颜色的列表,分别对应饼图的四个部分;`line`参数用字典,定义边界线的样式,包括颜色和宽度。这里设置为白色边界线,宽度为2。" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hole": 0.3, + "hoverinfo": "label+percent", + "labels": [ + "Category A", + "Category B", + "Category C", + "Category D" + ], + "marker": { + "colors": [ + "red", + "green", + "blue", + "purple" + ], + "line": { + "color": "white", + "width": 2 + } + }, + "name": "Pie Chart", + "textinfo": "percent+label", + "type": "pie", + "values": [ + 40, + 30, + 20, + 10 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "## 定义数据\n", + "labels = ['Category A', 'Category B', 'Category C', 'Category D'] #包含了饼图每个部分的标签,表示不同的类别\n", + "values = [40, 30, 20, 10] #包含了每个部分对应的数值\n", + "\n", + "trace = go.Pie(\n", + " labels=labels,\n", + " values=values,\n", + " textinfo='percent+label',\n", + " hoverinfo='label+percent',\n", + " hole=0.3,\n", + " name='Pie Chart',\n", + " marker=dict(\n", + " colors=['red', 'green', 'blue', 'purple'],\n", + " line=dict(color='white', width=2)\n", + " )\n", + ")\n", + "\n", + "#fig = go.Figure(trace) # 可以直接作图\n", + "fig = go.Figure()\n", + "fig.add_trace(trace)\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 直方图\n", + "\n", + "\n", + "`go.Histogram` 是 Plotly 中用于创建饼图(Pie chart)的类。以下是一些常用的参数:\n", + "\n", + "- `x`: 用于指定数据点在 x 轴上的坐标,表示待绘制直方图的数据,可以是单个值、列表或数组。\n", + "- `nbinsx`: 设置直方图的箱体数量,即直方图中显示的条形数量。\n", + "- `histnorm`: 用于指定直方图的归一化方式,可以是 'percent'(百分比)、'probability'(概率)等。\n", + "- `name`: 为 trace 指定一个名称,用于图例等。\n", + "- `orientation`: 设置直方图的方向,可以是 'v'(垂直)或 'h'(水平),默认为垂直。\n", + "- `opacity`: 设置直方图的透明度,取值范围为 [0, 1]。\n", + "- `marker`: 一个字典,包含有关直方图的条形的属性,例如颜色、透明度等。\n", + "\n", + "例:对给定一组连续的数据作直方图,分为5个箱子,显示为百分比的方式,透明度设置为0.7,整体颜色为蓝色。" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "histnorm": "percent", + "marker": { + "color": "blue" + }, + "name": "Histogram", + "nbinsx": 5, + "opacity": 0.7, + "type": "histogram", + "x": [ + 1, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 5, + 5 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import plotly.graph_objects as go\n", + "\n", + "## 数据\n", + "data = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5]\n", + "\n", + "trace = go.Histogram(\n", + " x=data,\n", + " nbinsx=5,\n", + " histnorm='percent',\n", + " opacity=0.7,\n", + " marker=dict(\n", + " color='blue'\n", + " )\n", + ")\n", + "\n", + "#fig = go.Figure(trace)\n", + "fig = go.Figure()\n", + "fig.add_trace(trace)\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 箱线图\n", + "\n", + "箱线图能够有效地反映数据的中位数、分位数范围、异常值等统计信息,有助于观察数据的分布和离群值情况。`go.Box` 是 Plotly 中用于创建箱线图(Box plot)的类。以下是一些常用的参数:\n", + "\n", + "- `y`: 用于指定数据点在 y 轴上的坐标,表示待绘制箱线图的数据,可以是单个值、列表或数组。\n", + "- `boxpoints`: 控制箱线图上显示的数据点,可以是 'all'(所有数据点)、'outliers'(离群值)、'all' + 'outliers' 等。不设置该参数时,则不显示具体的点位。\n", + "- `name`: 为 trace 指定一个名称,用于图例等。\n", + "- `boxmean`: 设置是否在箱体内显示均值线。\n", + "- `marker`: 一个字典,包含有关具体点的属性,例如颜色、透明度等。\n", + "- `line`: 一个字典,包含有关中位线和边缘线的属性,例如颜色、宽度等,也控制了箱体颜色。\n", + "\n", + "\n", + "例:对给定的一组连续数据作箱线图,展示所有数据点为散点,显示均值线,数据点颜色为绿色,异常值颜色为红色,并使用蓝色线条描绘。" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "boxmean": true, + "boxpoints": "all", + "line": { + "color": "blue" + }, + "marker": { + "color": "green", + "outliercolor": "red" + }, + "name": "boxplot", + "type": "box", + "y": [ + 1, + 2, + 2, + 3, + 3, + 3, + 4, + 4, + 5, + 5 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "data = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5]\n", + "\n", + "trace = go.Box(\n", + " y=data,\n", + " boxpoints='all',\n", + " boxmean=True,\n", + " name='boxplot',\n", + " marker=dict(\n", + " color='green',\n", + " outliercolor='red'\n", + " ),\n", + " line=dict(\n", + " color='blue'\n", + " )\n", + ")\n", + "\n", + "fig = go.Figure()\n", + "fig.add_trace(trace)\n", + "fig.show()\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pyds", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ch-plotly/elements.ipynb b/ch-plotly/elements.ipynb new file mode 100644 index 0000000..4752dbd --- /dev/null +++ b/ch-plotly/elements.ipynb @@ -0,0 +1,5845 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plotly 画图元素" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "import plotly.graph_objects as go\n", + "#import plotly.express as px\n", + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plotly 提供了丰富的画图元素,使得用户能够创建各种交互性图形。本节对 Plotly 中常用的画图元素进行详细说明。" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 图形 Figure \n", + "\n", + "与 Matplotlib 类似, Plotly 中的 `Figure` 对象也是整个图形的容器,包含了数据的集合轨迹 `traces` 和图形样式 `Layout` 。可以创建 `Figure` 并在其中添加多个 `traces`,然后通过修改 `Layout` 来调整外观;也可以在一个 `Figure` 对象中创建多个子图,再分别添加对应的 `traces`。\n", + "\n", + "在 Plotly 的第一节,我们已经介绍了如何创建一个子图。这里主要以创建多个子图为例。我们用 `plotly.subplots` 模块中的 `.make_subplots()` 方法来创建多个子图的图表,可类比于 Matplotlib 中的`subplots()`函数,常用 `rows` 和 `cols` 参数设置子图的行数和列数排布, `subplot_titles` 参数设置子图的名字,用列表传入。 \n", + "\n", + "例:创建以一行两列形式包含两个子图的图表,第一个子图为散点图,第二个子图为折线图,分别命名为 Subplot 1 和 Subplot 2。\n", + "\n", + "这里先创建好 `trace`,再传入 `.add_trace()`,并用 `row` 和 `column` 参数设置好对应的子图位置。\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x", + "y": [ + 10, + 11, + 12, + 13 + ], + "yaxis": "y" + }, + { + "mode": "lines", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x2", + "y": [ + 5, + 4, + 3, + 2 + ], + "yaxis": "y2" + } + ], + "layout": { + "annotations": [ + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 1", + "x": 0.225, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + }, + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 2", + "x": 0.775, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + } + ], + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Multiple Subplots" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 0.45 + ] + }, + "xaxis2": { + "anchor": "y2", + "domain": [ + 0.55, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ] + }, + "yaxis2": { + "anchor": "x2", + "domain": [ + 0, + 1 + ] + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import plotly.subplots as sp\n", + "\n", + "# 创建包含两个子图的图表\n", + "fig = sp.make_subplots(rows=1, cols=2, subplot_titles=['Subplot 1', 'Subplot 2'])\n", + "\n", + "# 子图1 - 散点图\n", + "scatter_trace = go.Scatter(x=[1, 2, 3, 4], y=[10, 11, 12, 13], mode='markers')\n", + "fig.add_trace(scatter_trace, row=1, col=1)\n", + "\n", + "# 子图2 - 折线图\n", + "line_trace = go.Scatter(x=[1, 2, 3, 4], y=[5, 4, 3, 2], mode='lines')\n", + "fig.add_trace(line_trace, row=1, col=2)\n", + "\n", + "# 更新布局信息\n", + "fig.update_layout(title='Multiple Subplots')\n", + "\n", + "# 显示图表\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 布局 `Layout`\n", + "`Layout` 是图形的外观和样式的控制元素, `layout` 对象包含在 `Figure` 对象中,通常通过设置 `.update_layout()` 来调整图形的布局,一张图可以多次调整,即可以多次使用该函数。常见的具体设置如下。\n", + "\n", + "### 修改标题 \n", + "\n", + "使用 `title` 参数设置新标题即可。\n", + "\n", + "例:将上面的 `Figure` 的标题改为 Subplots,并居中显示。\n", + "\n", + "```{note}\n", + "Plotly 中,图片标题不会默认居中,需要设置 `title_x=0.5` 来调整。\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x", + "y": [ + 10, + 11, + 12, + 13 + ], + "yaxis": "y" + }, + { + "mode": "lines", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x2", + "y": [ + 5, + 4, + 3, + 2 + ], + "yaxis": "y2" + } + ], + "layout": { + "annotations": [ + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 1", + "x": 0.225, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + }, + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 2", + "x": 0.775, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + } + ], + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Subplots", + "x": 0.5 + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 0.45 + ] + }, + "xaxis2": { + "anchor": "y2", + "domain": [ + 0.55, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ] + }, + "yaxis2": { + "anchor": "x2", + "domain": [ + 0, + 1 + ] + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.update_layout(title='Subplots', title_x=0.5)\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 设置图例 `Legend`\n", + "\n", + "使用 `.update_layout()` 方法的 `showlegend` 参数,设置为 True 则显示图例, False 则不显示,默认为True。在一个图上有多条轨迹 `trace` 时可以更清楚地反映数据。\n", + "\n", + "例:将上面的 `Figure` 默认的图例删除。\n" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x", + "y": [ + 10, + 11, + 12, + 13 + ], + "yaxis": "y" + }, + { + "mode": "lines", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x2", + "y": [ + 5, + 4, + 3, + 2 + ], + "yaxis": "y2" + } + ], + "layout": { + "annotations": [ + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 1", + "x": 0.225, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + }, + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 2", + "x": 0.775, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + } + ], + "showlegend": false, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "showlakes": true, + "showland": true, + "subunitcolor": "#506784" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "dark" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, + "ternary": { + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Subplots", + "x": 0.5 + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 0.45 + ] + }, + "xaxis2": { + "anchor": "y2", + "domain": [ + 0.55, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ] + }, + "yaxis2": { + "anchor": "x2", + "domain": [ + 0, + 1 + ] + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.update_layout(showlegend=False)\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 设置轴标题\n", + "\n", + "`xaxis_title` 和 `yaxis_title` 参数分别用于设置 X 轴和 Y 轴的标题;也可以使用 `.update_xaxes()` 和 `.update_yaxes()` 方法,传入 `title_text` 参数设置标题。\n", + "\n", + "如果图形包含多个子图(subplots),可以使用 `update_layout` 方法来设置整体布局的属性,而使用 `.update_xaxes()` 和 `.update_yaxes()` 方法来设置每个子图的轴标题。\n", + "\n", + "例:分别设置上面 `Figure` 的两个子图的横轴标题和纵轴标题。" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x", + "y": [ + 10, + 11, + 12, + 13 + ], + "yaxis": "y" + }, + { + "mode": "lines", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x2", + "y": [ + 5, + 4, + 3, + 2 + ], + "yaxis": "y2" + } + ], + "layout": { + "annotations": [ + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 1", + "x": 0.225, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + }, + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 2", + "x": 0.775, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + } + ], + "height": 400, + "showlegend": false, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "showlakes": true, + "showland": true, + "subunitcolor": "#506784" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "dark" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, + "ternary": { + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Subplots", + "x": 0.5 + }, + "width": 600, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 0.45 + ], + "title": { + "text": "X1轴标题" + } + }, + "xaxis2": { + "anchor": "y2", + "domain": [ + 0.55, + 1 + ], + "title": { + "text": "X2轴标题" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Y1轴标题" + } + }, + "yaxis2": { + "anchor": "x2", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Y2轴标题" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# 设置子图1的轴标题\n", + "fig.update_xaxes(title_text='X1轴标题', row=1, col=1)\n", + "fig.update_yaxes(title_text='Y1轴标题', row=1, col=1)\n", + "\n", + "# 设置子图2的轴标题\n", + "fig.update_xaxes(title_text='X2轴标题', row=1, col=2)\n", + "fig.update_yaxes(title_text='Y2轴标题', row=1, col=2)\n", + "\n", + "# 显示图形\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 设置模版 `template`\n", + "`template` 参数用于设置图形布局的模板,这可以应用特定的风格和主题。常用的参数选择有:\n", + "- \"plotly\" (默认): 默认模板,采用 Plotly 经典的白色背景和颜色样式。\n", + "- \"plotly_dark\": 深色主题的模板,适合在暗色环境中查看。\n", + "- \"ggplot2\": 类似于 R 语言中的 ggplot2 图形系统的模板,采用灰色背景。\n", + "- \"seaborn\": 模拟 seaborn Python 库的外观,具有淡蓝色的背景和灰色网格线。\n", + "- \"simple_white\": 简单的白色背景,适用于注重简洁性的图形。\n", + "- \"plotly_white\": 与 \"plotly\" 模板类似,采用白色背景,但可能有轻微差异。\n", + "\n", + "例:对上面的 `Figure` 使用深色主题。\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x", + "y": [ + 10, + 11, + 12, + 13 + ], + "yaxis": "y" + }, + { + "mode": "lines", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x2", + "y": [ + 5, + 4, + 3, + 2 + ], + "yaxis": "y2" + } + ], + "layout": { + "annotations": [ + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 1", + "x": 0.225, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + }, + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 2", + "x": 0.775, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + } + ], + "showlegend": false, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "showlakes": true, + "showland": true, + "subunitcolor": "#506784" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "dark" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, + "ternary": { + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Subplots", + "x": 0.5 + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 0.45 + ] + }, + "xaxis2": { + "anchor": "y2", + "domain": [ + 0.55, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ] + }, + "yaxis2": { + "anchor": "x2", + "domain": [ + 0, + 1 + ] + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.update_layout(template='plotly_dark')\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 设置图片大小\n", + "可以使用 `height` 和 `width` 参数来指定图形的高度和宽度。\n", + "\n", + "例:修改上面 `Figure` 的高度和宽度。" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "markers", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x", + "y": [ + 10, + 11, + 12, + 13 + ], + "yaxis": "y" + }, + { + "mode": "lines", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "xaxis": "x2", + "y": [ + 5, + 4, + 3, + 2 + ], + "yaxis": "y2" + } + ], + "layout": { + "annotations": [ + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 1", + "x": 0.225, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + }, + { + "font": { + "size": 16 + }, + "showarrow": false, + "text": "Subplot 2", + "x": 0.775, + "xanchor": "center", + "xref": "paper", + "y": 1, + "yanchor": "bottom", + "yref": "paper" + } + ], + "height": 400, + "showlegend": false, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "showlakes": true, + "showland": true, + "subunitcolor": "#506784" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "dark" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, + "ternary": { + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Subplots", + "x": 0.5 + }, + "width": 600, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 0.45 + ] + }, + "xaxis2": { + "anchor": "y2", + "domain": [ + 0.55, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ] + }, + "yaxis2": { + "anchor": "x2", + "domain": [ + 0, + 1 + ] + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.update_layout(\n", + " height=400, # 设置图形高度\n", + " width=600 # 设置图形宽度\n", + ")\n", + "fig.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pyds", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ch-plotly/financialcharts.ipynb b/ch-plotly/financialcharts.ipynb new file mode 100644 index 0000000..2233bf9 --- /dev/null +++ b/ch-plotly/financialcharts.ipynb @@ -0,0 +1,7781 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 金融图表" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import plotly.graph_objects as go\n", + "#import plotly.express as px\n", + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "Plotly 的金融图表库提供了丰富的功能,可以用于分析和可视化金融数据。本小节介绍一些基本的经济金融相关图表。\n", + "\n", + "## 蜡烛图\n", + "\n", + "蜡烛图是一种用于展示股票或其他金融资产价格的图表类型。每个蜡烛表示一段时间内的开盘价、收盘价、最高价和最低价,股市的k线图就是一个蜡烛图。Plotly 的 `candlestick` 函数可用于创建这种类型的图表。参数有:\n", + "\n", + "- x: x 轴上的数据。通常是时间轴上的日期数据,表示蜡烛图中每个蜡烛的位置。\n", + "- `open`: 每个蜡烛的开盘价数据。\n", + "- `high`: 每个蜡烛的最高价数据。\n", + "- `low`: 每个蜡烛的最低价数据。\n", + "- `close`: 每个蜡烛的收盘价数据。\n", + "\n", + "日内收盘价高于开盘价则绿色,反之蜡烛图显示为红色。还可以在 `.update_layout` 中设置 `xaxis_rangeslider_visible` 参数决定是否有时间区间的滑块,设置为 False 则不显示滑块,默认为显示。\n", + "\n", + "例:作出苹果公司(AAPL)2015-2917年股市的蜡烛图。数据包含了每日的开盘价、最高价、最低价和收盘价。作图后,可以通过交互按钮放大特定时间区间的具体表现。\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "close": [ + 127.830002, + 128.720001, + 128.449997, + 129.5, + 133, + 132.169998, + 128.789993, + 130.419998, + 128.460007, + 129.089996, + 129.360001, + 128.539993, + 126.410004, + 126.599998, + 127.139999, + 124.510002, + 122.239998, + 124.449997, + 123.589996, + 124.949997, + 127.040001, + 128.470001, + 127.5, + 125.900002, + 127.209999, + 126.690002, + 123.379997, + 124.239998, + 123.25, + 126.370003, + 124.43, + 124.25, + 125.32, + 127.349998, + 126.010002, + 125.599998, + 126.559998, + 127.099998, + 126.849998, + 126.300003, + 126.779999, + 126.169998, + 124.75, + 127.599998, + 126.910004, + 128.619995, + 129.669998, + 130.279999, + 132.649994, + 130.559998, + 128.639999, + 125.150002, + 128.949997, + 128.699997, + 125.800003, + 125.010002, + 125.260002, + 127.620003, + 126.32, + 125.870003, + 126.010002, + 128.949997, + 128.770004, + 130.190002, + 130.070007, + 130.059998, + 131.389999, + 132.539993, + 129.619995, + 132.039993, + 131.779999, + 130.279999, + 130.539993, + 129.960007, + 130.119995, + 129.360001, + 128.649994, + 127.800003, + 127.419998, + 128.880005, + 128.589996, + 127.169998, + 126.919998, + 127.599998, + 127.300003, + 127.879997, + 126.599998, + 127.610001, + 127.029999, + 128.110001, + 127.5, + 126.75, + 124.529999, + 125.43, + 126.599998, + 126.440002, + 126, + 125.690002, + 122.57, + 120.07, + 123.279999, + 125.660004, + 125.610001, + 126.82, + 128.509995, + 129.619995, + 132.070007, + 130.75, + 125.220001, + 125.160004, + 124.5, + 122.769997, + 123.379997, + 122.989998, + 122.370003, + 121.300003, + 118.440002, + 114.639999, + 115.400002, + 115.129997, + 115.519997, + 119.720001, + 113.489998, + 115.239998, + 115.150002, + 115.959999, + 117.160004, + 116.5, + 115.010002, + 112.650002, + 105.760002, + 103.120003, + 103.739998, + 109.690002, + 112.919998, + 113.290001, + 112.760002, + 107.720001, + 112.339996, + 110.370003, + 109.269997, + 112.309998, + 110.150002, + 112.57, + 114.209999, + 115.309998, + 116.279999, + 116.410004, + 113.919998, + 113.449997, + 115.209999, + 113.400002, + 114.32, + 115, + 114.709999, + 112.440002, + 109.059998, + 110.300003, + 109.580002, + 110.379997, + 110.779999, + 111.309998, + 110.779999, + 109.5, + 112.120003, + 111.599998, + 111.790001, + 110.209999, + 111.860001, + 111.040001, + 111.730003, + 113.769997, + 113.760002, + 115.5, + 119.080002, + 115.279999, + 114.550003, + 119.269997, + 120.529999, + 119.5, + 121.18, + 122.57, + 122, + 120.919998, + 121.059998, + 120.57, + 116.769997, + 116.110001, + 115.720001, + 112.339996, + 114.18, + 113.690002, + 117.290001, + 118.779999, + 119.300003, + 117.75, + 118.879997, + 118.029999, + 117.809998, + 118.300003, + 117.339996, + 116.279999, + 115.199997, + 119.029999, + 118.279999, + 118.230003, + 115.620003, + 116.169998, + 113.18, + 112.480003, + 110.489998, + 111.339996, + 108.980003, + 106.029999, + 107.330002, + 107.230003, + 108.610001, + 108.029999, + 106.82, + 108.739998, + 107.32, + 105.260002, + 105.349998, + 102.709999, + 100.699997, + 96.449997, + 96.959999, + 98.529999, + 99.959999, + 97.389999, + 99.519997, + 97.129997, + 96.660004, + 96.790001, + 96.300003, + 101.419998, + 99.440002, + 99.989998, + 93.419998, + 94.089996, + 97.339996, + 96.43, + 94.480003, + 96.349998, + 96.599998, + 94.019997, + 95.010002, + 94.989998, + 94.269997, + 93.699997, + 93.989998, + 96.639999, + 98.120003, + 96.260002, + 96.040001, + 96.879997, + 94.690002, + 96.099998, + 96.760002, + 96.910004, + 96.690002, + 100.529999, + 100.75, + 101.5, + 103.010002, + 101.870003, + 101.029999, + 101.120003, + 101.169998, + 102.260002, + 102.519997, + 104.580002, + 105.970001, + 105.800003, + 105.919998, + 105.910004, + 106.720001, + 106.129997, + 105.669998, + 105.190002, + 107.68, + 109.559998, + 108.989998, + 109.989998, + 111.120003, + 109.809998, + 110.959999, + 108.540001, + 108.660004, + 109.019997, + 110.440002, + 112.040001, + 112.099998, + 109.849998, + 107.480003, + 106.910004, + 107.129997, + 105.970001, + 105.68, + 105.080002, + 104.349998, + 97.82, + 94.830002, + 93.739998, + 93.639999, + 95.18, + 94.190002, + 93.239998, + 92.720001, + 92.790001, + 93.419998, + 92.510002, + 90.339996, + 90.519997, + 93.879997, + 93.489998, + 94.559998, + 94.199997, + 95.220001, + 96.43, + 97.900002, + 99.620003, + 100.410004, + 100.349998, + 99.860001, + 98.459999, + 97.720001, + 97.919998, + 98.629997, + 99.029999, + 98.940002, + 99.650002, + 98.830002, + 97.339996, + 97.459999, + 97.139999, + 97.550003, + 95.330002, + 95.099998, + 95.910004, + 95.550003, + 96.099998, + 93.400002, + 92.040001, + 93.589996, + 94.400002, + 95.599998, + 95.889999, + 94.989998, + 95.529999, + 95.940002, + 96.68, + 96.980003, + 97.419998, + 96.870003, + 98.790001, + 98.779999, + 99.830002, + 99.870003, + 99.959999, + 99.43, + 98.660004, + 97.339996, + 96.669998, + 102.949997, + 104.339996, + 104.209999, + 106.050003, + 104.480003, + 105.790001, + 105.870003, + 107.480003, + 108.370003, + 108.809998, + 108, + 107.93, + 108.18, + 109.480003, + 109.379997, + 109.220001, + 109.080002, + 109.360001, + 108.510002, + 108.849998, + 108.029999, + 107.57, + 106.940002, + 106.82, + 106, + 106.099998, + 106.730003, + 107.730003, + 107.699997, + 108.360001, + 105.519997, + 103.129997, + 105.440002, + 107.949997, + 111.769997, + 115.57, + 114.919998, + 113.580002, + 113.57, + 113.550003, + 114.620003, + 112.709999, + 112.879997, + 113.089996, + 113.949997, + 112.18, + 113.050003, + 112.519997, + 113, + 113.050003, + 113.889999, + 114.059998, + 116.050003, + 116.300003, + 117.339996, + 116.980003, + 117.629997, + 117.550003, + 117.470001, + 117.120003, + 117.059998, + 116.599998, + 117.650002, + 118.25, + 115.589996, + 114.480003, + 113.720001, + 113.540001, + 111.489998, + 111.589996, + 109.830002, + 108.839996, + 110.410004, + 111.059998, + 110.879997, + 107.790001, + 108.43, + 105.709999, + 107.110001, + 109.989998, + 109.949997, + 110.059998, + 111.730003, + 111.800003, + 111.230003, + 111.790001, + 111.57, + 111.459999, + 110.519997, + 109.489998, + 109.900002, + 109.110001, + 109.949997, + 111.029999, + 112.120003, + 113.949997, + 113.300003, + 115.190002, + 115.190002, + 115.82, + 115.970001, + 116.639999, + 116.949997, + 117.059998, + 116.290001, + 116.519997, + 117.260002, + 116.760002, + 116.730003, + 115.82, + 116.150002, + 116.019997, + 116.610001, + 117.910004, + 118.989998, + 119.110001, + 119.75, + 119.25, + 119.040001, + 120, + 119.989998, + 119.779999, + 120, + 120.080002, + 119.970001, + 121.879997, + 121.940002, + 121.949997, + 121.629997, + 121.349998, + 128.75, + 128.529999, + 129.080002, + 130.289993, + 131.529999, + 132.039993, + 132.419998, + 132.119995, + 133.289993, + 135.020004, + 135.509995, + 135.350006 + ], + "high": [ + 128.880005, + 128.779999, + 129.029999, + 129.5, + 133, + 133.600006, + 131.600006, + 130.869995, + 130.570007, + 130.279999, + 129.520004, + 129.559998, + 128.75, + 129.369995, + 129.570007, + 127.220001, + 124.769997, + 124.900002, + 125.400002, + 124.949997, + 127.32, + 129.160004, + 129.25, + 128.399994, + 127.849998, + 128.039993, + 126.82, + 124.879997, + 124.699997, + 126.400002, + 126.489998, + 125.120003, + 125.559998, + 127.510002, + 128.119995, + 126.400002, + 126.580002, + 127.209999, + 128.570007, + 127.290001, + 127.129997, + 127.099998, + 126.139999, + 128.119995, + 128.199997, + 128.869995, + 130.419998, + 130.630005, + 133.130005, + 134.539993, + 131.589996, + 128.639999, + 130.130005, + 130.570007, + 128.449997, + 126.75, + 126.080002, + 127.620003, + 127.559998, + 126.879997, + 127.190002, + 128.949997, + 129.490005, + 130.720001, + 130.880005, + 130.979996, + 131.630005, + 132.970001, + 132.910004, + 132.259995, + 131.949997, + 131.449997, + 131.389999, + 130.660004, + 130.940002, + 130.580002, + 129.690002, + 129.210007, + 128.080002, + 129.339996, + 130.179993, + 128.330002, + 127.239998, + 127.849998, + 127.879997, + 128.309998, + 127.82, + 128.059998, + 127.610001, + 129.800003, + 129.199997, + 127.989998, + 126.470001, + 126.120003, + 126.940002, + 126.690002, + 126.230003, + 126.150002, + 124.639999, + 124.059998, + 123.849998, + 125.760002, + 126.370003, + 127.150002, + 128.570007, + 129.619995, + 132.970001, + 132.919998, + 125.5, + 127.089996, + 125.739998, + 123.610001, + 123.910004, + 123.5, + 122.57, + 122.639999, + 122.57, + 117.699997, + 117.440002, + 116.5, + 116.25, + 119.989998, + 118.18, + 115.419998, + 116.400002, + 116.309998, + 117.650002, + 117.440002, + 116.519997, + 114.349998, + 111.900002, + 108.800003, + 111.110001, + 109.889999, + 113.239998, + 113.309998, + 114.529999, + 111.879997, + 112.339996, + 112.779999, + 110.449997, + 112.559998, + 114.019997, + 113.279999, + 114.209999, + 116.889999, + 116.529999, + 116.540001, + 116.489998, + 114.300003, + 115.370003, + 114.18, + 114.720001, + 115.5, + 116.690002, + 114.57, + 113.510002, + 111.540001, + 109.620003, + 111.010002, + 111.370003, + 111.739998, + 111.769997, + 110.190002, + 112.279999, + 112.75, + 112.449997, + 111.519997, + 112.099998, + 112, + 111.75, + 114.169998, + 115.580002, + 115.5, + 119.230003, + 118.129997, + 116.540001, + 119.300003, + 120.690002, + 121.220001, + 121.360001, + 123.489998, + 123.82, + 122.690002, + 121.809998, + 121.809998, + 118.07, + 117.419998, + 116.82, + 115.57, + 114.239998, + 115.050003, + 117.489998, + 119.75, + 119.919998, + 119.730003, + 119.349998, + 119.230003, + 118.410004, + 119.410004, + 118.809998, + 118.110001, + 116.790001, + 119.25, + 119.860001, + 118.599998, + 117.690002, + 116.940002, + 115.389999, + 112.68, + 112.800003, + 111.989998, + 112.25, + 109.519997, + 107.370003, + 107.720001, + 108.849998, + 109, + 107.690002, + 109.43, + 108.699997, + 107.029999, + 105.370003, + 105.849998, + 102.370003, + 100.129997, + 99.110001, + 99.059998, + 100.690002, + 101.190002, + 100.480003, + 97.709999, + 98.650002, + 98.190002, + 97.879997, + 101.459999, + 101.529999, + 100.879997, + 96.629997, + 94.519997, + 97.339996, + 96.709999, + 96.040001, + 96.839996, + 97.330002, + 96.919998, + 95.699997, + 95.940002, + 96.349998, + 94.720001, + 94.5, + 96.849998, + 98.209999, + 98.889999, + 96.760002, + 96.900002, + 96.5, + 96.379997, + 96.760002, + 98.019997, + 98.230003, + 100.769997, + 100.889999, + 101.709999, + 103.75, + 102.830002, + 101.760002, + 101.580002, + 102.239998, + 102.279999, + 102.910004, + 105.18, + 106.309998, + 106.470001, + 106.5, + 107.650002, + 107.290001, + 107.07, + 106.25, + 106.190002, + 107.790001, + 110.419998, + 109.900002, + 110, + 112.190002, + 110.730003, + 110.980003, + 110.419998, + 109.769997, + 110.610001, + 110.5, + 112.339996, + 112.389999, + 112.300003, + 108.949997, + 108, + 108.089996, + 106.93, + 106.480003, + 105.650002, + 105.300003, + 98.709999, + 97.879997, + 94.720001, + 94.080002, + 95.739998, + 95.900002, + 94.07, + 93.449997, + 93.769997, + 93.57, + 93.57, + 92.779999, + 91.669998, + 94.389999, + 94.699997, + 95.209999, + 94.639999, + 95.43, + 97.190002, + 98.089996, + 99.739998, + 100.730003, + 100.470001, + 100.400002, + 99.540001, + 97.839996, + 98.269997, + 101.889999, + 99.870003, + 99.559998, + 99.989998, + 99.349998, + 99.120003, + 98.480003, + 98.410004, + 97.75, + 96.650002, + 96.57, + 96.349998, + 96.889999, + 96.290001, + 94.660004, + 93.050003, + 93.660004, + 94.550003, + 95.769997, + 96.470001, + 95.400002, + 95.660004, + 96.5, + 96.889999, + 97.650002, + 97.699997, + 97.669998, + 98.989998, + 99.300003, + 100.129997, + 100, + 100.459999, + 101, + 99.300003, + 98.839996, + 97.970001, + 104.349998, + 104.449997, + 104.550003, + 106.150002, + 106.07, + 105.839996, + 106, + 107.650002, + 108.370003, + 108.940002, + 108.900002, + 108.93, + 108.440002, + 109.540001, + 110.230003, + 109.370003, + 109.599998, + 109.690002, + 109.099998, + 109.32, + 108.75, + 107.879997, + 107.949997, + 107.440002, + 106.5, + 106.57, + 106.800003, + 108, + 108.300003, + 108.760002, + 107.269997, + 105.720001, + 105.720001, + 108.790001, + 113.029999, + 115.730003, + 116.129997, + 116.18, + 114.120003, + 113.989998, + 114.940002, + 114.790001, + 113.389999, + 113.18, + 114.639999, + 113.800003, + 113.370003, + 113.050003, + 114.309998, + 113.660004, + 114.339996, + 114.559998, + 116.75, + 118.690002, + 117.980003, + 117.440002, + 118.169998, + 117.839996, + 118.209999, + 117.760002, + 117.379997, + 116.910004, + 117.739998, + 118.360001, + 115.699997, + 115.860001, + 115.209999, + 114.230003, + 113.769997, + 112.349998, + 111.459999, + 110.25, + 110.510002, + 111.720001, + 111.32, + 111.089996, + 108.870003, + 107.809998, + 107.68, + 110.230003, + 110.349998, + 110.540001, + 111.989998, + 112.419998, + 111.510002, + 111.870003, + 112.470001, + 112.029999, + 112.199997, + 110.940002, + 110.089996, + 110.029999, + 110.360001, + 111.190002, + 112.43, + 114.699997, + 115, + 115.919998, + 116.199997, + 116.730003, + 116.5, + 117.379997, + 117.5, + 117.400002, + 116.510002, + 116.519997, + 117.800003, + 118.019997, + 117.110001, + 117.199997, + 116.330002, + 116.510002, + 116.860001, + 118.160004, + 119.43, + 119.379997, + 119.93, + 119.300003, + 119.620003, + 120.239998, + 120.5, + 120.089996, + 120.449997, + 120.809998, + 120.099998, + 122.099998, + 122.440002, + 122.349998, + 121.629997, + 121.389999, + 130.490005, + 129.389999, + 129.190002, + 130.5, + 132.089996, + 132.220001, + 132.449997, + 132.940002, + 133.820007, + 135.089996, + 136.270004, + 135.899994 + ], + "low": [ + 126.919998, + 127.449997, + 128.330002, + 128.050003, + 129.660004, + 131.169998, + 128.149994, + 126.610001, + 128.240005, + 128.300003, + 128.089996, + 128.320007, + 125.760002, + 126.260002, + 125.059998, + 123.800003, + 122.110001, + 121.629997, + 122.580002, + 122.870003, + 125.650002, + 126.370003, + 127.400002, + 125.160004, + 126.519997, + 126.559998, + 123.379997, + 122.599998, + 122.910004, + 124, + 124.360001, + 123.099998, + 124.190002, + 124.330002, + 125.980003, + 124.970001, + 124.660004, + 125.260002, + 126.610001, + 125.910004, + 126.010002, + 126.110001, + 124.459999, + 125.169998, + 126.669998, + 126.32, + 128.139999, + 129.229996, + 131.149994, + 129.570007, + 128.300003, + 124.580002, + 125.300003, + 128.259995, + 125.779999, + 123.360001, + 124.019997, + 126.110001, + 125.629997, + 124.82, + 125.870003, + 127.160004, + 128.210007, + 128.360001, + 129.639999, + 129.339996, + 129.830002, + 131.399994, + 129.119995, + 130.050003, + 131.100006, + 129.899994, + 130.050003, + 129.320007, + 129.899994, + 128.910004, + 128.360001, + 126.830002, + 125.620003, + 127.849998, + 128.479996, + 127.110001, + 125.709999, + 126.370003, + 126.739998, + 127.220001, + 126.400002, + 127.080002, + 126.879997, + 127.120003, + 127.5, + 126.510002, + 124.480003, + 124.860001, + 125.989998, + 125.769997, + 124.849998, + 123.769997, + 122.540001, + 119.220001, + 121.209999, + 124.32, + 125.040001, + 125.580002, + 127.349998, + 128.309998, + 130.699997, + 130.320007, + 121.989998, + 125.059998, + 123.900002, + 122.120003, + 122.550003, + 122.269997, + 121.709999, + 120.910004, + 117.519997, + 113.25, + 112.099998, + 114.120003, + 114.5, + 116.529999, + 113.330002, + 109.629997, + 114.540001, + 114.010002, + 115.5, + 116.010002, + 114.68, + 111.629997, + 105.650002, + 92, + 103.5, + 105.050003, + 110.019997, + 111.540001, + 112, + 107.360001, + 109.129997, + 110.040001, + 108.510002, + 110.32, + 109.769997, + 109.900002, + 111.760002, + 114.860001, + 114.419998, + 115.440002, + 113.720001, + 111.870003, + 113.660004, + 112.519997, + 113.300003, + 112.370003, + 114.019997, + 112.440002, + 107.860001, + 108.730003, + 107.309998, + 107.550003, + 109.07, + 109.769997, + 109.410004, + 108.209999, + 109.489998, + 111.440002, + 110.68, + 109.559998, + 110.489998, + 110.529999, + 110.110001, + 110.82, + 113.699997, + 114.099998, + 116.330002, + 114.919998, + 113.989998, + 116.059998, + 118.269997, + 119.449997, + 119.610001, + 120.699997, + 121.620003, + 120.18, + 120.620003, + 120.050003, + 116.059998, + 115.209999, + 115.650002, + 112.269997, + 111, + 113.32, + 115.5, + 116.760002, + 118.849998, + 117.339996, + 117.120003, + 117.919998, + 117.599998, + 117.75, + 116.860001, + 116.080002, + 114.220001, + 115.110001, + 117.809998, + 116.860001, + 115.080002, + 115.510002, + 112.849998, + 109.790001, + 110.349998, + 108.800003, + 108.980003, + 105.809998, + 105.57, + 106.449997, + 107.199997, + 107.949997, + 106.18, + 106.860001, + 107.18, + 104.82, + 102, + 102.410004, + 99.870003, + 96.43, + 96.760002, + 97.339996, + 98.839996, + 97.300003, + 95.739998, + 95.360001, + 95.5, + 93.419998, + 94.940002, + 98.370003, + 99.209999, + 98.07, + 93.339996, + 92.389999, + 94.349998, + 95.400002, + 94.279999, + 94.080002, + 95.190002, + 93.690002, + 93.040001, + 93.93, + 94.099998, + 92.589996, + 93.010002, + 94.610001, + 96.150002, + 96.089996, + 95.800003, + 95.919998, + 94.550003, + 93.32, + 95.25, + 96.580002, + 96.650002, + 97.419998, + 99.639999, + 100.449997, + 101.370003, + 100.959999, + 100.400002, + 100.269997, + 100.150002, + 101.5, + 101.779999, + 103.849998, + 104.589996, + 104.959999, + 105.190002, + 105.139999, + 105.209999, + 105.900002, + 104.889999, + 105.059998, + 104.879997, + 108.599998, + 108.879997, + 108.199997, + 110.269997, + 109.419998, + 109.199997, + 108.120003, + 108.169998, + 108.830002, + 108.660004, + 110.800003, + 111.330002, + 109.730003, + 106.940002, + 106.230003, + 106.059998, + 105.519997, + 104.620003, + 104.510002, + 103.910004, + 95.68, + 94.25, + 92.510002, + 92.400002, + 93.68, + 93.82, + 92.68, + 91.849998, + 92.589996, + 92.110001, + 92.459999, + 89.470001, + 90, + 91.650002, + 93.010002, + 93.889999, + 93.57, + 94.519997, + 95.669998, + 96.839996, + 98.110001, + 98.639999, + 99.25, + 98.82, + 98.330002, + 96.629997, + 97.449997, + 97.550003, + 98.959999, + 98.68, + 98.459999, + 98.480003, + 97.099998, + 96.75, + 97.029999, + 96.07, + 95.300003, + 95.029999, + 94.68, + 95.349998, + 95.25, + 92.650002, + 91.5, + 92.139999, + 93.629997, + 94.300003, + 95.330002, + 94.459999, + 94.370003, + 95.620003, + 96.050003, + 96.730003, + 97.120003, + 96.839996, + 97.32, + 98.5, + 98.599998, + 99.339996, + 99.739998, + 99.129997, + 98.309998, + 96.919998, + 96.419998, + 102.75, + 102.82, + 103.68, + 104.410004, + 104, + 104.769997, + 105.279999, + 106.18, + 107.160004, + 108.010002, + 107.760002, + 107.849998, + 107.779999, + 108.080002, + 109.209999, + 108.339996, + 109.019997, + 108.360001, + 107.849998, + 108.529999, + 107.68, + 106.68, + 106.309998, + 106.290001, + 105.5, + 105.639999, + 105.620003, + 106.82, + 107.510002, + 107.07, + 105.239998, + 103.129997, + 102.529999, + 107.239998, + 108.599998, + 113.489998, + 114.040001, + 113.25, + 112.510002, + 112.440002, + 114, + 111.550003, + 111.550003, + 112.339996, + 113.43, + 111.800003, + 111.800003, + 112.279999, + 112.629997, + 112.690002, + 113.129997, + 113.510002, + 114.720001, + 116.199997, + 116.75, + 115.720001, + 117.129997, + 116.779999, + 117.449997, + 113.800003, + 116.330002, + 116.279999, + 117, + 117.309998, + 113.309998, + 114.099998, + 113.449997, + 113.199997, + 110.529999, + 111.230003, + 109.550003, + 108.110001, + 109.459999, + 109.699997, + 108.050003, + 105.830002, + 106.550003, + 104.080002, + 106.160004, + 106.599998, + 108.830002, + 109.660004, + 110.010002, + 111.400002, + 110.330002, + 110.949997, + 111.389999, + 110.07, + 110.269997, + 109.029999, + 108.849998, + 108.25, + 109.190002, + 109.160004, + 110.599998, + 112.309998, + 112.489998, + 113.75, + 114.980003, + 115.230003, + 115.650002, + 115.75, + 116.68, + 116.779999, + 115.639999, + 115.589996, + 116.489998, + 116.199997, + 116.400002, + 115.43, + 114.760002, + 115.75, + 115.809998, + 116.470001, + 117.940002, + 118.300003, + 118.599998, + 118.209999, + 118.809998, + 118.220001, + 119.709999, + 119.370003, + 119.730003, + 119.769997, + 119.5, + 120.279999, + 121.599998, + 121.599998, + 120.660004, + 120.620003, + 127.010002, + 127.779999, + 128.160004, + 128.899994, + 130.449997, + 131.220001, + 131.119995, + 132.050003, + 132.75, + 133.25, + 134.619995, + 134.839996 + ], + "open": [ + 127.489998, + 127.629997, + 128.479996, + 128.619995, + 130.020004, + 132.940002, + 131.559998, + 128.789993, + 130, + 129.25, + 128.960007, + 129.100006, + 128.580002, + 128.399994, + 127.959999, + 126.410004, + 124.75, + 122.309998, + 124.400002, + 123.879997, + 125.900002, + 127, + 128.75, + 128.25, + 127.120003, + 127.230003, + 126.540001, + 122.760002, + 124.57, + 124.050003, + 126.089996, + 124.82, + 125.029999, + 124.470001, + 127.639999, + 125.849998, + 125.849998, + 125.949997, + 128.369995, + 127, + 126.410004, + 126.279999, + 125.550003, + 125.57, + 128.100006, + 126.989998, + 128.300003, + 130.490005, + 132.309998, + 134.460007, + 130.160004, + 128.639999, + 126.099998, + 129.5, + 128.149994, + 126.559998, + 124.769997, + 126.68, + 127.389999, + 125.599998, + 126.150002, + 127.410004, + 129.070007, + 128.380005, + 130.690002, + 130, + 130.070007, + 131.600006, + 132.600006, + 130.339996, + 131.860001, + 131.229996, + 130.279999, + 129.860001, + 130.660004, + 129.580002, + 129.5, + 128.899994, + 126.699997, + 127.919998, + 129.179993, + 128.190002, + 126.099998, + 127.029999, + 127.720001, + 127.230003, + 127.709999, + 127.489998, + 127.480003, + 127.209999, + 128.860001, + 127.669998, + 125.459999, + 125.57, + 126.900002, + 126.43, + 124.940002, + 125.889999, + 124.480003, + 123.849998, + 121.940002, + 125.029999, + 126.040001, + 125.720001, + 127.739998, + 129.080002, + 130.970001, + 132.850006, + 121.989998, + 126.199997, + 125.32, + 123.089996, + 123.379997, + 123.150002, + 122.32, + 122.599998, + 121.5, + 117.419998, + 112.949997, + 115.970001, + 114.580002, + 116.529999, + 117.809998, + 112.529999, + 116.040001, + 114.32, + 116.040001, + 116.43, + 116.099998, + 114.080002, + 110.43, + 94.870003, + 111.110001, + 107.089996, + 112.230003, + 112.169998, + 112.029999, + 110.150002, + 110.230003, + 112.489998, + 108.970001, + 111.75, + 113.760002, + 110.269997, + 111.790001, + 116.580002, + 115.93, + 116.25, + 115.660004, + 112.209999, + 113.669998, + 113.379997, + 113.629997, + 113.25, + 116.440002, + 113.849998, + 112.830002, + 110.169998, + 109.07, + 108.010002, + 109.879997, + 110.629997, + 111.739998, + 110.190002, + 110, + 112.730003, + 110.82, + 111.290001, + 110.93, + 111.779999, + 110.800003, + 111.339996, + 114, + 114.330002, + 116.699997, + 118.080002, + 115.400002, + 116.93, + 118.699997, + 120.989998, + 120.800003, + 120.790001, + 123.129997, + 121.849998, + 121.110001, + 120.959999, + 116.900002, + 116.370003, + 116.260002, + 115.199997, + 111.379997, + 114.919998, + 115.760002, + 117.639999, + 119.199997, + 119.269997, + 117.330002, + 119.209999, + 118.290001, + 117.989998, + 118.75, + 117.339996, + 116.550003, + 115.290001, + 118.980003, + 117.519997, + 117.639999, + 116.040001, + 115.190002, + 112.18, + 111.940002, + 111.07, + 112.019997, + 108.910004, + 107.279999, + 107.400002, + 107.269997, + 109, + 107.589996, + 106.959999, + 108.580002, + 107.010002, + 102.610001, + 105.75, + 100.559998, + 98.68, + 98.550003, + 98.970001, + 100.550003, + 100.32, + 97.959999, + 96.199997, + 98.410004, + 95.099998, + 97.059998, + 98.629997, + 101.519997, + 99.93, + 96.040001, + 93.790001, + 94.790001, + 96.470001, + 95.419998, + 95, + 95.860001, + 96.519997, + 93.129997, + 94.290001, + 95.919998, + 93.790001, + 94.190002, + 95.019997, + 96.669998, + 98.839996, + 96, + 96.309998, + 96.400002, + 93.980003, + 96.050003, + 97.199997, + 96.860001, + 97.650002, + 100.510002, + 100.580002, + 102.370003, + 102.389999, + 100.779999, + 101.309998, + 101.410004, + 102.239998, + 101.910004, + 103.959999, + 104.610001, + 105.519997, + 106.339996, + 105.93, + 105.25, + 106.480003, + 105.470001, + 106, + 104.889999, + 108.650002, + 109.720001, + 108.779999, + 110.419998, + 109.510002, + 110.230003, + 109.949997, + 108.910004, + 108.970001, + 109.339996, + 110.800003, + 111.620003, + 112.110001, + 108.889999, + 107.879997, + 106.639999, + 106.93, + 105.010002, + 105, + 103.910004, + 96, + 97.610001, + 93.989998, + 93.970001, + 94.199997, + 95.199997, + 94, + 93.370003, + 93, + 93.330002, + 93.480003, + 92.720001, + 90, + 92.389999, + 94.550003, + 94.160004, + 94.639999, + 94.639999, + 95.870003, + 97.220001, + 98.669998, + 99.68, + 99.440002, + 99.599998, + 99.019997, + 97.599998, + 97.790001, + 97.989998, + 99.25, + 99.019997, + 98.5, + 98.529999, + 98.690002, + 97.32, + 97.82, + 96.449997, + 96.620003, + 96, + 94.940002, + 96.25, + 95.940002, + 92.910004, + 93, + 92.900002, + 93.970001, + 94.440002, + 95.489998, + 95.389999, + 94.599998, + 95.699997, + 96.489998, + 96.75, + 97.169998, + 97.410004, + 97.389999, + 98.919998, + 98.699997, + 99.559998, + 100, + 99.830002, + 99.260002, + 98.25, + 96.82, + 104.269997, + 102.830002, + 104.190002, + 104.410004, + 106.050003, + 104.809998, + 105.580002, + 106.269997, + 107.519997, + 108.230003, + 108.709999, + 108.519997, + 107.779999, + 108.139999, + 109.629997, + 109.099998, + 109.230003, + 108.769997, + 108.860001, + 108.589996, + 108.57, + 107.389999, + 107.410004, + 106.620003, + 105.800003, + 105.660004, + 106.139999, + 107.699997, + 107.900002, + 107.830002, + 107.25, + 104.639999, + 102.650002, + 107.510002, + 108.730003, + 113.860001, + 115.120003, + 115.190002, + 113.050003, + 113.849998, + 114.349998, + 114.419998, + 111.639999, + 113, + 113.690002, + 113.160004, + 112.459999, + 112.709999, + 113.059998, + 113.400002, + 113.699997, + 114.309998, + 115.019997, + 117.699997, + 117.349998, + 116.790001, + 117.879997, + 117.330002, + 118.18, + 117.25, + 116.860001, + 116.809998, + 117.099998, + 117.949997, + 114.309998, + 115.389999, + 113.870003, + 113.650002, + 113.459999, + 111.400002, + 110.980003, + 108.529999, + 110.080002, + 110.309998, + 109.879997, + 111.089996, + 107.120003, + 107.709999, + 106.57, + 106.699997, + 109.809998, + 109.720001, + 110.120003, + 111.949997, + 111.360001, + 111.129997, + 111.43, + 110.779999, + 111.599998, + 110.370003, + 109.169998, + 110, + 109.5, + 109.260002, + 110.860001, + 112.309998, + 113.290001, + 113.839996, + 115.040001, + 115.379997, + 116.470001, + 115.800003, + 116.739998, + 116.800003, + 116.349998, + 115.589996, + 116.519997, + 117.519997, + 116.449997, + 116.650002, + 115.800003, + 115.849998, + 115.919998, + 116.779999, + 117.949997, + 118.769997, + 118.739998, + 118.900002, + 119.110001, + 118.339996, + 120, + 119.400002, + 120.449997, + 120, + 119.550003, + 120.419998, + 121.669998, + 122.139999, + 120.93, + 121.150002, + 127.029999, + 127.980003, + 128.309998, + 129.130005, + 130.539993, + 131.350006, + 131.649994, + 132.460007, + 133.080002, + 133.470001, + 135.520004, + 135.669998 + ], + "type": "candlestick", + "x": [ + "2015-02-17", + "2015-02-18", + "2015-02-19", + "2015-02-20", + "2015-02-23", + "2015-02-24", + "2015-02-25", + "2015-02-26", + "2015-02-27", + "2015-03-02", + "2015-03-03", + "2015-03-04", + "2015-03-05", + "2015-03-06", + "2015-03-09", + "2015-03-10", + "2015-03-11", + "2015-03-12", + "2015-03-13", + "2015-03-16", + "2015-03-17", + "2015-03-18", + "2015-03-19", + "2015-03-20", + "2015-03-23", + "2015-03-24", + "2015-03-25", + "2015-03-26", + "2015-03-27", + "2015-03-30", + "2015-03-31", + "2015-04-01", + "2015-04-02", + "2015-04-06", + "2015-04-07", + "2015-04-08", + "2015-04-09", + "2015-04-10", + "2015-04-13", + "2015-04-14", + "2015-04-15", + "2015-04-16", + "2015-04-17", + "2015-04-20", + "2015-04-21", + "2015-04-22", + "2015-04-23", + "2015-04-24", + "2015-04-27", + "2015-04-28", + "2015-04-29", + "2015-04-30", + "2015-05-01", + "2015-05-04", + "2015-05-05", + "2015-05-06", + "2015-05-07", + "2015-05-08", + "2015-05-11", + "2015-05-12", + "2015-05-13", + "2015-05-14", + "2015-05-15", + "2015-05-18", + "2015-05-19", + "2015-05-20", + "2015-05-21", + "2015-05-22", + "2015-05-26", + "2015-05-27", + "2015-05-28", + "2015-05-29", + "2015-06-01", + "2015-06-02", + "2015-06-03", + "2015-06-04", + "2015-06-05", + "2015-06-08", + "2015-06-09", + "2015-06-10", + "2015-06-11", + "2015-06-12", + "2015-06-15", + "2015-06-16", + "2015-06-17", + "2015-06-18", + "2015-06-19", + "2015-06-22", + "2015-06-23", + "2015-06-24", + "2015-06-25", + "2015-06-26", + "2015-06-29", + "2015-06-30", + "2015-07-01", + "2015-07-02", + "2015-07-06", + "2015-07-07", + "2015-07-08", + "2015-07-09", + "2015-07-10", + "2015-07-13", + "2015-07-14", + "2015-07-15", + "2015-07-16", + "2015-07-17", + "2015-07-20", + "2015-07-21", + "2015-07-22", + "2015-07-23", + "2015-07-24", + "2015-07-27", + "2015-07-28", + "2015-07-29", + "2015-07-30", + "2015-07-31", + "2015-08-03", + "2015-08-04", + "2015-08-05", + "2015-08-06", + "2015-08-07", + "2015-08-10", + "2015-08-11", + "2015-08-12", + "2015-08-13", + "2015-08-14", + "2015-08-17", + "2015-08-18", + "2015-08-19", + "2015-08-20", + "2015-08-21", + "2015-08-24", + "2015-08-25", + "2015-08-26", + "2015-08-27", + "2015-08-28", + "2015-08-31", + "2015-09-01", + "2015-09-02", + "2015-09-03", + "2015-09-04", + "2015-09-08", + "2015-09-09", + "2015-09-10", + "2015-09-11", + "2015-09-14", + "2015-09-15", + "2015-09-16", + "2015-09-17", + "2015-09-18", + "2015-09-21", + "2015-09-22", + "2015-09-23", + "2015-09-24", + "2015-09-25", + "2015-09-28", + "2015-09-29", + "2015-09-30", + "2015-10-01", + "2015-10-02", + "2015-10-05", + "2015-10-06", + "2015-10-07", + "2015-10-08", + "2015-10-09", + "2015-10-12", + "2015-10-13", + "2015-10-14", + "2015-10-15", + "2015-10-16", + "2015-10-19", + "2015-10-20", + "2015-10-21", + "2015-10-22", + "2015-10-23", + "2015-10-26", + "2015-10-27", + "2015-10-28", + "2015-10-29", + "2015-10-30", + "2015-11-02", + "2015-11-03", + "2015-11-04", + "2015-11-05", + "2015-11-06", + "2015-11-09", + "2015-11-10", + "2015-11-11", + "2015-11-12", + "2015-11-13", + "2015-11-16", + "2015-11-17", + "2015-11-18", + "2015-11-19", + "2015-11-20", + "2015-11-23", + "2015-11-24", + "2015-11-25", + "2015-11-27", + "2015-11-30", + "2015-12-01", + "2015-12-02", + "2015-12-03", + "2015-12-04", + "2015-12-07", + "2015-12-08", + "2015-12-09", + "2015-12-10", + "2015-12-11", + "2015-12-14", + "2015-12-15", + "2015-12-16", + "2015-12-17", + "2015-12-18", + "2015-12-21", + "2015-12-22", + "2015-12-23", + "2015-12-24", + "2015-12-28", + "2015-12-29", + "2015-12-30", + "2015-12-31", + "2016-01-04", + "2016-01-05", + "2016-01-06", + "2016-01-07", + "2016-01-08", + "2016-01-11", + "2016-01-12", + "2016-01-13", + "2016-01-14", + "2016-01-15", + "2016-01-19", + "2016-01-20", + "2016-01-21", + "2016-01-22", + "2016-01-25", + "2016-01-26", + "2016-01-27", + "2016-01-28", + "2016-01-29", + "2016-02-01", + "2016-02-02", + "2016-02-03", + "2016-02-04", + "2016-02-05", + "2016-02-08", + "2016-02-09", + "2016-02-10", + "2016-02-11", + "2016-02-12", + "2016-02-16", + "2016-02-17", + "2016-02-18", + "2016-02-19", + "2016-02-22", + "2016-02-23", + "2016-02-24", + "2016-02-25", + "2016-02-26", + "2016-02-29", + "2016-03-01", + "2016-03-02", + "2016-03-03", + "2016-03-04", + "2016-03-07", + "2016-03-08", + "2016-03-09", + "2016-03-10", + "2016-03-11", + "2016-03-14", + "2016-03-15", + "2016-03-16", + "2016-03-17", + "2016-03-18", + "2016-03-21", + "2016-03-22", + "2016-03-23", + "2016-03-24", + "2016-03-28", + "2016-03-29", + "2016-03-30", + "2016-03-31", + "2016-04-01", + "2016-04-04", + "2016-04-05", + "2016-04-06", + "2016-04-07", + "2016-04-08", + "2016-04-11", + "2016-04-12", + "2016-04-13", + "2016-04-14", + "2016-04-15", + "2016-04-18", + "2016-04-19", + "2016-04-20", + "2016-04-21", + "2016-04-22", + "2016-04-25", + "2016-04-26", + "2016-04-27", + "2016-04-28", + "2016-04-29", + "2016-05-02", + "2016-05-03", + "2016-05-04", + "2016-05-05", + "2016-05-06", + "2016-05-09", + "2016-05-10", + "2016-05-11", + "2016-05-12", + "2016-05-13", + "2016-05-16", + "2016-05-17", + "2016-05-18", + "2016-05-19", + "2016-05-20", + "2016-05-23", + "2016-05-24", + "2016-05-25", + "2016-05-26", + "2016-05-27", + "2016-05-31", + "2016-06-01", + "2016-06-02", + "2016-06-03", + "2016-06-06", + "2016-06-07", + "2016-06-08", + "2016-06-09", + "2016-06-10", + "2016-06-13", + "2016-06-14", + "2016-06-15", + "2016-06-16", + "2016-06-17", + "2016-06-20", + "2016-06-21", + "2016-06-22", + "2016-06-23", + "2016-06-24", + "2016-06-27", + "2016-06-28", + "2016-06-29", + "2016-06-30", + "2016-07-01", + "2016-07-05", + "2016-07-06", + "2016-07-07", + "2016-07-08", + "2016-07-11", + "2016-07-12", + "2016-07-13", + "2016-07-14", + "2016-07-15", + "2016-07-18", + "2016-07-19", + "2016-07-20", + "2016-07-21", + "2016-07-22", + "2016-07-25", + "2016-07-26", + "2016-07-27", + "2016-07-28", + "2016-07-29", + "2016-08-01", + "2016-08-02", + "2016-08-03", + "2016-08-04", + "2016-08-05", + "2016-08-08", + "2016-08-09", + "2016-08-10", + "2016-08-11", + "2016-08-12", + "2016-08-15", + "2016-08-16", + "2016-08-17", + "2016-08-18", + "2016-08-19", + "2016-08-22", + "2016-08-23", + "2016-08-24", + "2016-08-25", + "2016-08-26", + "2016-08-29", + "2016-08-30", + "2016-08-31", + "2016-09-01", + "2016-09-02", + "2016-09-06", + "2016-09-07", + "2016-09-08", + "2016-09-09", + "2016-09-12", + "2016-09-13", + "2016-09-14", + "2016-09-15", + "2016-09-16", + "2016-09-19", + "2016-09-20", + "2016-09-21", + "2016-09-22", + "2016-09-23", + "2016-09-26", + "2016-09-27", + "2016-09-28", + "2016-09-29", + "2016-09-30", + "2016-10-03", + "2016-10-04", + "2016-10-05", + "2016-10-06", + "2016-10-07", + "2016-10-10", + "2016-10-11", + "2016-10-12", + "2016-10-13", + "2016-10-14", + "2016-10-17", + "2016-10-18", + "2016-10-19", + "2016-10-20", + "2016-10-21", + "2016-10-24", + "2016-10-25", + "2016-10-26", + "2016-10-27", + "2016-10-28", + "2016-10-31", + "2016-11-01", + "2016-11-02", + "2016-11-03", + "2016-11-04", + "2016-11-07", + "2016-11-08", + "2016-11-09", + "2016-11-10", + "2016-11-11", + "2016-11-14", + "2016-11-15", + "2016-11-16", + "2016-11-17", + "2016-11-18", + "2016-11-21", + "2016-11-22", + "2016-11-23", + "2016-11-25", + "2016-11-28", + "2016-11-29", + "2016-11-30", + "2016-12-01", + "2016-12-02", + "2016-12-05", + "2016-12-06", + "2016-12-07", + "2016-12-08", + "2016-12-09", + "2016-12-12", + "2016-12-13", + "2016-12-14", + "2016-12-15", + "2016-12-16", + "2016-12-19", + "2016-12-20", + "2016-12-21", + "2016-12-22", + "2016-12-23", + "2016-12-27", + "2016-12-28", + "2016-12-29", + "2016-12-30", + "2017-01-03", + "2017-01-04", + "2017-01-05", + "2017-01-06", + "2017-01-09", + "2017-01-10", + "2017-01-11", + "2017-01-12", + "2017-01-13", + "2017-01-17", + "2017-01-18", + "2017-01-19", + "2017-01-20", + "2017-01-23", + "2017-01-24", + "2017-01-25", + "2017-01-26", + "2017-01-27", + "2017-01-30", + "2017-01-31", + "2017-02-01", + "2017-02-02", + "2017-02-03", + "2017-02-06", + "2017-02-07", + "2017-02-08", + "2017-02-09", + "2017-02-10", + "2017-02-13", + "2017-02-14", + "2017-02-15", + "2017-02-16" + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')\n", + "\n", + "fig = go.Figure()\n", + "fig.add_trace(go.Candlestick(x=df['Date'],\n", + " open=df['AAPL.Open'],\n", + " high=df['AAPL.High'],\n", + " low=df['AAPL.Low'],\n", + " close=df['AAPL.Close']))\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 开-高-低-收图(OHLC Charts)\n", + "OHLC 图表与蜡烛图类似,但用线段表示开盘和收盘价,通过 `Ohlc` 函数创建。" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "close": [ + 127.830002, + 128.720001, + 128.449997, + 129.5, + 133, + 132.169998, + 128.789993, + 130.419998, + 128.460007, + 129.089996, + 129.360001, + 128.539993, + 126.410004, + 126.599998, + 127.139999, + 124.510002, + 122.239998, + 124.449997, + 123.589996, + 124.949997, + 127.040001, + 128.470001, + 127.5, + 125.900002, + 127.209999, + 126.690002, + 123.379997, + 124.239998, + 123.25, + 126.370003, + 124.43, + 124.25, + 125.32, + 127.349998, + 126.010002, + 125.599998, + 126.559998, + 127.099998, + 126.849998, + 126.300003, + 126.779999, + 126.169998, + 124.75, + 127.599998, + 126.910004, + 128.619995, + 129.669998, + 130.279999, + 132.649994, + 130.559998, + 128.639999, + 125.150002, + 128.949997, + 128.699997, + 125.800003, + 125.010002, + 125.260002, + 127.620003, + 126.32, + 125.870003, + 126.010002, + 128.949997, + 128.770004, + 130.190002, + 130.070007, + 130.059998, + 131.389999, + 132.539993, + 129.619995, + 132.039993, + 131.779999, + 130.279999, + 130.539993, + 129.960007, + 130.119995, + 129.360001, + 128.649994, + 127.800003, + 127.419998, + 128.880005, + 128.589996, + 127.169998, + 126.919998, + 127.599998, + 127.300003, + 127.879997, + 126.599998, + 127.610001, + 127.029999, + 128.110001, + 127.5, + 126.75, + 124.529999, + 125.43, + 126.599998, + 126.440002, + 126, + 125.690002, + 122.57, + 120.07, + 123.279999, + 125.660004, + 125.610001, + 126.82, + 128.509995, + 129.619995, + 132.070007, + 130.75, + 125.220001, + 125.160004, + 124.5, + 122.769997, + 123.379997, + 122.989998, + 122.370003, + 121.300003, + 118.440002, + 114.639999, + 115.400002, + 115.129997, + 115.519997, + 119.720001, + 113.489998, + 115.239998, + 115.150002, + 115.959999, + 117.160004, + 116.5, + 115.010002, + 112.650002, + 105.760002, + 103.120003, + 103.739998, + 109.690002, + 112.919998, + 113.290001, + 112.760002, + 107.720001, + 112.339996, + 110.370003, + 109.269997, + 112.309998, + 110.150002, + 112.57, + 114.209999, + 115.309998, + 116.279999, + 116.410004, + 113.919998, + 113.449997, + 115.209999, + 113.400002, + 114.32, + 115, + 114.709999, + 112.440002, + 109.059998, + 110.300003, + 109.580002, + 110.379997, + 110.779999, + 111.309998, + 110.779999, + 109.5, + 112.120003, + 111.599998, + 111.790001, + 110.209999, + 111.860001, + 111.040001, + 111.730003, + 113.769997, + 113.760002, + 115.5, + 119.080002, + 115.279999, + 114.550003, + 119.269997, + 120.529999, + 119.5, + 121.18, + 122.57, + 122, + 120.919998, + 121.059998, + 120.57, + 116.769997, + 116.110001, + 115.720001, + 112.339996, + 114.18, + 113.690002, + 117.290001, + 118.779999, + 119.300003, + 117.75, + 118.879997, + 118.029999, + 117.809998, + 118.300003, + 117.339996, + 116.279999, + 115.199997, + 119.029999, + 118.279999, + 118.230003, + 115.620003, + 116.169998, + 113.18, + 112.480003, + 110.489998, + 111.339996, + 108.980003, + 106.029999, + 107.330002, + 107.230003, + 108.610001, + 108.029999, + 106.82, + 108.739998, + 107.32, + 105.260002, + 105.349998, + 102.709999, + 100.699997, + 96.449997, + 96.959999, + 98.529999, + 99.959999, + 97.389999, + 99.519997, + 97.129997, + 96.660004, + 96.790001, + 96.300003, + 101.419998, + 99.440002, + 99.989998, + 93.419998, + 94.089996, + 97.339996, + 96.43, + 94.480003, + 96.349998, + 96.599998, + 94.019997, + 95.010002, + 94.989998, + 94.269997, + 93.699997, + 93.989998, + 96.639999, + 98.120003, + 96.260002, + 96.040001, + 96.879997, + 94.690002, + 96.099998, + 96.760002, + 96.910004, + 96.690002, + 100.529999, + 100.75, + 101.5, + 103.010002, + 101.870003, + 101.029999, + 101.120003, + 101.169998, + 102.260002, + 102.519997, + 104.580002, + 105.970001, + 105.800003, + 105.919998, + 105.910004, + 106.720001, + 106.129997, + 105.669998, + 105.190002, + 107.68, + 109.559998, + 108.989998, + 109.989998, + 111.120003, + 109.809998, + 110.959999, + 108.540001, + 108.660004, + 109.019997, + 110.440002, + 112.040001, + 112.099998, + 109.849998, + 107.480003, + 106.910004, + 107.129997, + 105.970001, + 105.68, + 105.080002, + 104.349998, + 97.82, + 94.830002, + 93.739998, + 93.639999, + 95.18, + 94.190002, + 93.239998, + 92.720001, + 92.790001, + 93.419998, + 92.510002, + 90.339996, + 90.519997, + 93.879997, + 93.489998, + 94.559998, + 94.199997, + 95.220001, + 96.43, + 97.900002, + 99.620003, + 100.410004, + 100.349998, + 99.860001, + 98.459999, + 97.720001, + 97.919998, + 98.629997, + 99.029999, + 98.940002, + 99.650002, + 98.830002, + 97.339996, + 97.459999, + 97.139999, + 97.550003, + 95.330002, + 95.099998, + 95.910004, + 95.550003, + 96.099998, + 93.400002, + 92.040001, + 93.589996, + 94.400002, + 95.599998, + 95.889999, + 94.989998, + 95.529999, + 95.940002, + 96.68, + 96.980003, + 97.419998, + 96.870003, + 98.790001, + 98.779999, + 99.830002, + 99.870003, + 99.959999, + 99.43, + 98.660004, + 97.339996, + 96.669998, + 102.949997, + 104.339996, + 104.209999, + 106.050003, + 104.480003, + 105.790001, + 105.870003, + 107.480003, + 108.370003, + 108.809998, + 108, + 107.93, + 108.18, + 109.480003, + 109.379997, + 109.220001, + 109.080002, + 109.360001, + 108.510002, + 108.849998, + 108.029999, + 107.57, + 106.940002, + 106.82, + 106, + 106.099998, + 106.730003, + 107.730003, + 107.699997, + 108.360001, + 105.519997, + 103.129997, + 105.440002, + 107.949997, + 111.769997, + 115.57, + 114.919998, + 113.580002, + 113.57, + 113.550003, + 114.620003, + 112.709999, + 112.879997, + 113.089996, + 113.949997, + 112.18, + 113.050003, + 112.519997, + 113, + 113.050003, + 113.889999, + 114.059998, + 116.050003, + 116.300003, + 117.339996, + 116.980003, + 117.629997, + 117.550003, + 117.470001, + 117.120003, + 117.059998, + 116.599998, + 117.650002, + 118.25, + 115.589996, + 114.480003, + 113.720001, + 113.540001, + 111.489998, + 111.589996, + 109.830002, + 108.839996, + 110.410004, + 111.059998, + 110.879997, + 107.790001, + 108.43, + 105.709999, + 107.110001, + 109.989998, + 109.949997, + 110.059998, + 111.730003, + 111.800003, + 111.230003, + 111.790001, + 111.57, + 111.459999, + 110.519997, + 109.489998, + 109.900002, + 109.110001, + 109.949997, + 111.029999, + 112.120003, + 113.949997, + 113.300003, + 115.190002, + 115.190002, + 115.82, + 115.970001, + 116.639999, + 116.949997, + 117.059998, + 116.290001, + 116.519997, + 117.260002, + 116.760002, + 116.730003, + 115.82, + 116.150002, + 116.019997, + 116.610001, + 117.910004, + 118.989998, + 119.110001, + 119.75, + 119.25, + 119.040001, + 120, + 119.989998, + 119.779999, + 120, + 120.080002, + 119.970001, + 121.879997, + 121.940002, + 121.949997, + 121.629997, + 121.349998, + 128.75, + 128.529999, + 129.080002, + 130.289993, + 131.529999, + 132.039993, + 132.419998, + 132.119995, + 133.289993, + 135.020004, + 135.509995, + 135.350006 + ], + "high": [ + 128.880005, + 128.779999, + 129.029999, + 129.5, + 133, + 133.600006, + 131.600006, + 130.869995, + 130.570007, + 130.279999, + 129.520004, + 129.559998, + 128.75, + 129.369995, + 129.570007, + 127.220001, + 124.769997, + 124.900002, + 125.400002, + 124.949997, + 127.32, + 129.160004, + 129.25, + 128.399994, + 127.849998, + 128.039993, + 126.82, + 124.879997, + 124.699997, + 126.400002, + 126.489998, + 125.120003, + 125.559998, + 127.510002, + 128.119995, + 126.400002, + 126.580002, + 127.209999, + 128.570007, + 127.290001, + 127.129997, + 127.099998, + 126.139999, + 128.119995, + 128.199997, + 128.869995, + 130.419998, + 130.630005, + 133.130005, + 134.539993, + 131.589996, + 128.639999, + 130.130005, + 130.570007, + 128.449997, + 126.75, + 126.080002, + 127.620003, + 127.559998, + 126.879997, + 127.190002, + 128.949997, + 129.490005, + 130.720001, + 130.880005, + 130.979996, + 131.630005, + 132.970001, + 132.910004, + 132.259995, + 131.949997, + 131.449997, + 131.389999, + 130.660004, + 130.940002, + 130.580002, + 129.690002, + 129.210007, + 128.080002, + 129.339996, + 130.179993, + 128.330002, + 127.239998, + 127.849998, + 127.879997, + 128.309998, + 127.82, + 128.059998, + 127.610001, + 129.800003, + 129.199997, + 127.989998, + 126.470001, + 126.120003, + 126.940002, + 126.690002, + 126.230003, + 126.150002, + 124.639999, + 124.059998, + 123.849998, + 125.760002, + 126.370003, + 127.150002, + 128.570007, + 129.619995, + 132.970001, + 132.919998, + 125.5, + 127.089996, + 125.739998, + 123.610001, + 123.910004, + 123.5, + 122.57, + 122.639999, + 122.57, + 117.699997, + 117.440002, + 116.5, + 116.25, + 119.989998, + 118.18, + 115.419998, + 116.400002, + 116.309998, + 117.650002, + 117.440002, + 116.519997, + 114.349998, + 111.900002, + 108.800003, + 111.110001, + 109.889999, + 113.239998, + 113.309998, + 114.529999, + 111.879997, + 112.339996, + 112.779999, + 110.449997, + 112.559998, + 114.019997, + 113.279999, + 114.209999, + 116.889999, + 116.529999, + 116.540001, + 116.489998, + 114.300003, + 115.370003, + 114.18, + 114.720001, + 115.5, + 116.690002, + 114.57, + 113.510002, + 111.540001, + 109.620003, + 111.010002, + 111.370003, + 111.739998, + 111.769997, + 110.190002, + 112.279999, + 112.75, + 112.449997, + 111.519997, + 112.099998, + 112, + 111.75, + 114.169998, + 115.580002, + 115.5, + 119.230003, + 118.129997, + 116.540001, + 119.300003, + 120.690002, + 121.220001, + 121.360001, + 123.489998, + 123.82, + 122.690002, + 121.809998, + 121.809998, + 118.07, + 117.419998, + 116.82, + 115.57, + 114.239998, + 115.050003, + 117.489998, + 119.75, + 119.919998, + 119.730003, + 119.349998, + 119.230003, + 118.410004, + 119.410004, + 118.809998, + 118.110001, + 116.790001, + 119.25, + 119.860001, + 118.599998, + 117.690002, + 116.940002, + 115.389999, + 112.68, + 112.800003, + 111.989998, + 112.25, + 109.519997, + 107.370003, + 107.720001, + 108.849998, + 109, + 107.690002, + 109.43, + 108.699997, + 107.029999, + 105.370003, + 105.849998, + 102.370003, + 100.129997, + 99.110001, + 99.059998, + 100.690002, + 101.190002, + 100.480003, + 97.709999, + 98.650002, + 98.190002, + 97.879997, + 101.459999, + 101.529999, + 100.879997, + 96.629997, + 94.519997, + 97.339996, + 96.709999, + 96.040001, + 96.839996, + 97.330002, + 96.919998, + 95.699997, + 95.940002, + 96.349998, + 94.720001, + 94.5, + 96.849998, + 98.209999, + 98.889999, + 96.760002, + 96.900002, + 96.5, + 96.379997, + 96.760002, + 98.019997, + 98.230003, + 100.769997, + 100.889999, + 101.709999, + 103.75, + 102.830002, + 101.760002, + 101.580002, + 102.239998, + 102.279999, + 102.910004, + 105.18, + 106.309998, + 106.470001, + 106.5, + 107.650002, + 107.290001, + 107.07, + 106.25, + 106.190002, + 107.790001, + 110.419998, + 109.900002, + 110, + 112.190002, + 110.730003, + 110.980003, + 110.419998, + 109.769997, + 110.610001, + 110.5, + 112.339996, + 112.389999, + 112.300003, + 108.949997, + 108, + 108.089996, + 106.93, + 106.480003, + 105.650002, + 105.300003, + 98.709999, + 97.879997, + 94.720001, + 94.080002, + 95.739998, + 95.900002, + 94.07, + 93.449997, + 93.769997, + 93.57, + 93.57, + 92.779999, + 91.669998, + 94.389999, + 94.699997, + 95.209999, + 94.639999, + 95.43, + 97.190002, + 98.089996, + 99.739998, + 100.730003, + 100.470001, + 100.400002, + 99.540001, + 97.839996, + 98.269997, + 101.889999, + 99.870003, + 99.559998, + 99.989998, + 99.349998, + 99.120003, + 98.480003, + 98.410004, + 97.75, + 96.650002, + 96.57, + 96.349998, + 96.889999, + 96.290001, + 94.660004, + 93.050003, + 93.660004, + 94.550003, + 95.769997, + 96.470001, + 95.400002, + 95.660004, + 96.5, + 96.889999, + 97.650002, + 97.699997, + 97.669998, + 98.989998, + 99.300003, + 100.129997, + 100, + 100.459999, + 101, + 99.300003, + 98.839996, + 97.970001, + 104.349998, + 104.449997, + 104.550003, + 106.150002, + 106.07, + 105.839996, + 106, + 107.650002, + 108.370003, + 108.940002, + 108.900002, + 108.93, + 108.440002, + 109.540001, + 110.230003, + 109.370003, + 109.599998, + 109.690002, + 109.099998, + 109.32, + 108.75, + 107.879997, + 107.949997, + 107.440002, + 106.5, + 106.57, + 106.800003, + 108, + 108.300003, + 108.760002, + 107.269997, + 105.720001, + 105.720001, + 108.790001, + 113.029999, + 115.730003, + 116.129997, + 116.18, + 114.120003, + 113.989998, + 114.940002, + 114.790001, + 113.389999, + 113.18, + 114.639999, + 113.800003, + 113.370003, + 113.050003, + 114.309998, + 113.660004, + 114.339996, + 114.559998, + 116.75, + 118.690002, + 117.980003, + 117.440002, + 118.169998, + 117.839996, + 118.209999, + 117.760002, + 117.379997, + 116.910004, + 117.739998, + 118.360001, + 115.699997, + 115.860001, + 115.209999, + 114.230003, + 113.769997, + 112.349998, + 111.459999, + 110.25, + 110.510002, + 111.720001, + 111.32, + 111.089996, + 108.870003, + 107.809998, + 107.68, + 110.230003, + 110.349998, + 110.540001, + 111.989998, + 112.419998, + 111.510002, + 111.870003, + 112.470001, + 112.029999, + 112.199997, + 110.940002, + 110.089996, + 110.029999, + 110.360001, + 111.190002, + 112.43, + 114.699997, + 115, + 115.919998, + 116.199997, + 116.730003, + 116.5, + 117.379997, + 117.5, + 117.400002, + 116.510002, + 116.519997, + 117.800003, + 118.019997, + 117.110001, + 117.199997, + 116.330002, + 116.510002, + 116.860001, + 118.160004, + 119.43, + 119.379997, + 119.93, + 119.300003, + 119.620003, + 120.239998, + 120.5, + 120.089996, + 120.449997, + 120.809998, + 120.099998, + 122.099998, + 122.440002, + 122.349998, + 121.629997, + 121.389999, + 130.490005, + 129.389999, + 129.190002, + 130.5, + 132.089996, + 132.220001, + 132.449997, + 132.940002, + 133.820007, + 135.089996, + 136.270004, + 135.899994 + ], + "low": [ + 126.919998, + 127.449997, + 128.330002, + 128.050003, + 129.660004, + 131.169998, + 128.149994, + 126.610001, + 128.240005, + 128.300003, + 128.089996, + 128.320007, + 125.760002, + 126.260002, + 125.059998, + 123.800003, + 122.110001, + 121.629997, + 122.580002, + 122.870003, + 125.650002, + 126.370003, + 127.400002, + 125.160004, + 126.519997, + 126.559998, + 123.379997, + 122.599998, + 122.910004, + 124, + 124.360001, + 123.099998, + 124.190002, + 124.330002, + 125.980003, + 124.970001, + 124.660004, + 125.260002, + 126.610001, + 125.910004, + 126.010002, + 126.110001, + 124.459999, + 125.169998, + 126.669998, + 126.32, + 128.139999, + 129.229996, + 131.149994, + 129.570007, + 128.300003, + 124.580002, + 125.300003, + 128.259995, + 125.779999, + 123.360001, + 124.019997, + 126.110001, + 125.629997, + 124.82, + 125.870003, + 127.160004, + 128.210007, + 128.360001, + 129.639999, + 129.339996, + 129.830002, + 131.399994, + 129.119995, + 130.050003, + 131.100006, + 129.899994, + 130.050003, + 129.320007, + 129.899994, + 128.910004, + 128.360001, + 126.830002, + 125.620003, + 127.849998, + 128.479996, + 127.110001, + 125.709999, + 126.370003, + 126.739998, + 127.220001, + 126.400002, + 127.080002, + 126.879997, + 127.120003, + 127.5, + 126.510002, + 124.480003, + 124.860001, + 125.989998, + 125.769997, + 124.849998, + 123.769997, + 122.540001, + 119.220001, + 121.209999, + 124.32, + 125.040001, + 125.580002, + 127.349998, + 128.309998, + 130.699997, + 130.320007, + 121.989998, + 125.059998, + 123.900002, + 122.120003, + 122.550003, + 122.269997, + 121.709999, + 120.910004, + 117.519997, + 113.25, + 112.099998, + 114.120003, + 114.5, + 116.529999, + 113.330002, + 109.629997, + 114.540001, + 114.010002, + 115.5, + 116.010002, + 114.68, + 111.629997, + 105.650002, + 92, + 103.5, + 105.050003, + 110.019997, + 111.540001, + 112, + 107.360001, + 109.129997, + 110.040001, + 108.510002, + 110.32, + 109.769997, + 109.900002, + 111.760002, + 114.860001, + 114.419998, + 115.440002, + 113.720001, + 111.870003, + 113.660004, + 112.519997, + 113.300003, + 112.370003, + 114.019997, + 112.440002, + 107.860001, + 108.730003, + 107.309998, + 107.550003, + 109.07, + 109.769997, + 109.410004, + 108.209999, + 109.489998, + 111.440002, + 110.68, + 109.559998, + 110.489998, + 110.529999, + 110.110001, + 110.82, + 113.699997, + 114.099998, + 116.330002, + 114.919998, + 113.989998, + 116.059998, + 118.269997, + 119.449997, + 119.610001, + 120.699997, + 121.620003, + 120.18, + 120.620003, + 120.050003, + 116.059998, + 115.209999, + 115.650002, + 112.269997, + 111, + 113.32, + 115.5, + 116.760002, + 118.849998, + 117.339996, + 117.120003, + 117.919998, + 117.599998, + 117.75, + 116.860001, + 116.080002, + 114.220001, + 115.110001, + 117.809998, + 116.860001, + 115.080002, + 115.510002, + 112.849998, + 109.790001, + 110.349998, + 108.800003, + 108.980003, + 105.809998, + 105.57, + 106.449997, + 107.199997, + 107.949997, + 106.18, + 106.860001, + 107.18, + 104.82, + 102, + 102.410004, + 99.870003, + 96.43, + 96.760002, + 97.339996, + 98.839996, + 97.300003, + 95.739998, + 95.360001, + 95.5, + 93.419998, + 94.940002, + 98.370003, + 99.209999, + 98.07, + 93.339996, + 92.389999, + 94.349998, + 95.400002, + 94.279999, + 94.080002, + 95.190002, + 93.690002, + 93.040001, + 93.93, + 94.099998, + 92.589996, + 93.010002, + 94.610001, + 96.150002, + 96.089996, + 95.800003, + 95.919998, + 94.550003, + 93.32, + 95.25, + 96.580002, + 96.650002, + 97.419998, + 99.639999, + 100.449997, + 101.370003, + 100.959999, + 100.400002, + 100.269997, + 100.150002, + 101.5, + 101.779999, + 103.849998, + 104.589996, + 104.959999, + 105.190002, + 105.139999, + 105.209999, + 105.900002, + 104.889999, + 105.059998, + 104.879997, + 108.599998, + 108.879997, + 108.199997, + 110.269997, + 109.419998, + 109.199997, + 108.120003, + 108.169998, + 108.830002, + 108.660004, + 110.800003, + 111.330002, + 109.730003, + 106.940002, + 106.230003, + 106.059998, + 105.519997, + 104.620003, + 104.510002, + 103.910004, + 95.68, + 94.25, + 92.510002, + 92.400002, + 93.68, + 93.82, + 92.68, + 91.849998, + 92.589996, + 92.110001, + 92.459999, + 89.470001, + 90, + 91.650002, + 93.010002, + 93.889999, + 93.57, + 94.519997, + 95.669998, + 96.839996, + 98.110001, + 98.639999, + 99.25, + 98.82, + 98.330002, + 96.629997, + 97.449997, + 97.550003, + 98.959999, + 98.68, + 98.459999, + 98.480003, + 97.099998, + 96.75, + 97.029999, + 96.07, + 95.300003, + 95.029999, + 94.68, + 95.349998, + 95.25, + 92.650002, + 91.5, + 92.139999, + 93.629997, + 94.300003, + 95.330002, + 94.459999, + 94.370003, + 95.620003, + 96.050003, + 96.730003, + 97.120003, + 96.839996, + 97.32, + 98.5, + 98.599998, + 99.339996, + 99.739998, + 99.129997, + 98.309998, + 96.919998, + 96.419998, + 102.75, + 102.82, + 103.68, + 104.410004, + 104, + 104.769997, + 105.279999, + 106.18, + 107.160004, + 108.010002, + 107.760002, + 107.849998, + 107.779999, + 108.080002, + 109.209999, + 108.339996, + 109.019997, + 108.360001, + 107.849998, + 108.529999, + 107.68, + 106.68, + 106.309998, + 106.290001, + 105.5, + 105.639999, + 105.620003, + 106.82, + 107.510002, + 107.07, + 105.239998, + 103.129997, + 102.529999, + 107.239998, + 108.599998, + 113.489998, + 114.040001, + 113.25, + 112.510002, + 112.440002, + 114, + 111.550003, + 111.550003, + 112.339996, + 113.43, + 111.800003, + 111.800003, + 112.279999, + 112.629997, + 112.690002, + 113.129997, + 113.510002, + 114.720001, + 116.199997, + 116.75, + 115.720001, + 117.129997, + 116.779999, + 117.449997, + 113.800003, + 116.330002, + 116.279999, + 117, + 117.309998, + 113.309998, + 114.099998, + 113.449997, + 113.199997, + 110.529999, + 111.230003, + 109.550003, + 108.110001, + 109.459999, + 109.699997, + 108.050003, + 105.830002, + 106.550003, + 104.080002, + 106.160004, + 106.599998, + 108.830002, + 109.660004, + 110.010002, + 111.400002, + 110.330002, + 110.949997, + 111.389999, + 110.07, + 110.269997, + 109.029999, + 108.849998, + 108.25, + 109.190002, + 109.160004, + 110.599998, + 112.309998, + 112.489998, + 113.75, + 114.980003, + 115.230003, + 115.650002, + 115.75, + 116.68, + 116.779999, + 115.639999, + 115.589996, + 116.489998, + 116.199997, + 116.400002, + 115.43, + 114.760002, + 115.75, + 115.809998, + 116.470001, + 117.940002, + 118.300003, + 118.599998, + 118.209999, + 118.809998, + 118.220001, + 119.709999, + 119.370003, + 119.730003, + 119.769997, + 119.5, + 120.279999, + 121.599998, + 121.599998, + 120.660004, + 120.620003, + 127.010002, + 127.779999, + 128.160004, + 128.899994, + 130.449997, + 131.220001, + 131.119995, + 132.050003, + 132.75, + 133.25, + 134.619995, + 134.839996 + ], + "open": [ + 127.489998, + 127.629997, + 128.479996, + 128.619995, + 130.020004, + 132.940002, + 131.559998, + 128.789993, + 130, + 129.25, + 128.960007, + 129.100006, + 128.580002, + 128.399994, + 127.959999, + 126.410004, + 124.75, + 122.309998, + 124.400002, + 123.879997, + 125.900002, + 127, + 128.75, + 128.25, + 127.120003, + 127.230003, + 126.540001, + 122.760002, + 124.57, + 124.050003, + 126.089996, + 124.82, + 125.029999, + 124.470001, + 127.639999, + 125.849998, + 125.849998, + 125.949997, + 128.369995, + 127, + 126.410004, + 126.279999, + 125.550003, + 125.57, + 128.100006, + 126.989998, + 128.300003, + 130.490005, + 132.309998, + 134.460007, + 130.160004, + 128.639999, + 126.099998, + 129.5, + 128.149994, + 126.559998, + 124.769997, + 126.68, + 127.389999, + 125.599998, + 126.150002, + 127.410004, + 129.070007, + 128.380005, + 130.690002, + 130, + 130.070007, + 131.600006, + 132.600006, + 130.339996, + 131.860001, + 131.229996, + 130.279999, + 129.860001, + 130.660004, + 129.580002, + 129.5, + 128.899994, + 126.699997, + 127.919998, + 129.179993, + 128.190002, + 126.099998, + 127.029999, + 127.720001, + 127.230003, + 127.709999, + 127.489998, + 127.480003, + 127.209999, + 128.860001, + 127.669998, + 125.459999, + 125.57, + 126.900002, + 126.43, + 124.940002, + 125.889999, + 124.480003, + 123.849998, + 121.940002, + 125.029999, + 126.040001, + 125.720001, + 127.739998, + 129.080002, + 130.970001, + 132.850006, + 121.989998, + 126.199997, + 125.32, + 123.089996, + 123.379997, + 123.150002, + 122.32, + 122.599998, + 121.5, + 117.419998, + 112.949997, + 115.970001, + 114.580002, + 116.529999, + 117.809998, + 112.529999, + 116.040001, + 114.32, + 116.040001, + 116.43, + 116.099998, + 114.080002, + 110.43, + 94.870003, + 111.110001, + 107.089996, + 112.230003, + 112.169998, + 112.029999, + 110.150002, + 110.230003, + 112.489998, + 108.970001, + 111.75, + 113.760002, + 110.269997, + 111.790001, + 116.580002, + 115.93, + 116.25, + 115.660004, + 112.209999, + 113.669998, + 113.379997, + 113.629997, + 113.25, + 116.440002, + 113.849998, + 112.830002, + 110.169998, + 109.07, + 108.010002, + 109.879997, + 110.629997, + 111.739998, + 110.190002, + 110, + 112.730003, + 110.82, + 111.290001, + 110.93, + 111.779999, + 110.800003, + 111.339996, + 114, + 114.330002, + 116.699997, + 118.080002, + 115.400002, + 116.93, + 118.699997, + 120.989998, + 120.800003, + 120.790001, + 123.129997, + 121.849998, + 121.110001, + 120.959999, + 116.900002, + 116.370003, + 116.260002, + 115.199997, + 111.379997, + 114.919998, + 115.760002, + 117.639999, + 119.199997, + 119.269997, + 117.330002, + 119.209999, + 118.290001, + 117.989998, + 118.75, + 117.339996, + 116.550003, + 115.290001, + 118.980003, + 117.519997, + 117.639999, + 116.040001, + 115.190002, + 112.18, + 111.940002, + 111.07, + 112.019997, + 108.910004, + 107.279999, + 107.400002, + 107.269997, + 109, + 107.589996, + 106.959999, + 108.580002, + 107.010002, + 102.610001, + 105.75, + 100.559998, + 98.68, + 98.550003, + 98.970001, + 100.550003, + 100.32, + 97.959999, + 96.199997, + 98.410004, + 95.099998, + 97.059998, + 98.629997, + 101.519997, + 99.93, + 96.040001, + 93.790001, + 94.790001, + 96.470001, + 95.419998, + 95, + 95.860001, + 96.519997, + 93.129997, + 94.290001, + 95.919998, + 93.790001, + 94.190002, + 95.019997, + 96.669998, + 98.839996, + 96, + 96.309998, + 96.400002, + 93.980003, + 96.050003, + 97.199997, + 96.860001, + 97.650002, + 100.510002, + 100.580002, + 102.370003, + 102.389999, + 100.779999, + 101.309998, + 101.410004, + 102.239998, + 101.910004, + 103.959999, + 104.610001, + 105.519997, + 106.339996, + 105.93, + 105.25, + 106.480003, + 105.470001, + 106, + 104.889999, + 108.650002, + 109.720001, + 108.779999, + 110.419998, + 109.510002, + 110.230003, + 109.949997, + 108.910004, + 108.970001, + 109.339996, + 110.800003, + 111.620003, + 112.110001, + 108.889999, + 107.879997, + 106.639999, + 106.93, + 105.010002, + 105, + 103.910004, + 96, + 97.610001, + 93.989998, + 93.970001, + 94.199997, + 95.199997, + 94, + 93.370003, + 93, + 93.330002, + 93.480003, + 92.720001, + 90, + 92.389999, + 94.550003, + 94.160004, + 94.639999, + 94.639999, + 95.870003, + 97.220001, + 98.669998, + 99.68, + 99.440002, + 99.599998, + 99.019997, + 97.599998, + 97.790001, + 97.989998, + 99.25, + 99.019997, + 98.5, + 98.529999, + 98.690002, + 97.32, + 97.82, + 96.449997, + 96.620003, + 96, + 94.940002, + 96.25, + 95.940002, + 92.910004, + 93, + 92.900002, + 93.970001, + 94.440002, + 95.489998, + 95.389999, + 94.599998, + 95.699997, + 96.489998, + 96.75, + 97.169998, + 97.410004, + 97.389999, + 98.919998, + 98.699997, + 99.559998, + 100, + 99.830002, + 99.260002, + 98.25, + 96.82, + 104.269997, + 102.830002, + 104.190002, + 104.410004, + 106.050003, + 104.809998, + 105.580002, + 106.269997, + 107.519997, + 108.230003, + 108.709999, + 108.519997, + 107.779999, + 108.139999, + 109.629997, + 109.099998, + 109.230003, + 108.769997, + 108.860001, + 108.589996, + 108.57, + 107.389999, + 107.410004, + 106.620003, + 105.800003, + 105.660004, + 106.139999, + 107.699997, + 107.900002, + 107.830002, + 107.25, + 104.639999, + 102.650002, + 107.510002, + 108.730003, + 113.860001, + 115.120003, + 115.190002, + 113.050003, + 113.849998, + 114.349998, + 114.419998, + 111.639999, + 113, + 113.690002, + 113.160004, + 112.459999, + 112.709999, + 113.059998, + 113.400002, + 113.699997, + 114.309998, + 115.019997, + 117.699997, + 117.349998, + 116.790001, + 117.879997, + 117.330002, + 118.18, + 117.25, + 116.860001, + 116.809998, + 117.099998, + 117.949997, + 114.309998, + 115.389999, + 113.870003, + 113.650002, + 113.459999, + 111.400002, + 110.980003, + 108.529999, + 110.080002, + 110.309998, + 109.879997, + 111.089996, + 107.120003, + 107.709999, + 106.57, + 106.699997, + 109.809998, + 109.720001, + 110.120003, + 111.949997, + 111.360001, + 111.129997, + 111.43, + 110.779999, + 111.599998, + 110.370003, + 109.169998, + 110, + 109.5, + 109.260002, + 110.860001, + 112.309998, + 113.290001, + 113.839996, + 115.040001, + 115.379997, + 116.470001, + 115.800003, + 116.739998, + 116.800003, + 116.349998, + 115.589996, + 116.519997, + 117.519997, + 116.449997, + 116.650002, + 115.800003, + 115.849998, + 115.919998, + 116.779999, + 117.949997, + 118.769997, + 118.739998, + 118.900002, + 119.110001, + 118.339996, + 120, + 119.400002, + 120.449997, + 120, + 119.550003, + 120.419998, + 121.669998, + 122.139999, + 120.93, + 121.150002, + 127.029999, + 127.980003, + 128.309998, + 129.130005, + 130.539993, + 131.350006, + 131.649994, + 132.460007, + 133.080002, + 133.470001, + 135.520004, + 135.669998 + ], + "type": "ohlc", + "x": [ + "2015-02-17", + "2015-02-18", + "2015-02-19", + "2015-02-20", + "2015-02-23", + "2015-02-24", + "2015-02-25", + "2015-02-26", + "2015-02-27", + "2015-03-02", + "2015-03-03", + "2015-03-04", + "2015-03-05", + "2015-03-06", + "2015-03-09", + "2015-03-10", + "2015-03-11", + "2015-03-12", + "2015-03-13", + "2015-03-16", + "2015-03-17", + "2015-03-18", + "2015-03-19", + "2015-03-20", + "2015-03-23", + "2015-03-24", + "2015-03-25", + "2015-03-26", + "2015-03-27", + "2015-03-30", + "2015-03-31", + "2015-04-01", + "2015-04-02", + "2015-04-06", + "2015-04-07", + "2015-04-08", + "2015-04-09", + "2015-04-10", + "2015-04-13", + "2015-04-14", + "2015-04-15", + "2015-04-16", + "2015-04-17", + "2015-04-20", + "2015-04-21", + "2015-04-22", + "2015-04-23", + "2015-04-24", + "2015-04-27", + "2015-04-28", + "2015-04-29", + "2015-04-30", + "2015-05-01", + "2015-05-04", + "2015-05-05", + "2015-05-06", + "2015-05-07", + "2015-05-08", + "2015-05-11", + "2015-05-12", + "2015-05-13", + "2015-05-14", + "2015-05-15", + "2015-05-18", + "2015-05-19", + "2015-05-20", + "2015-05-21", + "2015-05-22", + "2015-05-26", + "2015-05-27", + "2015-05-28", + "2015-05-29", + "2015-06-01", + "2015-06-02", + "2015-06-03", + "2015-06-04", + "2015-06-05", + "2015-06-08", + "2015-06-09", + "2015-06-10", + "2015-06-11", + "2015-06-12", + "2015-06-15", + "2015-06-16", + "2015-06-17", + "2015-06-18", + "2015-06-19", + "2015-06-22", + "2015-06-23", + "2015-06-24", + "2015-06-25", + "2015-06-26", + "2015-06-29", + "2015-06-30", + "2015-07-01", + "2015-07-02", + "2015-07-06", + "2015-07-07", + "2015-07-08", + "2015-07-09", + "2015-07-10", + "2015-07-13", + "2015-07-14", + "2015-07-15", + "2015-07-16", + "2015-07-17", + "2015-07-20", + "2015-07-21", + "2015-07-22", + "2015-07-23", + "2015-07-24", + "2015-07-27", + "2015-07-28", + "2015-07-29", + "2015-07-30", + "2015-07-31", + "2015-08-03", + "2015-08-04", + "2015-08-05", + "2015-08-06", + "2015-08-07", + "2015-08-10", + "2015-08-11", + "2015-08-12", + "2015-08-13", + "2015-08-14", + "2015-08-17", + "2015-08-18", + "2015-08-19", + "2015-08-20", + "2015-08-21", + "2015-08-24", + "2015-08-25", + "2015-08-26", + "2015-08-27", + "2015-08-28", + "2015-08-31", + "2015-09-01", + "2015-09-02", + "2015-09-03", + "2015-09-04", + "2015-09-08", + "2015-09-09", + "2015-09-10", + "2015-09-11", + "2015-09-14", + "2015-09-15", + "2015-09-16", + "2015-09-17", + "2015-09-18", + "2015-09-21", + "2015-09-22", + "2015-09-23", + "2015-09-24", + "2015-09-25", + "2015-09-28", + "2015-09-29", + "2015-09-30", + "2015-10-01", + "2015-10-02", + "2015-10-05", + "2015-10-06", + "2015-10-07", + "2015-10-08", + "2015-10-09", + "2015-10-12", + "2015-10-13", + "2015-10-14", + "2015-10-15", + "2015-10-16", + "2015-10-19", + "2015-10-20", + "2015-10-21", + "2015-10-22", + "2015-10-23", + "2015-10-26", + "2015-10-27", + "2015-10-28", + "2015-10-29", + "2015-10-30", + "2015-11-02", + "2015-11-03", + "2015-11-04", + "2015-11-05", + "2015-11-06", + "2015-11-09", + "2015-11-10", + "2015-11-11", + "2015-11-12", + "2015-11-13", + "2015-11-16", + "2015-11-17", + "2015-11-18", + "2015-11-19", + "2015-11-20", + "2015-11-23", + "2015-11-24", + "2015-11-25", + "2015-11-27", + "2015-11-30", + "2015-12-01", + "2015-12-02", + "2015-12-03", + "2015-12-04", + "2015-12-07", + "2015-12-08", + "2015-12-09", + "2015-12-10", + "2015-12-11", + "2015-12-14", + "2015-12-15", + "2015-12-16", + "2015-12-17", + "2015-12-18", + "2015-12-21", + "2015-12-22", + "2015-12-23", + "2015-12-24", + "2015-12-28", + "2015-12-29", + "2015-12-30", + "2015-12-31", + "2016-01-04", + "2016-01-05", + "2016-01-06", + "2016-01-07", + "2016-01-08", + "2016-01-11", + "2016-01-12", + "2016-01-13", + "2016-01-14", + "2016-01-15", + "2016-01-19", + "2016-01-20", + "2016-01-21", + "2016-01-22", + "2016-01-25", + "2016-01-26", + "2016-01-27", + "2016-01-28", + "2016-01-29", + "2016-02-01", + "2016-02-02", + "2016-02-03", + "2016-02-04", + "2016-02-05", + "2016-02-08", + "2016-02-09", + "2016-02-10", + "2016-02-11", + "2016-02-12", + "2016-02-16", + "2016-02-17", + "2016-02-18", + "2016-02-19", + "2016-02-22", + "2016-02-23", + "2016-02-24", + "2016-02-25", + "2016-02-26", + "2016-02-29", + "2016-03-01", + "2016-03-02", + "2016-03-03", + "2016-03-04", + "2016-03-07", + "2016-03-08", + "2016-03-09", + "2016-03-10", + "2016-03-11", + "2016-03-14", + "2016-03-15", + "2016-03-16", + "2016-03-17", + "2016-03-18", + "2016-03-21", + "2016-03-22", + "2016-03-23", + "2016-03-24", + "2016-03-28", + "2016-03-29", + "2016-03-30", + "2016-03-31", + "2016-04-01", + "2016-04-04", + "2016-04-05", + "2016-04-06", + "2016-04-07", + "2016-04-08", + "2016-04-11", + "2016-04-12", + "2016-04-13", + "2016-04-14", + "2016-04-15", + "2016-04-18", + "2016-04-19", + "2016-04-20", + "2016-04-21", + "2016-04-22", + "2016-04-25", + "2016-04-26", + "2016-04-27", + "2016-04-28", + "2016-04-29", + "2016-05-02", + "2016-05-03", + "2016-05-04", + "2016-05-05", + "2016-05-06", + "2016-05-09", + "2016-05-10", + "2016-05-11", + "2016-05-12", + "2016-05-13", + "2016-05-16", + "2016-05-17", + "2016-05-18", + "2016-05-19", + "2016-05-20", + "2016-05-23", + "2016-05-24", + "2016-05-25", + "2016-05-26", + "2016-05-27", + "2016-05-31", + "2016-06-01", + "2016-06-02", + "2016-06-03", + "2016-06-06", + "2016-06-07", + "2016-06-08", + "2016-06-09", + "2016-06-10", + "2016-06-13", + "2016-06-14", + "2016-06-15", + "2016-06-16", + "2016-06-17", + "2016-06-20", + "2016-06-21", + "2016-06-22", + "2016-06-23", + "2016-06-24", + "2016-06-27", + "2016-06-28", + "2016-06-29", + "2016-06-30", + "2016-07-01", + "2016-07-05", + "2016-07-06", + "2016-07-07", + "2016-07-08", + "2016-07-11", + "2016-07-12", + "2016-07-13", + "2016-07-14", + "2016-07-15", + "2016-07-18", + "2016-07-19", + "2016-07-20", + "2016-07-21", + "2016-07-22", + "2016-07-25", + "2016-07-26", + "2016-07-27", + "2016-07-28", + "2016-07-29", + "2016-08-01", + "2016-08-02", + "2016-08-03", + "2016-08-04", + "2016-08-05", + "2016-08-08", + "2016-08-09", + "2016-08-10", + "2016-08-11", + "2016-08-12", + "2016-08-15", + "2016-08-16", + "2016-08-17", + "2016-08-18", + "2016-08-19", + "2016-08-22", + "2016-08-23", + "2016-08-24", + "2016-08-25", + "2016-08-26", + "2016-08-29", + "2016-08-30", + "2016-08-31", + "2016-09-01", + "2016-09-02", + "2016-09-06", + "2016-09-07", + "2016-09-08", + "2016-09-09", + "2016-09-12", + "2016-09-13", + "2016-09-14", + "2016-09-15", + "2016-09-16", + "2016-09-19", + "2016-09-20", + "2016-09-21", + "2016-09-22", + "2016-09-23", + "2016-09-26", + "2016-09-27", + "2016-09-28", + "2016-09-29", + "2016-09-30", + "2016-10-03", + "2016-10-04", + "2016-10-05", + "2016-10-06", + "2016-10-07", + "2016-10-10", + "2016-10-11", + "2016-10-12", + "2016-10-13", + "2016-10-14", + "2016-10-17", + "2016-10-18", + "2016-10-19", + "2016-10-20", + "2016-10-21", + "2016-10-24", + "2016-10-25", + "2016-10-26", + "2016-10-27", + "2016-10-28", + "2016-10-31", + "2016-11-01", + "2016-11-02", + "2016-11-03", + "2016-11-04", + "2016-11-07", + "2016-11-08", + "2016-11-09", + "2016-11-10", + "2016-11-11", + "2016-11-14", + "2016-11-15", + "2016-11-16", + "2016-11-17", + "2016-11-18", + "2016-11-21", + "2016-11-22", + "2016-11-23", + "2016-11-25", + "2016-11-28", + "2016-11-29", + "2016-11-30", + "2016-12-01", + "2016-12-02", + "2016-12-05", + "2016-12-06", + "2016-12-07", + "2016-12-08", + "2016-12-09", + "2016-12-12", + "2016-12-13", + "2016-12-14", + "2016-12-15", + "2016-12-16", + "2016-12-19", + "2016-12-20", + "2016-12-21", + "2016-12-22", + "2016-12-23", + "2016-12-27", + "2016-12-28", + "2016-12-29", + "2016-12-30", + "2017-01-03", + "2017-01-04", + "2017-01-05", + "2017-01-06", + "2017-01-09", + "2017-01-10", + "2017-01-11", + "2017-01-12", + "2017-01-13", + "2017-01-17", + "2017-01-18", + "2017-01-19", + "2017-01-20", + "2017-01-23", + "2017-01-24", + "2017-01-25", + "2017-01-26", + "2017-01-27", + "2017-01-30", + "2017-01-31", + "2017-02-01", + "2017-02-02", + "2017-02-03", + "2017-02-06", + "2017-02-07", + "2017-02-08", + "2017-02-09", + "2017-02-10", + "2017-02-13", + "2017-02-14", + "2017-02-15", + "2017-02-16" + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig = go.Figure()\n", + "fig.add_trace(go.Ohlc(x=df['Date'],\n", + " open=df['AAPL.Open'],\n", + " high=df['AAPL.High'],\n", + " low=df['AAPL.Low'],\n", + " close=df['AAPL.Close']))\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 瀑布图 \n", + "\n", + "瀑布图是一种用于展示数值数据中各项增减对总体变化的贡献的图表类型。它以垂直方向的条形表示数据的累积效果,展示了从一个起始点到最终结果的各个过程和因素的贡献。瀑布图通常用于呈现财务数据中的收入、支出、利润等变化。\n", + "\n", + "`go.Waterfall` 是 Plotly 中用于创建瀑布图的图表对象。主要参数包括:\n", + "\n", + "- `measure` : 每个柱的测量类型,可以是 \"relative\"(相对值,即相对于前一个柱的增量)或 \"total\"(总值,即当前柱的绝对值)。\n", + "- `y`: 每个柱的数值,代表各个因素对总体变化的贡献。\n", + "- `name`(optional): 该瀑布图的名称,用于在图例中标识。\n", + "- `orientation`(optional): 瀑布图的方向,可以是 \"v\"(垂直)或 \"h\"(水平)。\n", + "- `x` (optional): 每个柱的标签,用于表示瀑布图中的各个过程或因素。\n", + "- `textposition` (optional): 柱上文本标签的位置,可以是 \"inside\"(内部)或 \"outside\"(外部)。\n", + "- `text`(optional): 与每个柱相关联的文本标签,用于显示在柱的旁边。\n", + "- `connector` (optional): 连接线的样式,是一个包含 \"line\" 字典的字典。可以设置颜色等样式。\n", + "\n", + "例:创建一个垂直方向的瀑布图,表示了不同因素对于损益表的贡献,包括销售额、咨询费用、净收入、采购成本、其他费用以及税前利润。" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "connector": { + "line": { + "color": "rgb(63, 63, 63)" + } + }, + "measure": [ + "relative", + "relative", + "total", + "relative", + "relative", + "total" + ], + "orientation": "v", + "text": [ + "+60", + "+80", + "", + "-40", + "-20", + "Total" + ], + "textposition": "outside", + "type": "waterfall", + "x": [ + "Sales", + "Consulting", + "Net revenue", + "Purchases", + "Other expenses", + "Profit before tax" + ], + "y": [ + 60, + 80, + 0, + -40, + -20, + 0 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Profit and loss statement 2018" + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig = go.Figure()\n", + "trace = go.Waterfall( orientation = \"v\",\n", + " measure = [\"relative\", \"relative\", \"total\", \"relative\", \"relative\", \"total\"],\n", + " y = [60, 80, 0, -40, -20, 0],\n", + " x = [\"Sales\", \"Consulting\", \"Net revenue\", \"Purchases\", \"Other expenses\", \"Profit before tax\"],\n", + " textposition = \"outside\",\n", + " text = [\"+60\", \"+80\", \"\", \"-40\", \"-20\", \"Total\"],\n", + " connector = {\"line\":{\"color\":\"rgb(63, 63, 63)\"}},\n", + ")\n", + "fig.add_trace(trace)\n", + "fig.update_layout(\n", + " title = \"Profit and loss statement 2018\"\n", + ")\n", + "\n", + "fig.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pyds", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ch-plotly/intro.ipynb b/ch-plotly/intro.ipynb new file mode 100644 index 0000000..c449788 --- /dev/null +++ b/ch-plotly/intro.ipynb @@ -0,0 +1,5928 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plotly 简介\n", + "\n", + "Plotly 是一个用于创建$\\textbf{交互性}$可视化图表的 Python 库。它支持多种图表类型,包括散点图、线图、条形图、饼图、3D 图等,并且提供了丰富的交互性功能,使用户能够在图表上进行缩放、平移、旋转等操作,也支持悬停显示信息、点击事件等。\n", + "\n", + "它是 Matplotlib 画图库的一个补充,有以下一些区别:\n", + "\n", + "- 使用 Matplotlib 需要较多的代码来创建和定制图表,需要显式地指定图表的各个部分,如标题、轴标签等;Plotly 是一个交互式的绘图库,可以用较少的代码生成交互式图表。\n", + "\n", + "- 默认情况下,Matplotlib 生成的图表通常是静态的,缺乏交互性。虽然可以通过一些插件或工具实现一些交互性,但不如 Plotly 易用和直观。\n", + "\n", + "- Matplotlib 是一个功能强大的通用绘图库,支持许多图表类型,包括线图、散点图、柱状图等;Plotly 同时提供一些 Matplotlib 不太容易实现的高级图表类型,如3D图表、地理图表等。\n", + "\n", + "## 安装库和导入包\n", + "\n", + "使用 `pip` 安装:\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", + "Requirement already satisfied: plotly in /Users/xu/anaconda3/envs/pyds/lib/python3.11/site-packages (5.18.0)\n", + "Requirement already satisfied: tenacity>=6.2.0 in /Users/xu/anaconda3/envs/pyds/lib/python3.11/site-packages (from plotly) (8.2.3)\n", + "Requirement already satisfied: packaging in /Users/xu/anaconda3/envs/pyds/lib/python3.11/site-packages (from plotly) (23.2)\n" + ] + } + ], + "source": [ + "## 安装包\n", + "!pip install plotly -i https://pypi.tuna.tsinghua.edu.cn/simple" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", + "Requirement already satisfied: kaleido in /Users/xu/anaconda3/envs/pyds/lib/python3.11/site-packages (0.2.1)\n" + ] + } + ], + "source": [ + "!pip install -U kaleido -i https://pypi.tuna.tsinghua.edu.cn/simple" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "如下所示,导入 Plotly (并导入其他相关库):\n", + "\n", + "```{note}\n", + "plotly.graph_object 模块包含了用于创建图表的类和方法,而使用as go的别名后,可以使用更简洁的go来调用这些类和方法,使得代码更为简洁。\n", + "\n", + "plotly.express 是一种更高级的 api 接口,通常需要更少的代码,因为它使用了一些默认设置,而且很多配置都是隐式的,适用于快速创建简单图表,而 plotly.graph_objects 更适合需要更多控制和自定义的情况。\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "import plotly.graph_objects as go\n", + "import plotly.express as px\n", + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 常用绘图步骤\n", + "\n", + "Plotly 的绘图通常遵循一定的步骤和格式。以下是一个简单的示例,展示了创建一个基本折线图的流程:\n", + "\n", + "### 类似于 Matplotlib,首先创建 `Figure` 对象。\n", + "\n", + "使用 `go.Figure()` 创建一个 `Figure` 对象,它是 Plotly 绘图的基础。可以选择添加一些初始布局信息(用`.update_layout()`方法添加,后续详细说明)。" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "## 折线图数据\n", + "x_data = [1, 2, 3, 4]\n", + "y_data = [10, 11, 12, 13]\n", + "\n", + "fig = go.Figure()\n", + "fig\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 添加轨迹 `trace`\n", + "```{note}\n", + "在 Plotly 中,trace 是一个基本的绘图元素,用于描述图表中的数据和其样式。\n", + "```\n", + "使用 `add_trace` 方法向 `Figure` 对象添加具体的图表,比如散点图、折线图等(可以在一张图上添加多个)。\n", + "\n", + "该例使用 `go.Scatter()` 表示作散点图或折线图:`x=x_data`指定了图表的x轴数据;`y=y_data`指定了图表的y轴数据;`mode='lines+markers'`设置了 `trace` 的模式,在这里,它设置为 lines+markers,表示想要在图表上同时显示线和标记;`name='My Line'`为这条 `trace` 分配一个名称。当在一个图表中有多个 `trace` (即多组数据多组图表)时,`name` 参数可以便于作出图例。" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "lines+markers", + "name": "My Line", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 10, + 11, + 12, + 13 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.add_trace(go.Scatter(x=x_data, y=y_data, mode='lines+markers', name='My Line'))\n", + "# fig.add_trace(go.Scatter(x=x_data, y=y_data, mode='markers', name='My Line'))\n", + "# fig.add_trace(go.Scatter(x=x_data, y=y_data, mode='lines', name='My Line'))\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 更新布局信息\n", + "使用 `update_layout` 方法更新图表的布局信息,包括标题、坐标轴标签等。" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "lines+markers", + "name": "My Line", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 10, + 11, + 12, + 13 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "My Plot" + }, + "xaxis": { + "title": { + "text": "X-Axis" + } + }, + "yaxis": { + "title": { + "text": "Y-Axis" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.update_layout(title='My Plot', xaxis_title='X-Axis', yaxis_title='Y-Axis')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 输出图片\n", + "\n", + "用 `.show()` 展示图片后,右上角可以选择放大缩小、保存图片等,图片中可以查看具体点位。" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "mode": "lines+markers", + "name": "My Line", + "type": "scatter", + "x": [ + 1, + 2, + 3, + 4 + ], + "y": [ + 10, + 11, + 12, + 13 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "My Plot" + }, + "xaxis": { + "title": { + "text": "X-Axis" + } + }, + "yaxis": { + "title": { + "text": "Y-Axis" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig.show()\n", + "# import kaleido\n", + "# fig.write_image(\"/Users/xu/Desktop/plotly_figure.png\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hoverinfo": "x+y", + "line": { + "width": 2 + }, + "mode": "lines", + "name": "Price", + "type": "scatter", + "x": [ + "2022-01-03T00:00:00", + "2022-01-04T00:00:00", + "2022-01-05T00:00:00", + "2022-01-06T00:00:00", + "2022-01-07T00:00:00", + "2022-01-10T00:00:00", + "2022-01-11T00:00:00", + "2022-01-12T00:00:00", + "2022-01-13T00:00:00", + "2022-01-14T00:00:00", + "2022-01-17T00:00:00", + "2022-01-18T00:00:00", + "2022-01-19T00:00:00", + "2022-01-20T00:00:00", + "2022-01-21T00:00:00", + "2022-01-24T00:00:00", + "2022-01-25T00:00:00", + "2022-01-26T00:00:00", + "2022-01-27T00:00:00", + "2022-01-28T00:00:00", + "2022-01-31T00:00:00", + "2022-02-01T00:00:00", + "2022-02-02T00:00:00", + "2022-02-03T00:00:00", + "2022-02-04T00:00:00", + "2022-02-07T00:00:00", + "2022-02-08T00:00:00", + "2022-02-09T00:00:00", + "2022-02-10T00:00:00", + "2022-02-11T00:00:00", + "2022-02-14T00:00:00", + "2022-02-15T00:00:00", + "2022-02-16T00:00:00", + "2022-02-17T00:00:00", + "2022-02-18T00:00:00", + "2022-02-21T00:00:00", + "2022-02-22T00:00:00", + "2022-02-23T00:00:00", + "2022-02-24T00:00:00", + "2022-02-25T00:00:00", + "2022-02-28T00:00:00", + "2022-03-01T00:00:00", + "2022-03-02T00:00:00", + "2022-03-03T00:00:00", + "2022-03-04T00:00:00", + "2022-03-07T00:00:00", + "2022-03-08T00:00:00", + "2022-03-09T00:00:00", + "2022-03-10T00:00:00", + "2022-03-11T00:00:00", + "2022-03-14T00:00:00", + "2022-03-15T00:00:00", + "2022-03-16T00:00:00", + "2022-03-17T00:00:00", + "2022-03-18T00:00:00", + "2022-03-21T00:00:00", + "2022-03-22T00:00:00", + "2022-03-23T00:00:00", + "2022-03-24T00:00:00", + "2022-03-25T00:00:00", + "2022-03-28T00:00:00", + "2022-03-29T00:00:00", + "2022-03-30T00:00:00", + "2022-03-31T00:00:00", + "2022-04-01T00:00:00", + "2022-04-04T00:00:00", + "2022-04-05T00:00:00", + "2022-04-06T00:00:00", + "2022-04-07T00:00:00", + "2022-04-08T00:00:00", + "2022-04-11T00:00:00", + "2022-04-12T00:00:00", + "2022-04-13T00:00:00", + "2022-04-14T00:00:00", + "2022-04-15T00:00:00", + "2022-04-18T00:00:00", + "2022-04-19T00:00:00", + "2022-04-20T00:00:00", + "2022-04-21T00:00:00", + "2022-04-22T00:00:00", + "2022-04-25T00:00:00", + "2022-04-26T00:00:00", + "2022-04-27T00:00:00", + "2022-04-28T00:00:00", + "2022-04-29T00:00:00", + "2022-05-02T00:00:00", + "2022-05-03T00:00:00", + "2022-05-04T00:00:00", + "2022-05-05T00:00:00", + "2022-05-06T00:00:00", + "2022-05-09T00:00:00", + "2022-05-10T00:00:00", + "2022-05-11T00:00:00", + "2022-05-12T00:00:00", + "2022-05-13T00:00:00", + "2022-05-16T00:00:00", + "2022-05-17T00:00:00", + "2022-05-18T00:00:00", + "2022-05-19T00:00:00", + "2022-05-20T00:00:00", + "2022-05-23T00:00:00", + "2022-05-24T00:00:00", + "2022-05-25T00:00:00", + "2022-05-26T00:00:00", + "2022-05-27T00:00:00", + "2022-05-30T00:00:00", + "2022-05-31T00:00:00", + "2022-06-01T00:00:00", + "2022-06-02T00:00:00", + "2022-06-03T00:00:00", + "2022-06-06T00:00:00", + "2022-06-07T00:00:00", + "2022-06-08T00:00:00", + "2022-06-09T00:00:00", + "2022-06-10T00:00:00", + "2022-06-13T00:00:00", + "2022-06-14T00:00:00", + "2022-06-15T00:00:00", + "2022-06-16T00:00:00", + "2022-06-17T00:00:00", + "2022-06-20T00:00:00", + "2022-06-21T00:00:00", + "2022-06-22T00:00:00", + "2022-06-23T00:00:00", + "2022-06-24T00:00:00", + "2022-06-27T00:00:00", + "2022-06-28T00:00:00", + "2022-06-29T00:00:00", + "2022-06-30T00:00:00", + "2022-07-01T00:00:00", + "2022-07-04T00:00:00", + "2022-07-05T00:00:00", + "2022-07-06T00:00:00", + "2022-07-07T00:00:00", + "2022-07-08T00:00:00", + "2022-07-11T00:00:00", + "2022-07-12T00:00:00", + "2022-07-13T00:00:00", + "2022-07-14T00:00:00", + "2022-07-15T00:00:00", + "2022-07-18T00:00:00", + "2022-07-19T00:00:00", + "2022-07-20T00:00:00", + "2022-07-21T00:00:00", + "2022-07-22T00:00:00", + "2022-07-25T00:00:00", + "2022-07-26T00:00:00", + "2022-07-27T00:00:00", + "2022-07-28T00:00:00", + "2022-07-29T00:00:00", + "2022-08-01T00:00:00", + "2022-08-02T00:00:00", + "2022-08-03T00:00:00", + "2022-08-04T00:00:00", + "2022-08-05T00:00:00", + "2022-08-08T00:00:00", + "2022-08-09T00:00:00", + "2022-08-10T00:00:00", + "2022-08-11T00:00:00", + "2022-08-12T00:00:00", + "2022-08-15T00:00:00", + "2022-08-16T00:00:00", + "2022-08-17T00:00:00", + "2022-08-18T00:00:00", + "2022-08-19T00:00:00", + "2022-08-22T00:00:00", + "2022-08-23T00:00:00", + "2022-08-24T00:00:00", + "2022-08-25T00:00:00", + "2022-08-26T00:00:00", + "2022-08-29T00:00:00", + "2022-08-30T00:00:00", + "2022-08-31T00:00:00", + "2022-09-01T00:00:00", + "2022-09-02T00:00:00", + "2022-09-05T00:00:00", + "2022-09-06T00:00:00", + "2022-09-07T00:00:00", + "2022-09-08T00:00:00", + "2022-09-09T00:00:00", + "2022-09-12T00:00:00", + "2022-09-13T00:00:00", + "2022-09-14T00:00:00", + "2022-09-15T00:00:00", + "2022-09-16T00:00:00", + "2022-09-19T00:00:00", + "2022-09-20T00:00:00", + "2022-09-21T00:00:00", + "2022-09-22T00:00:00", + "2022-09-23T00:00:00", + "2022-09-26T00:00:00", + "2022-09-27T00:00:00", + "2022-09-28T00:00:00", + "2022-09-29T00:00:00", + "2022-09-30T00:00:00", + "2022-10-03T00:00:00", + "2022-10-04T00:00:00", + "2022-10-05T00:00:00", + "2022-10-06T00:00:00", + "2022-10-07T00:00:00", + "2022-10-10T00:00:00", + "2022-10-11T00:00:00", + "2022-10-12T00:00:00", + "2022-10-13T00:00:00", + "2022-10-14T00:00:00", + "2022-10-17T00:00:00", + "2022-10-18T00:00:00", + "2022-10-19T00:00:00", + "2022-10-20T00:00:00", + "2022-10-21T00:00:00", + "2022-10-24T00:00:00", + "2022-10-25T00:00:00", + "2022-10-26T00:00:00", + "2022-10-27T00:00:00", + "2022-10-28T00:00:00", + "2022-10-31T00:00:00", + "2022-11-01T00:00:00", + "2022-11-02T00:00:00", + "2022-11-03T00:00:00", + "2022-11-04T00:00:00", + "2022-11-07T00:00:00", + "2022-11-08T00:00:00", + "2022-11-09T00:00:00", + "2022-11-10T00:00:00", + "2022-11-11T00:00:00", + "2022-11-14T00:00:00", + "2022-11-15T00:00:00", + "2022-11-16T00:00:00", + "2022-11-17T00:00:00", + "2022-11-18T00:00:00", + "2022-11-21T00:00:00", + "2022-11-22T00:00:00", + "2022-11-23T00:00:00", + "2022-11-24T00:00:00", + "2022-11-25T00:00:00", + "2022-11-28T00:00:00", + "2022-11-29T00:00:00", + "2022-11-30T00:00:00", + "2022-12-01T00:00:00", + "2022-12-02T00:00:00", + "2022-12-05T00:00:00", + "2022-12-06T00:00:00", + "2022-12-07T00:00:00", + "2022-12-08T00:00:00", + "2022-12-09T00:00:00", + "2022-12-12T00:00:00", + "2022-12-13T00:00:00", + "2022-12-14T00:00:00", + "2022-12-15T00:00:00", + "2022-12-16T00:00:00", + "2022-12-19T00:00:00", + "2022-12-20T00:00:00", + "2022-12-21T00:00:00", + "2022-12-22T00:00:00", + "2022-12-23T00:00:00", + "2022-12-26T00:00:00", + "2022-12-27T00:00:00", + "2022-12-28T00:00:00", + "2022-12-29T00:00:00", + "2022-12-30T00:00:00" + ], + "y": [ + 100, + 101.1, + 103.3, + 106.6, + 111, + 116.5, + 123.1, + 130.8, + 139.6, + 149.5, + 160.5, + 172.6, + 185.8, + 200.1, + 215.5, + 232, + 249.6, + 268.29999999999995, + 288.1, + 309, + 331, + 354.1, + 378.3, + 403.6, + 430, + 457.5, + 486.1, + 515.8, + 546.6, + 578.5, + 611.5, + 645.6, + 680.8000000000001, + 717.1, + 754.5, + 793, + 832.6, + 873.3000000000001, + 915.1, + 958, + 1002, + 1047.1, + 1093.3000000000002, + 1140.6000000000001, + 1189.0000000000002, + 1238.5000000000002, + 1289.1000000000001, + 1340.8000000000002, + 1393.6000000000001, + 1447.5000000000002, + 1502.5000000000002, + 1558.6000000000001, + 1615.8000000000002, + 1674.1000000000001, + 1733.5000000000002, + 1794.0000000000002, + 1855.6000000000001, + 1918.3000000000002, + 1982.1000000000001, + 2047.0000000000002, + 2113, + 2180.1000000000004, + 2248.3, + 2317.6000000000004, + 2388.0000000000005, + 2459.5000000000005, + 2532.1000000000004, + 2605.8, + 2680.6000000000004, + 2756.5000000000005, + 2833.5000000000005, + 2911.6000000000004, + 2990.8, + 3071.1000000000004, + 3152.5000000000005, + 3235.0000000000005, + 3318.6000000000004, + 3403.3, + 3489.1000000000004, + 3576.0000000000005, + 3664.0000000000005, + 3753.1000000000004, + 3843.3, + 3934.6000000000004, + 4027.0000000000005, + 4120.5, + 4215.1, + 4310.8, + 4407.6, + 4505.5, + 4604.5, + 4704.6, + 4805.8, + 4908.1, + 5011.5, + 5116, + 5221.6, + 5328.3, + 5436.1, + 5545, + 5655, + 5766.1, + 5878.3, + 5991.6, + 6106, + 6221.5, + 6338.1, + 6455.8, + 6574.6, + 6694.5, + 6815.5, + 6937.6, + 7060.8, + 7185.1, + 7310.5, + 7437, + 7564.6, + 7693.3, + 7823.1, + 7954, + 8086, + 8219.1, + 8353.300000000001, + 8488.6, + 8625, + 8762.5, + 8901.1, + 9040.800000000001, + 9181.6, + 9323.5, + 9466.5, + 9610.6, + 9755.800000000001, + 9902.1, + 10049.5, + 10198, + 10347.6, + 10498.300000000001, + 10650.1, + 10803, + 10957, + 11112.1, + 11268.300000000001, + 11425.6, + 11584, + 11743.5, + 11904.1, + 12065.800000000001, + 12228.6, + 12392.5, + 12557.5, + 12723.6, + 12890.800000000001, + 13059.1, + 13228.5, + 13399, + 13570.6, + 13743.300000000001, + 13917.1, + 14092, + 14268, + 14445.1, + 14623.300000000001, + 14802.6, + 14983, + 15164.5, + 15347.1, + 15530.800000000001, + 15715.6, + 15901.5, + 16088.5, + 16276.6, + 16465.800000000003, + 16656.100000000002, + 16847.500000000004, + 17040.000000000004, + 17233.600000000002, + 17428.300000000003, + 17624.100000000002, + 17821.000000000004, + 18019.000000000004, + 18218.100000000002, + 18418.300000000003, + 18619.600000000002, + 18822.000000000004, + 19025.500000000004, + 19230.100000000002, + 19435.800000000003, + 19642.600000000002, + 19850.500000000004, + 20059.500000000004, + 20269.600000000002, + 20480.800000000003, + 20693.100000000002, + 20906.500000000004, + 21121.000000000004, + 21336.600000000002, + 21553.300000000003, + 21771.100000000002, + 21990.000000000004, + 22210.000000000004, + 22431.100000000002, + 22653.300000000003, + 22876.600000000002, + 23101.000000000004, + 23326.500000000004, + 23553.100000000002, + 23780.800000000003, + 24009.600000000002, + 24239.500000000004, + 24470.500000000004, + 24702.600000000002, + 24935.800000000003, + 25170.100000000002, + 25405.500000000004, + 25642.000000000004, + 25879.600000000002, + 26118.300000000003, + 26358.100000000002, + 26599.000000000004, + 26841.000000000004, + 27084.100000000002, + 27328.300000000003, + 27573.600000000002, + 27820.000000000004, + 28067.500000000004, + 28316.100000000002, + 28565.800000000003, + 28816.600000000002, + 29068.500000000004, + 29321.500000000004, + 29575.600000000002, + 29830.800000000003, + 30087.100000000002, + 30344.500000000004, + 30603.000000000004, + 30862.600000000002, + 31123.300000000003, + 31385.100000000002, + 31648.000000000004, + 31912.000000000004, + 32177.100000000002, + 32443.300000000003, + 32710.600000000002, + 32979, + 33248.5, + 33519.1, + 33790.799999999996, + 34063.6, + 34337.5, + 34612.5, + 34888.6, + 35165.799999999996, + 35444.1, + 35723.5, + 36004, + 36285.6, + 36568.299999999996, + 36852.1, + 37137 + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "showlakes": true, + "showland": true, + "subunitcolor": "#506784" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "dark" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, + "ternary": { + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "金融数据可视化" + }, + "xaxis": { + "title": { + "text": "日期" + } + }, + "yaxis": { + "title": { + "text": "价格" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import pandas as pd\n", + "import plotly.graph_objects as go\n", + "\n", + "# 生成模拟的金融时间序列数据\n", + "date_rng = pd.date_range(start='2022-01-01', end='2022-12-31', freq='B')\n", + "data = pd.DataFrame(date_rng, columns=['date'])\n", + "data['price'] = 100 + (pd.Series(range(len(date_rng))) + pd.Series(range(len(date_rng))) * 0.1).cumsum()\n", + "data['returns'] = data['price'].pct_change()\n", + "\n", + "# 创建折线图\n", + "fig = go.Figure()\n", + "\n", + "# 基础绘图 - 价格走势\n", + "fig.add_trace(go.Scatter(x=data['date'], y=data['price'], mode='lines', name='Price'))\n", + "\n", + "# 交互性 - 添加悬停信息\n", + "fig.update_traces(hoverinfo='x+y', line=dict(width=2))\n", + "\n", + "# 添加布局信息\n", + "fig.update_layout(\n", + " title='金融数据可视化',\n", + " xaxis_title='日期',\n", + " yaxis_title='价格',\n", + " template='plotly_dark' # 使用暗色主题\n", + ")\n", + "\n", + "# 显示图表\n", + "fig.show()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "close": [ + 155, + 158, + 163 + ], + "high": [ + 160, + 162, + 165 + ], + "low": [ + 145, + 152, + 158 + ], + "open": [ + 150, + 155, + 160 + ], + "type": "candlestick", + "x": [ + "2022-01-01", + "2022-01-02", + "2022-01-03" + ] + } + ], + "layout": { + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "股票蜡烛图" + }, + "xaxis": { + "title": { + "text": "日期" + } + }, + "yaxis": { + "title": { + "text": "价格" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import plotly.graph_objects as go\n", + "\n", + "# 模拟蜡烛图数据\n", + "candle_data = {\n", + " 'date': ['2022-01-01', '2022-01-02', '2022-01-03'],\n", + " 'open': [150, 155, 160],\n", + " 'high': [160, 162, 165],\n", + " 'low': [145, 152, 158],\n", + " 'close': [155, 158, 163]\n", + "}\n", + "\n", + "fig = go.Figure(data=[go.Candlestick(x=candle_data['date'],\n", + " open=candle_data['open'],\n", + " high=candle_data['high'],\n", + " low=candle_data['low'],\n", + " close=candle_data['close'])])\n", + "\n", + "fig.update_layout(title='股票蜡烛图', xaxis_title='日期', yaxis_title='价格')\n", + "fig.show()\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pyds", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}