From 7c63767414a582c4e8ca8c80e19c319e11e219a3 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 11:38:07 -0500 Subject: [PATCH 01/13] Add histogram texttemplate example --- doc/python/histograms.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/python/histograms.md b/doc/python/histograms.md index 757345312c4..c942abfb082 100644 --- a/doc/python/histograms.md +++ b/doc/python/histograms.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.4.2 + format_version: '1.3' + jupytext_version: 1.13.4 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.7 + version: 3.7.11 plotly: description: How to make Histograms in Python with Plotly. display_as: statistical @@ -340,6 +340,24 @@ fig.update_layout( fig.show() ``` +### Histogram Bar Text + + +You can add text to histogram bars using the `texttemplate` argument. In this example we add the x-axis values as text following the format `%{variable}`. We also adjust the size of the text using `textfont_size`. + + + +```python +import plotly.graph_objects as go + +numbers = ["5", "10", "3", "10", "5", "8", "5", "5"] + +fig = go.Figure() +fig.add_trace(go.Histogram(x=numbers, name="count", texttemplate="%{x}", textfont_size=20)) + +fig.show() +``` + ### Cumulative Histogram ```python From 5c00b077cced0f5559237a66b6a30b3a79c7ef12 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 11:45:05 -0500 Subject: [PATCH 02/13] 2D Histogram text on points example --- doc/python/2D-Histogram.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/python/2D-Histogram.md b/doc/python/2D-Histogram.md index d8218ea4062..e449af4f50e 100644 --- a/doc/python/2D-Histogram.md +++ b/doc/python/2D-Histogram.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.3.1 + format_version: '1.3' + jupytext_version: 1.13.4 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.8 + version: 3.7.11 plotly: description: How to make 2D Histograms in Python with Plotly. display_as: statistical @@ -235,5 +235,25 @@ fig.update_layout( fig.show() ``` +### Text on 2D Histogram Points + + +In this example we add text to 2D-Histogram points. We use the values from the `z` attribute for the text, adding them following the format **%{variable}**. + +```python +import plotly.graph_objects as go +from plotly import data + +df = data.tips() + +fig = go.Figure(go.Histogram2d( + x=df.total_bill, + y=df.tip, + texttemplate= "%{z}" + )) + +fig.show() +``` + #### Reference See https://plotly.com/python/reference/histogram2d/ for more information and chart attribute options! From 7a62e5c9866d0198c18b3befa33a28bb466d4a7f Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 11:48:48 -0500 Subject: [PATCH 03/13] Heatmap text example --- doc/python/heatmaps.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/python/heatmaps.md b/doc/python/heatmaps.md index 45ab4c6e371..0cb4900a457 100644 --- a/doc/python/heatmaps.md +++ b/doc/python/heatmaps.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.6.0 + format_version: '1.3' + jupytext_version: 1.13.4 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.6 + version: 3.7.11 plotly: description: How to make Heatmaps in Python with Plotly. display_as: scientific @@ -197,6 +197,25 @@ fig.update_layout( fig.show() ``` +### Text on Heatmap Points + + +In this example we add text to heatmap points. We use the values from the `text` attribute for the text. + +```python +import plotly.graph_objects as go +from plotly import data + +df = data.tips() + +fig = go.Figure(go.Histogram2d( + x=df.total_bill, + y=df.tip, + texttemplate= "%{z}" + )) +fig.show() +``` + ### Heatmap and datashader Arrays of rasterized values build by datashader can be visualized using From cbe9b40380526e9331ca8efc05f3f0878d61ee1a Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 12:33:02 -0500 Subject: [PATCH 04/13] Horizontal colorbar example --- doc/python/colorscales.md | 48 ++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/doc/python/colorscales.md b/doc/python/colorscales.md index 0520fa04d9b..3b2810a2192 100644 --- a/doc/python/colorscales.md +++ b/doc/python/colorscales.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.6.0 + format_version: '1.3' + jupytext_version: 1.13.4 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,10 +20,10 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.6 + version: 3.7.11 plotly: - description: How to set, create and control continuous color scales and color bars - in scatter, bar, map and heatmap figures. + description: How to set, create and control continuous color scales and color + bars in scatter, bar, map and heatmap figures. display_as: file_settings has_thumbnail: true ipynb: ~notebook_demo/187 @@ -518,6 +518,42 @@ fig.add_trace(go.Heatmap( fig.show() ``` +### Color Bar Displayed Horizontally + + +By default, color bars are displayed vertically. You can change a color bar to be displayed horizontally by setting `orientation`=`h`. + +```python +import plotly.graph_objects as go + +import six.moves.urllib +import json + +# Load heatmap data +response = six.moves.urllib.request.urlopen( + "https://raw.githubusercontent.com/plotly/datasets/master/custom_heatmap_colorscale.json") +dataset = json.load(response) + +# Create and show figure +fig = go.Figure() + +fig.add_trace(go.Heatmap( + z=dataset["z"], + colorbar=dict( + title="Surface Heat", + titleside="top", + tickmode="array", + tickvals=[2, 50, 100], + ticktext=["Cool", "Mild", "Hot"], + ticks="outside", + orientation='h' + + ) +)) + +fig.show() +``` + ### Sharing a Color Axis with Graph Objects To share colorscale information in multiple subplots, you can use [coloraxis](https://plotly.com/javascript/reference/scatter/#scatter-marker-line-coloraxis). From 87c9a10ada51cdf2ac2337d52cb914be1ef038e9 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 12:33:21 -0500 Subject: [PATCH 05/13] Correct examples and text --- doc/python/2D-Histogram.md | 2 +- doc/python/heatmaps.md | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/python/2D-Histogram.md b/doc/python/2D-Histogram.md index e449af4f50e..20c82a4990c 100644 --- a/doc/python/2D-Histogram.md +++ b/doc/python/2D-Histogram.md @@ -238,7 +238,7 @@ fig.show() ### Text on 2D Histogram Points -In this example we add text to 2D-Histogram points. We use the values from the `z` attribute for the text, adding them following the format **%{variable}**. +In this example we add text to 2D Histogram points. We use the values from the `z` attribute for the text. ```python import plotly.graph_objects as go diff --git a/doc/python/heatmaps.md b/doc/python/heatmaps.md index 0cb4900a457..f0be26c9d05 100644 --- a/doc/python/heatmaps.md +++ b/doc/python/heatmaps.md @@ -204,15 +204,16 @@ In this example we add text to heatmap points. We use the values from the `text` ```python import plotly.graph_objects as go -from plotly import data -df = data.tips() +fig = go.Figure(data=go.Heatmap( + z=[[1, 20, 30], + [20, 1, 60], + [30, 60, 1]], + text=[['one', 'twenty', 'thirty'], + ['twenty', 'one', 'sixty'], + ['thirty', 'sixty', 'one']], + texttemplate="%{text}")) -fig = go.Figure(go.Histogram2d( - x=df.total_bill, - y=df.tip, - texttemplate= "%{z}" - )) fig.show() ``` From 48795aae90dfcb4ff062cf4831efc35f551c2432 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 13:42:34 -0500 Subject: [PATCH 06/13] Added px example, edited graph objects example --- doc/python/heatmaps.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/python/heatmaps.md b/doc/python/heatmaps.md index f0be26c9d05..73664cfb3d3 100644 --- a/doc/python/heatmaps.md +++ b/doc/python/heatmaps.md @@ -86,6 +86,22 @@ fig.update_xaxes(side="top") fig.show() ``` +### Adding and customizing text on points + + +You can add text to heatmap points with `.update_traces(texttemplate="%{variable}")`. Here we use the values of the `z` attribute for `variable`. We also customize the font size with `textfont`. + +```python +import plotly.express as px + +df = px.data.medals_wide(indexed=True) +fig = px.imshow(df) +fig.update_traces(texttemplate="%{z}") +fig.update_traces(textfont={"size":20}) + +fig.show() +``` + ### Basic Heatmap with `plotly.graph_objects` If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Heatmap` class from `plotly.graph_objects`](/python/graph-objects/). @@ -200,7 +216,7 @@ fig.show() ### Text on Heatmap Points -In this example we add text to heatmap points. We use the values from the `text` attribute for the text. +In this example we add text to heatmap points using `texttemplate`. We use the values from the `text` attribute for the text. We also adjust the font size using `textfont`. ```python import plotly.graph_objects as go @@ -212,7 +228,8 @@ fig = go.Figure(data=go.Heatmap( text=[['one', 'twenty', 'thirty'], ['twenty', 'one', 'sixty'], ['thirty', 'sixty', 'one']], - texttemplate="%{text}")) + texttemplate="%{text}", + textfont={"size":20})) fig.show() ``` From 997aad389a40451bdfa776fb89f74944faaab17d Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 14:11:41 -0500 Subject: [PATCH 07/13] Added px example --- doc/python/2D-Histogram.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/python/2D-Histogram.md b/doc/python/2D-Histogram.md index 20c82a4990c..42f392428bc 100644 --- a/doc/python/2D-Histogram.md +++ b/doc/python/2D-Histogram.md @@ -82,6 +82,17 @@ fig = px.density_heatmap(df, x="total_bill", y="tip", facet_row="sex", facet_col fig.show() ``` +You can add `z` as text to 2D Histogram points using `fig.update_traces(texttemplate="%{z}")` + +```python +import plotly.express as px +df = px.data.tips() + +fig = px.density_heatmap(df, x="total_bill", y="tip") +fig.update_traces(texttemplate="%{z}") +fig.show() +``` + ### Other aggregation functions than `count` By passing in a `z` value and a `histfunc`, density heatmaps can perform basic aggregation operations. Here we show average Sepal Length grouped by Petal Length and Petal Width for the Iris dataset. From ec44961c6af543e2f3192031126025d62d087df5 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 13 Dec 2021 14:37:12 -0500 Subject: [PATCH 08/13] histogram examples for px --- doc/python/2D-Histogram.md | 2 +- doc/python/histograms.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/python/2D-Histogram.md b/doc/python/2D-Histogram.md index 42f392428bc..35cc9312417 100644 --- a/doc/python/2D-Histogram.md +++ b/doc/python/2D-Histogram.md @@ -82,7 +82,7 @@ fig = px.density_heatmap(df, x="total_bill", y="tip", facet_row="sex", facet_col fig.show() ``` -You can add `z` as text to 2D Histogram points using `fig.update_traces(texttemplate="%{z}")` +You can add the `z` values as text to 2D Histogram points using `fig.update_traces(texttemplate="%{z}")` ```python import plotly.express as px diff --git a/doc/python/histograms.md b/doc/python/histograms.md index c942abfb082..4506126d4a6 100644 --- a/doc/python/histograms.md +++ b/doc/python/histograms.md @@ -208,6 +208,25 @@ fig = px.histogram(df, x="total_bill", color="sex", marginal="rug", # can be `bo fig.show() ``` +### Adding bar text + + +You can add text to histogram bars using `fig.update_traces(texttemplate="%{variable}")`, where `variable` is the text to add. In this example, we add the y-axis values to the bars. We get these values following the **Accessing the counts (y-axis) values** example above. + +```python +import plotly.express as px +import numpy as np + +df = px.data.tips() + +counts, bins = np.histogram(df.total_bill, bins=range(0, 60, 5)) +bins = 0.5 * (bins[:-1] + bins[1:]) + +fig = px.bar(x=bins, y=counts, labels={'x':'total_bill', 'y':'count'}) +fig.update_traces(texttemplate="%{y}") +fig.show() +``` + ## Histograms with go.Histogram If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Histogram` class from `plotly.graph_objects`](/python/graph-objects/). All of the available histogram options are described in the histogram section of the reference page: https://plotly.com/python/reference#histogram. From 1968b094e4e387dbc22daad2743821d555f785d4 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 14 Dec 2021 15:14:20 -0500 Subject: [PATCH 09/13] imshow examples, plus minor edits --- doc/python/annotated-heatmap.md | 61 +++++++++++++++++++++++++++++---- doc/python/colorscales.md | 14 ++------ doc/python/heatmaps.md | 2 +- doc/python/histograms.md | 4 +-- doc/python/imshow.md | 8 ++--- 5 files changed, 63 insertions(+), 26 deletions(-) diff --git a/doc/python/annotated-heatmap.md b/doc/python/annotated-heatmap.md index 1e27c221bb3..d94f1bea2c1 100644 --- a/doc/python/annotated-heatmap.md +++ b/doc/python/annotated-heatmap.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.1.1 + format_version: '1.3' + jupytext_version: 1.13.4 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.7 + version: 3.7.11 plotly: description: How to make Annotated Heatmaps in Python with Plotly. display_as: scientific @@ -34,9 +34,52 @@ jupyter: thumbnail: thumbnail/ann_heat.jpg --- -#### Simple Annotated Heatmap +### Annotated Heatmaps with plotly.express and px.imshow + + +These examples use [px.imshow](/python/imshow) to create Annotated Heatmaps. px.imshow is the best way creating heatmaps with z-annotations. + + +#### Basic Annotated Heatmap for z-annotations + + +After creating a figure with `px.imshow`, you can add z-annotations with `.update_traces(texttemplate="%{z}")`. + +```python +import plotly.express as px + +df = px.data.medals_wide(indexed=True) + +fig = px.imshow(df) +fig.update_traces(texttemplate="%{z}") + +fig.show() +``` + +#### Custom Font + + +You can make changes to the font using `textfont`. Here we set the font size to 20. -This page details the use of a [figure factory](/python/figure-factories/). For more examples with Heatmaps, see [this page](/python/heatmaps/). +```python +import plotly.express as px + +df = px.data.medals_wide(indexed=True) + +fig = px.imshow(df) +fig.update_traces(texttemplate="%{z}") +fig.update_traces(textfont={"size":20}) + +fig.show() +``` + +### Annotated Heatmaps with [figure factory](/python/figure-factories/). For more examples with Heatmaps, see [this page](/python/heatmaps/). + + +The remaining examples show how to create Annotated Heatmaps with [figure factory](/python/figure-factories/). For more examples with Heatmaps, see [this page](/python/heatmaps/). + + +#### Simple Annotated Heatmap ```python import plotly.figure_factory as ff @@ -201,6 +244,12 @@ fig.update_layout(title_text='Periodic Table') fig.show() ``` +#### Annotations with plotly.express + +```python + +``` + #### Reference For more info on Plotly heatmaps, see: https://plotly.com/python/reference/heatmap/.
For more info on using colorscales with Plotly see: https://plotly.com/python/heatmap-and-contour-colorscales/
For more info on `ff.create_annotated_heatmap()`, see the [full function reference](https://plotly.com/python-api-reference/generated/plotly.figure_factory.create_annotated_heatmap.html#plotly.figure_factory.create_annotated_heatmap) diff --git a/doc/python/colorscales.md b/doc/python/colorscales.md index 3b2810a2192..e7e10c2dcec 100644 --- a/doc/python/colorscales.md +++ b/doc/python/colorscales.md @@ -521,7 +521,7 @@ fig.show() ### Color Bar Displayed Horizontally -By default, color bars are displayed vertically. You can change a color bar to be displayed horizontally by setting `orientation`=`h`. +By default, color bars are displayed vertically. You can change a color bar to be displayed horizontally by setting the `colorbar` `orientation` attribute to `h`. ```python import plotly.graph_objects as go @@ -539,17 +539,7 @@ fig = go.Figure() fig.add_trace(go.Heatmap( z=dataset["z"], - colorbar=dict( - title="Surface Heat", - titleside="top", - tickmode="array", - tickvals=[2, 50, 100], - ticktext=["Cool", "Mild", "Hot"], - ticks="outside", - orientation='h' - - ) -)) + colorbar=dict(orientation='h'))) fig.show() ``` diff --git a/doc/python/heatmaps.md b/doc/python/heatmaps.md index 73664cfb3d3..8ab10c01586 100644 --- a/doc/python/heatmaps.md +++ b/doc/python/heatmaps.md @@ -216,7 +216,7 @@ fig.show() ### Text on Heatmap Points -In this example we add text to heatmap points using `texttemplate`. We use the values from the `text` attribute for the text. We also adjust the font size using `textfont`. +In this example we add text to heatmap points using `texttemplate`. We use the values of the `text` attribute for the text. We also adjust the font size using `textfont`. ```python import plotly.graph_objects as go diff --git a/doc/python/histograms.md b/doc/python/histograms.md index 4506126d4a6..6e796ca1672 100644 --- a/doc/python/histograms.md +++ b/doc/python/histograms.md @@ -362,9 +362,7 @@ fig.show() ### Histogram Bar Text -You can add text to histogram bars using the `texttemplate` argument. In this example we add the x-axis values as text following the format `%{variable}`. We also adjust the size of the text using `textfont_size`. - - +You can add text to histogram bars using the `texttemplate` argument. In this example we add the x-axis values as text following the format `%{variable}`. We also adjust the size of the text using `textfont_size`. ```python import plotly.graph_objects as go diff --git a/doc/python/imshow.md b/doc/python/imshow.md index 1ca97b4b5f9..869bb181903 100644 --- a/doc/python/imshow.md +++ b/doc/python/imshow.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.4.2 + format_version: '1.3' + jupytext_version: 1.13.4 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.7 + version: 3.7.11 plotly: description: How to display image data in Python with Plotly. display_as: scientific From caefc50294a10bfa87e3c3e76802ac28d464fbdb Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 14 Dec 2021 15:31:10 -0500 Subject: [PATCH 10/13] Minor edits, removed whitespace --- doc/python/2D-Histogram.md | 1 - doc/python/annotated-heatmap.md | 5 +---- doc/python/colorscales.md | 1 - doc/python/heatmaps.md | 4 +--- doc/python/histograms.md | 2 -- 5 files changed, 2 insertions(+), 11 deletions(-) diff --git a/doc/python/2D-Histogram.md b/doc/python/2D-Histogram.md index 35cc9312417..ea2543cf728 100644 --- a/doc/python/2D-Histogram.md +++ b/doc/python/2D-Histogram.md @@ -248,7 +248,6 @@ fig.show() ### Text on 2D Histogram Points - In this example we add text to 2D Histogram points. We use the values from the `z` attribute for the text. ```python diff --git a/doc/python/annotated-heatmap.md b/doc/python/annotated-heatmap.md index d94f1bea2c1..1c5e7a11e91 100644 --- a/doc/python/annotated-heatmap.md +++ b/doc/python/annotated-heatmap.md @@ -36,13 +36,11 @@ jupyter: ### Annotated Heatmaps with plotly.express and px.imshow - -These examples use [px.imshow](/python/imshow) to create Annotated Heatmaps. px.imshow is the best way creating heatmaps with z-annotations. +These examples use [px.imshow](/python/imshow) to create Annotated Heatmaps. px.imshow is the recommended way to create heatmaps with z-annotations. #### Basic Annotated Heatmap for z-annotations - After creating a figure with `px.imshow`, you can add z-annotations with `.update_traces(texttemplate="%{z}")`. ```python @@ -58,7 +56,6 @@ fig.show() #### Custom Font - You can make changes to the font using `textfont`. Here we set the font size to 20. ```python diff --git a/doc/python/colorscales.md b/doc/python/colorscales.md index e7e10c2dcec..4306f6fff76 100644 --- a/doc/python/colorscales.md +++ b/doc/python/colorscales.md @@ -520,7 +520,6 @@ fig.show() ### Color Bar Displayed Horizontally - By default, color bars are displayed vertically. You can change a color bar to be displayed horizontally by setting the `colorbar` `orientation` attribute to `h`. ```python diff --git a/doc/python/heatmaps.md b/doc/python/heatmaps.md index 8ab10c01586..192218aa9c3 100644 --- a/doc/python/heatmaps.md +++ b/doc/python/heatmaps.md @@ -88,7 +88,6 @@ fig.show() ### Adding and customizing text on points - You can add text to heatmap points with `.update_traces(texttemplate="%{variable}")`. Here we use the values of the `z` attribute for `variable`. We also customize the font size with `textfont`. ```python @@ -215,8 +214,7 @@ fig.show() ### Text on Heatmap Points - -In this example we add text to heatmap points using `texttemplate`. We use the values of the `text` attribute for the text. We also adjust the font size using `textfont`. +In this example we add text to heatmap points using `texttemplate`. We use the values from the `text` attribute for the text. We also adjust the font size using `textfont`. ```python import plotly.graph_objects as go diff --git a/doc/python/histograms.md b/doc/python/histograms.md index 6e796ca1672..485cd180cfc 100644 --- a/doc/python/histograms.md +++ b/doc/python/histograms.md @@ -210,7 +210,6 @@ fig.show() ### Adding bar text - You can add text to histogram bars using `fig.update_traces(texttemplate="%{variable}")`, where `variable` is the text to add. In this example, we add the y-axis values to the bars. We get these values following the **Accessing the counts (y-axis) values** example above. ```python @@ -361,7 +360,6 @@ fig.show() ### Histogram Bar Text - You can add text to histogram bars using the `texttemplate` argument. In this example we add the x-axis values as text following the format `%{variable}`. We also adjust the size of the text using `textfont_size`. ```python From 6da32ca7c20290179001d0ec3b7c0b120a28b6c1 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 14 Dec 2021 15:35:17 -0500 Subject: [PATCH 11/13] Removed extra heding --- doc/python/annotated-heatmap.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/python/annotated-heatmap.md b/doc/python/annotated-heatmap.md index 1c5e7a11e91..eeb08f5920c 100644 --- a/doc/python/annotated-heatmap.md +++ b/doc/python/annotated-heatmap.md @@ -72,7 +72,6 @@ fig.show() ### Annotated Heatmaps with [figure factory](/python/figure-factories/). For more examples with Heatmaps, see [this page](/python/heatmaps/). - The remaining examples show how to create Annotated Heatmaps with [figure factory](/python/figure-factories/). For more examples with Heatmaps, see [this page](/python/heatmaps/). @@ -241,12 +240,6 @@ fig.update_layout(title_text='Periodic Table') fig.show() ``` -#### Annotations with plotly.express - -```python - -``` - #### Reference For more info on Plotly heatmaps, see: https://plotly.com/python/reference/heatmap/.
For more info on using colorscales with Plotly see: https://plotly.com/python/heatmap-and-contour-colorscales/
For more info on `ff.create_annotated_heatmap()`, see the [full function reference](https://plotly.com/python-api-reference/generated/plotly.figure_factory.create_annotated_heatmap.html#plotly.figure_factory.create_annotated_heatmap) From 9638675f29b23404de63442cec7b42482ff70354 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 15 Dec 2021 14:24:34 -0500 Subject: [PATCH 12/13] Revert version changes --- doc/python/imshow.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/python/imshow.md b/doc/python/imshow.md index 869bb181903..1ca97b4b5f9 100644 --- a/doc/python/imshow.md +++ b/doc/python/imshow.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.3' - jupytext_version: 1.13.4 + format_version: '1.2' + jupytext_version: 1.4.2 kernelspec: - display_name: Python 3 (ipykernel) + display_name: Python 3 language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.11 + version: 3.7.7 plotly: description: How to display image data in Python with Plotly. display_as: scientific From c19b99a745af1911ef36384ab59369ca130bf78a Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 15 Dec 2021 14:56:39 -0500 Subject: [PATCH 13/13] Updated histogram example --- doc/python/histograms.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/python/histograms.md b/doc/python/histograms.md index 485cd180cfc..30f620dd2c1 100644 --- a/doc/python/histograms.md +++ b/doc/python/histograms.md @@ -210,18 +210,12 @@ fig.show() ### Adding bar text -You can add text to histogram bars using `fig.update_traces(texttemplate="%{variable}")`, where `variable` is the text to add. In this example, we add the y-axis values to the bars. We get these values following the **Accessing the counts (y-axis) values** example above. +You can add text to histogram bars using `fig.update_traces(texttemplate="%{variable}")`, where `variable` is the text to add. In this example, we add the y-axis values to the bars. ```python import plotly.express as px -import numpy as np - df = px.data.tips() - -counts, bins = np.histogram(df.total_bill, bins=range(0, 60, 5)) -bins = 0.5 * (bins[:-1] + bins[1:]) - -fig = px.bar(x=bins, y=counts, labels={'x':'total_bill', 'y':'count'}) +fig = px.histogram(df, x="total_bill", y="tip", histfunc='avg', nbins=8) fig.update_traces(texttemplate="%{y}") fig.show() ```