From 5985930eefbe7c9d7da46f8a31003995305556d9 Mon Sep 17 00:00:00 2001 From: Martino Mensio Date: Mon, 18 Sep 2023 22:03:19 +0200 Subject: [PATCH 01/18] Update dendrogram.md np.float has been removed, using float instead --- doc/python/dendrogram.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/dendrogram.md b/doc/python/dendrogram.md index c34bb4e45e9..0fe8968f202 100644 --- a/doc/python/dendrogram.md +++ b/doc/python/dendrogram.md @@ -92,7 +92,7 @@ from scipy.spatial.distance import pdist, squareform # get data data = np.genfromtxt("http://files.figshare.com/2133304/ExpRawData_E_TABM_84_A_AFFY_44.tab", names=True,usecols=tuple(range(1,30)),dtype=float, delimiter="\t") -data_array = data.view((np.float, len(data.dtype.names))) +data_array = data.view((float, len(data.dtype.names))) data_array = data_array.transpose() labels = data.dtype.names From e1e2eedb0b3506281619e0379066bc233707198f Mon Sep 17 00:00:00 2001 From: Mahot Descelliers Date: Fri, 27 Oct 2023 10:58:31 +0200 Subject: [PATCH 02/18] Fix broken markdown link in figure-labels.md --- doc/python/figure-labels.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/figure-labels.md b/doc/python/figure-labels.md index 633c343371f..fd939df389e 100644 --- a/doc/python/figure-labels.md +++ b/doc/python/figure-labels.md @@ -124,7 +124,7 @@ IFrame(snippet_url + 'figure-labels', width='100%', height=1200) ### Manual Labelling with Graph Objects -When using (graph objects)[/python/graph-objects/] rather than [Plotly Express](/python/plotly-express/), you will need to explicitly label traces and axes: +When using [graph objects](/python/graph-objects/) rather than [Plotly Express](/python/plotly-express/), you will need to explicitly label traces and axes: ```python import plotly.graph_objects as go From 90b29f610839e3f7cea53bf98a8d9757f6826074 Mon Sep 17 00:00:00 2001 From: mahotd Date: Thu, 30 Nov 2023 17:52:27 +0100 Subject: [PATCH 03/18] Fix `suplot` typo in doc --- doc/python/icicle-charts.md | 2 +- doc/python/sunburst-charts.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/python/icicle-charts.md b/doc/python/icicle-charts.md index ea6eeb0653c..540f9f7e82c 100644 --- a/doc/python/icicle-charts.md +++ b/doc/python/icicle-charts.md @@ -232,7 +232,7 @@ fig.show() ### Large Number of Slices -This example uses a [plotly grid attribute](https://plotly.com/python/reference/layout/#layout-grid) for the suplots. Reference the row and column destination using the [domain](https://plotly.com/python/reference/icicle/#icicle-domain) attribute. +This example uses a [plotly grid attribute](https://plotly.com/python/reference/layout/#layout-grid) for the subplots. Reference the row and column destination using the [domain](https://plotly.com/python/reference/icicle/#icicle-domain) attribute. ```python import plotly.graph_objects as go diff --git a/doc/python/sunburst-charts.md b/doc/python/sunburst-charts.md index 5e589e438fe..e22f9f9dd7b 100644 --- a/doc/python/sunburst-charts.md +++ b/doc/python/sunburst-charts.md @@ -214,7 +214,7 @@ fig.show() ### Large Number of Slices -This example uses a [plotly grid attribute](https://plotly.com/python/reference/layout/#layout-grid) for the suplots. Reference the row and column destination using the [domain](https://plotly.com/python/reference/sunburst/#sunburst-domain) attribute. +This example uses a [plotly grid attribute](https://plotly.com/python/reference/layout/#layout-grid) for the subplots. Reference the row and column destination using the [domain](https://plotly.com/python/reference/sunburst/#sunburst-domain) attribute. ```python import plotly.graph_objects as go From 054938b2e5d59a65ebe5a8655e9a57bf925284ea Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Thu, 14 Dec 2023 14:53:40 -0500 Subject: [PATCH 04/18] remove stamen --- doc/python/filled-area-on-mapbox.md | 6 +++--- doc/python/lines-on-mapbox.md | 6 +++--- doc/python/mapbox-density-heatmaps.md | 8 ++++---- doc/python/mapbox-layers.md | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/python/filled-area-on-mapbox.md b/doc/python/filled-area-on-mapbox.md index 0db09233d9e..2cd389642ae 100644 --- a/doc/python/filled-area-on-mapbox.md +++ b/doc/python/filled-area-on-mapbox.md @@ -60,7 +60,7 @@ fig = go.Figure(go.Scattermapbox( fig.update_layout( mapbox = { - 'style': "stamen-terrain", + 'style': "open-street-map", 'center': {'lon': -73, 'lat': 46 }, 'zoom': 5}, showlegend = False) @@ -81,7 +81,7 @@ fig = go.Figure(go.Scattermapbox( lat = [30, 6, 6, 30, 30, None, 20, 30, 30, 20, 20, None, 40, 50, 50, 40, 40])) fig.update_layout( - mapbox = {'style': "stamen-terrain", 'center': {'lon': 30, 'lat': 30}, 'zoom': 2}, + mapbox = {'style': "open-street-map", 'center': {'lon': 30, 'lat': 30}, 'zoom': 2}, showlegend = False, margin = {'l':0, 'r':0, 'b':0, 't':0}) @@ -102,7 +102,7 @@ fig = go.Figure(go.Scattermapbox( fig.update_layout( mapbox = { - 'style': "stamen-terrain", + 'style': "open-street-map", 'center': { 'lon': -73.6, 'lat': 45.5}, 'zoom': 12, 'layers': [{ 'source': { diff --git a/doc/python/lines-on-mapbox.md b/doc/python/lines-on-mapbox.md index 3d7bc953175..20bf2fc2726 100644 --- a/doc/python/lines-on-mapbox.md +++ b/doc/python/lines-on-mapbox.md @@ -51,7 +51,7 @@ import plotly.express as px fig = px.line_mapbox(us_cities, lat="lat", lon="lon", color="State", zoom=3, height=300) -fig.update_layout(mapbox_style="stamen-terrain", mapbox_zoom=4, mapbox_center_lat = 41, +fig.update_layout(mapbox_style="open-street-map", mapbox_zoom=4, mapbox_center_lat = 41, margin={"r":0,"t":0,"l":0,"b":0}) fig.show() @@ -95,7 +95,7 @@ for feature, name in zip(geo_df.geometry, geo_df.name): names = np.append(names, None) fig = px.line_mapbox(lat=lats, lon=lons, hover_name=names, - mapbox_style="stamen-terrain", zoom=1) + mapbox_style="open-street-map", zoom=1) fig.show() ``` @@ -123,7 +123,7 @@ fig.update_layout( margin ={'l':0,'t':0,'b':0,'r':0}, mapbox = { 'center': {'lon': 10, 'lat': 10}, - 'style': "stamen-terrain", + 'style': "open-street-map", 'center': {'lon': -20, 'lat': -20}, 'zoom': 1}) diff --git a/doc/python/mapbox-density-heatmaps.md b/doc/python/mapbox-density-heatmaps.md index 9ccdba1ce13..5687e378161 100644 --- a/doc/python/mapbox-density-heatmaps.md +++ b/doc/python/mapbox-density-heatmaps.md @@ -37,7 +37,7 @@ jupyter: To plot on Mapbox maps with Plotly you _may_ need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information. -### Stamen Terrain base map (no token needed): density mapbox with `plotly.express` +### OpenStreetMap base map (no token needed): density mapbox with `plotly.express` [Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on a variety of types of data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/). @@ -50,11 +50,11 @@ df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earth import plotly.express as px fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10, center=dict(lat=0, lon=180), zoom=0, - mapbox_style="stamen-terrain") + mapbox_style="open-street-map") fig.show() ``` -### Stamen Terrain base map (no token needed): density mapbox with `plotly.graph_objects` +### OpenStreetMap base map (no token needed): density mapbox with `plotly.graph_objects` If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Densitymapbox` class from `plotly.graph_objects`](/python/graph-objects/). @@ -65,7 +65,7 @@ quakes = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/e import plotly.graph_objects as go fig = go.Figure(go.Densitymapbox(lat=quakes.Latitude, lon=quakes.Longitude, z=quakes.Magnitude, radius=10)) -fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180) +fig.update_layout(mapbox_style="open-street-map", mapbox_center_lon=180) fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}) fig.show() ``` diff --git a/doc/python/mapbox-layers.md b/doc/python/mapbox-layers.md index be8d238bef4..993e4d0bca9 100644 --- a/doc/python/mapbox-layers.md +++ b/doc/python/mapbox-layers.md @@ -64,7 +64,7 @@ The word "mapbox" in the trace names and `layout.mapbox` refers to the Mapbox GL The accepted values for `layout.mapbox.style` are one of: - `"white-bg"` yields an empty white canvas which results in no external HTTP requests -- `"open-street-map"`, `"carto-positron"`, `"carto-darkmatter"`, `"stamen-terrain"`, `"stamen-toner"` or `"stamen-watercolor"` yield maps composed of _raster_ tiles from various public tile servers which do not require signups or access tokens +- `"open-street-map"`, `"carto-positron"`, and `"carto-darkmatter"` yield maps composed of _raster_ tiles from various public tile servers which do not require signups or access tokens. There is currently a known issue with `"stamen-terrain"`, `"stamen-toner"` and `"stamen-watercolor"` tiles, which will be fixed in a future Plotly.py release. - `"basic"`, `"streets"`, `"outdoors"`, `"light"`, `"dark"`, `"satellite"`, or `"satellite-streets"` yield maps composed of _vector_ tiles from the Mapbox service, and _do_ require a Mapbox Access Token or an on-premise Mapbox installation. - A Mapbox service style URL, which requires a Mapbox Access Token or an on-premise Mapbox installation. - A Mapbox Style object as defined at https://docs.mapbox.com/mapbox-gl-js/style-spec/ From 5e8bfee643cdc14c19203d143af361c4ba2ba34e Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Thu, 14 Dec 2023 15:21:54 -0500 Subject: [PATCH 05/18] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a72da2be471..ef17bac91d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - browser-tools: circleci/browser-tools@1.4.5 + browser-tools: circleci/browser-tools@1.4.6 commands: test_core: From 8cdc5ab3aad49d9199d4ba05c0136ead138e5325 Mon Sep 17 00:00:00 2001 From: Rob L Date: Wed, 27 Dec 2023 14:31:20 -0500 Subject: [PATCH 06/18] adding a jinja2 example to the interactive HTML export Jinja2 is a standard, safe, and powerful way to insert content into HTML in Python. I add an example to the documentation --- doc/python/interactive-html-export.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/python/interactive-html-export.md b/doc/python/interactive-html-export.md index bd7284beb02..f1df1f7413d 100644 --- a/doc/python/interactive-html-export.md +++ b/doc/python/interactive-html-export.md @@ -55,6 +55,29 @@ fig.write_html("path/to/file.html") By default, the resulting HTML file is a fully self-contained HTML file which can be uploaded to a web server or shared via email or other file-sharing mechanisms. The downside to this approach is that the file is very large (5Mb+) because it contains an inlined copy of the Plotly.js library required to make the figure interactive. This can be controlled via the `include_plotlyjs` argument (see below). +### Inserting Plotly Output into HTML using a Jinja2 Template + +You can insert Plotly output and text related to your data into HTML templates using Jinja2. First create an HTML template file containing a variable like `{{ fig }}`. Then use the following Python to replace `{{ fig }}` in the template with HTML that will display the Plotly figure "fig": + +``` +import plotly.express as px +from jinja2 import Template + +data_canada = px.data.gapminder().query("country == 'Canada'") +fig = px.bar(data_canada, x='year', y='pop') + +output_html_path=r"/path/to/output.html" +input_template_path = r"/path/to/template.html" + +plotly_jinja_data = {"fig":fig.to_html(full_html=False)} +#consider also defining the include_plotlyjs parameter to point to an external Plotly.js as described above + +with open(output_html_path, "w", encoding="utf-8") as output_file: + with open(input_template_path) as template_file: + j2_template = Template(template_file.read()) + output_file.write(j2_template.render(plotly_jinja_data)) +``` + ### HTML export in Dash From 4d8baf4b929eb726b0328d278f5b4301d372bf2f Mon Sep 17 00:00:00 2001 From: Rob L Date: Sat, 6 Jan 2024 15:45:40 -0500 Subject: [PATCH 07/18] Update interactive-html-export.md based on Plotly comments --- doc/python/interactive-html-export.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/python/interactive-html-export.md b/doc/python/interactive-html-export.md index f1df1f7413d..46f60334a5a 100644 --- a/doc/python/interactive-html-export.md +++ b/doc/python/interactive-html-export.md @@ -57,7 +57,20 @@ By default, the resulting HTML file is a fully self-contained HTML file which ca ### Inserting Plotly Output into HTML using a Jinja2 Template -You can insert Plotly output and text related to your data into HTML templates using Jinja2. First create an HTML template file containing a variable like `{{ fig }}`. Then use the following Python to replace `{{ fig }}` in the template with HTML that will display the Plotly figure "fig": +You can insert Plotly output and text related to your data into HTML templates using Jinja2. Use `.to_html` to send the HTML to a Python string variable rather using write_html to send the HTML to a disk file. Use the `full_html=False` option to output just the code necessary to add a figure to a template that will provide e.g. the `` tag rather than asking Plotly to ouput a complete webpage. First create an HTML template file containing a Jinja `{{ variable }}`. In this example, we customize the HTML in the template file by replacing the Jinja variable `{{ fig }}` with our graphic `fig`. + +``` + + + +

Here's a Plotly graph!

+{{ fig }} +

And here's some text after the graph.

+ + +``` + +Then use the following Python to replace `{{ fig }}` in the template with HTML that will display the Plotly figure "fig": ``` import plotly.express as px From bb55df092dd43330c031c43257b17859c5588563 Mon Sep 17 00:00:00 2001 From: Rob L Date: Mon, 8 Jan 2024 12:08:45 -0500 Subject: [PATCH 08/18] Update doc/python/interactive-html-export.md Co-authored-by: Liam Connors --- doc/python/interactive-html-export.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/interactive-html-export.md b/doc/python/interactive-html-export.md index 46f60334a5a..683537c4720 100644 --- a/doc/python/interactive-html-export.md +++ b/doc/python/interactive-html-export.md @@ -57,7 +57,7 @@ By default, the resulting HTML file is a fully self-contained HTML file which ca ### Inserting Plotly Output into HTML using a Jinja2 Template -You can insert Plotly output and text related to your data into HTML templates using Jinja2. Use `.to_html` to send the HTML to a Python string variable rather using write_html to send the HTML to a disk file. Use the `full_html=False` option to output just the code necessary to add a figure to a template that will provide e.g. the `` tag rather than asking Plotly to ouput a complete webpage. First create an HTML template file containing a Jinja `{{ variable }}`. In this example, we customize the HTML in the template file by replacing the Jinja variable `{{ fig }}` with our graphic `fig`. +You can insert Plotly output and text related to your data into HTML templates using Jinja2. Use `.to_html` to send the HTML to a Python string variable rather than using `write_html` to send the HTML to a disk file. Use the `full_html=False` option to output just the code necessary to add a figure to a template. We don't want to output a full HTML page, as the template will define the rest of the page's structure — for example, the page's `HTML` and `BODY` tags. First create an HTML template file containing a Jinja `{{ variable }}`. In this example, we customize the HTML in the template file by replacing the Jinja variable `{{ fig }}` with our graphic `fig`. ``` From 30d0deb197ce1511cf0fd42a6118bddcc55d4593 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 9 Jan 2024 13:34:53 -0500 Subject: [PATCH 09/18] Update interactive-html-export.md --- doc/python/interactive-html-export.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/python/interactive-html-export.md b/doc/python/interactive-html-export.md index 683537c4720..843ab897767 100644 --- a/doc/python/interactive-html-export.md +++ b/doc/python/interactive-html-export.md @@ -6,9 +6,9 @@ jupyter: extension: .md format_name: markdown format_version: '1.3' - jupytext_version: 1.14.1 + jupytext_version: 1.14.6 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.8.8 + version: 3.10.11 plotly: description: Plotly allows you to save interactive HTML versions of your figures to your local disk. @@ -51,6 +51,7 @@ fig.write_html("path/to/file.html") ``` + ### Controlling the size of the HTML file By default, the resulting HTML file is a fully self-contained HTML file which can be uploaded to a web server or shared via email or other file-sharing mechanisms. The downside to this approach is that the file is very large (5Mb+) because it contains an inlined copy of the Plotly.js library required to make the figure interactive. This can be controlled via the `include_plotlyjs` argument (see below). @@ -72,7 +73,7 @@ You can insert Plotly output and text related to your data into HTML templates u Then use the following Python to replace `{{ fig }}` in the template with HTML that will display the Plotly figure "fig": -``` +```python import plotly.express as px from jinja2 import Template @@ -90,7 +91,7 @@ with open(output_html_path, "w", encoding="utf-8") as output_file: j2_template = Template(template_file.read()) output_file.write(j2_template.render(plotly_jinja_data)) ``` - + ### HTML export in Dash From 7a909cabf88c62f66eb8df5663d6e260fa6d07ef Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 9 Jan 2024 13:58:21 -0500 Subject: [PATCH 10/18] Update interactive-html-export.md --- doc/python/interactive-html-export.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/python/interactive-html-export.md b/doc/python/interactive-html-export.md index 843ab897767..a6b1ecfcadb 100644 --- a/doc/python/interactive-html-export.md +++ b/doc/python/interactive-html-export.md @@ -51,7 +51,6 @@ fig.write_html("path/to/file.html") ``` - ### Controlling the size of the HTML file By default, the resulting HTML file is a fully self-contained HTML file which can be uploaded to a web server or shared via email or other file-sharing mechanisms. The downside to this approach is that the file is very large (5Mb+) because it contains an inlined copy of the Plotly.js library required to make the figure interactive. This can be controlled via the `include_plotlyjs` argument (see below). @@ -61,16 +60,18 @@ By default, the resulting HTML file is a fully self-contained HTML file which ca You can insert Plotly output and text related to your data into HTML templates using Jinja2. Use `.to_html` to send the HTML to a Python string variable rather than using `write_html` to send the HTML to a disk file. Use the `full_html=False` option to output just the code necessary to add a figure to a template. We don't want to output a full HTML page, as the template will define the rest of the page's structure — for example, the page's `HTML` and `BODY` tags. First create an HTML template file containing a Jinja `{{ variable }}`. In this example, we customize the HTML in the template file by replacing the Jinja variable `{{ fig }}` with our graphic `fig`. ``` - - - -

Here's a Plotly graph!

+<!DOCTYPE html> +<html> +<body> +<h1>Here's a Plotly graph!</h1> {{ fig }} -

And here's some text after the graph.

- - +<p>And here's some text after the graph.</p> +</body> +</html> ``` + + Then use the following Python to replace `{{ fig }}` in the template with HTML that will display the Plotly figure "fig": ```python From cf7c5a856b2c005f0aa51b3d8ea84081102c7e48 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 9 Jan 2024 14:18:26 -0500 Subject: [PATCH 11/18] Update interactive-html-export.md --- doc/python/interactive-html-export.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/python/interactive-html-export.md b/doc/python/interactive-html-export.md index a6b1ecfcadb..013c87c286b 100644 --- a/doc/python/interactive-html-export.md +++ b/doc/python/interactive-html-export.md @@ -57,7 +57,9 @@ By default, the resulting HTML file is a fully self-contained HTML file which ca ### Inserting Plotly Output into HTML using a Jinja2 Template -You can insert Plotly output and text related to your data into HTML templates using Jinja2. Use `.to_html` to send the HTML to a Python string variable rather than using `write_html` to send the HTML to a disk file. Use the `full_html=False` option to output just the code necessary to add a figure to a template. We don't want to output a full HTML page, as the template will define the rest of the page's structure — for example, the page's `HTML` and `BODY` tags. First create an HTML template file containing a Jinja `{{ variable }}`. In this example, we customize the HTML in the template file by replacing the Jinja variable `{{ fig }}` with our graphic `fig`. +You can insert Plotly output and text related to your data into HTML templates using Jinja2. Use `.to_html` to send the HTML to a Python string variable rather than using `write_html` to send the HTML to a disk file. Use the `full_html=False` option to output just the code necessary to add a figure to a template. We don't want to output a full HTML page, as the template will define the rest of the page's structure — for example, the page's `HTML` and `BODY` tags. First create an HTML template file containing a Jinja `{{ variable }}`. In this example, we customize the HTML in the template file by replacing the Jinja variable `{{ fig }}` with our graphic `fig`. + + ``` <!DOCTYPE html> @@ -70,7 +72,6 @@ You can insert Plotly output and text related to your data into HTML templates u </html> ``` - Then use the following Python to replace `{{ fig }}` in the template with HTML that will display the Plotly figure "fig": From 5014eaecbbc9858d3fba35b6524d1be52f8cc2a6 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Fri, 19 Jan 2024 15:58:21 -0500 Subject: [PATCH 12/18] Update marker-style.md --- doc/python/marker-style.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/python/marker-style.md b/doc/python/marker-style.md index 21b0a2ac052..91d136bcc58 100644 --- a/doc/python/marker-style.md +++ b/doc/python/marker-style.md @@ -6,7 +6,7 @@ jupyter: extension: .md format_name: markdown format_version: '1.3' - jupytext_version: 1.14.1 + jupytext_version: 1.14.6 kernelspec: display_name: Python 3 (ipykernel) language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.8.0 + version: 3.10.11 plotly: description: How to style markers in Python with Plotly. display_as: file_settings @@ -361,7 +361,7 @@ fig.show() ### Using a Custom Marker -To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`. +To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`. ```python @@ -378,6 +378,31 @@ fig.show() ``` +#### Open Marker Colors + +In the previous example, each marker has two colors, a marker color (set in Plotly Express with `color="species"`) and a line color (set on the line with `color="DarkSlateGrey"`. When using open markers, like `"diamond-open"` in the following example, the marker always uses only the marker color. Adding a line color won't update the marker. + +```python +import plotly.express as px + +df = px.data.iris() +fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") + +fig.update_traces( + marker=dict( + size=8, + symbol="diamond-open", + line=dict( + width=2, +# color="DarkSlateGrey" Line colors don't apply to open markers + ) + ), + selector=dict(mode="markers"), +) + +fig.show() +``` + ### Setting Marker Angles From c5cff44da4d5c6193f92e5d18c5c83aa01601f09 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Fri, 2 Feb 2024 15:45:07 -0500 Subject: [PATCH 13/18] Update text-and-annotations.md --- doc/python/text-and-annotations.md | 45 ++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/doc/python/text-and-annotations.md b/doc/python/text-and-annotations.md index d75751d1a50..b1107798859 100644 --- a/doc/python/text-and-annotations.md +++ b/doc/python/text-and-annotations.md @@ -6,9 +6,9 @@ jupyter: extension: .md format_name: markdown format_version: '1.3' - jupytext_version: 1.14.1 + jupytext_version: 1.16.1 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.8.8 + version: 3.10.11 plotly: description: How to add text labels and annotations to plots in python. display_as: file_settings @@ -207,6 +207,45 @@ fig.update_layout(showlegend=False) fig.show() ``` +#### Text Annotations with Log Axis Type + +If the `x` or `y` positions of an annotation reference a log axis, you need to provide that position as a `log10` value when adding the annotation. In this example, the yaxis is a log axis so we pass the `log10` value of `1000` to the annotation's `y` position. + +```python +import plotly.graph_objects as go +import math + +dates = [ + "2024-01-01", + "2024-01-02", + "2024-01-03", + "2024-01-04", + "2024-01-05", + "2024-01-06", +] +y_values = [1, 30, 70, 100, 1000, 10000000] + +fig = go.Figure( + data=[go.Scatter(x=dates, y=y_values, mode="lines+markers")], + layout=go.Layout( + yaxis=dict( + type="log", + ) + ), +) + +fig.add_annotation( + x="2024-01-05", + y=math.log10(1000), + text="Log axis annotation", + showarrow=True, + xanchor="right", +) + +fig.show() + +``` + ### 3D Annotations ```python From 6f2db21b980965afd317e252b306eb17adf04d35 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Fri, 2 Feb 2024 16:04:22 -0500 Subject: [PATCH 14/18] Update text-and-annotations.md --- doc/python/text-and-annotations.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/python/text-and-annotations.md b/doc/python/text-and-annotations.md index b1107798859..30631efd7cc 100644 --- a/doc/python/text-and-annotations.md +++ b/doc/python/text-and-annotations.md @@ -207,9 +207,9 @@ fig.update_layout(showlegend=False) fig.show() ``` -#### Text Annotations with Log Axis Type +#### Text Annotations with Log Axes -If the `x` or `y` positions of an annotation reference a log axis, you need to provide that position as a `log10` value when adding the annotation. In this example, the yaxis is a log axis so we pass the `log10` value of `1000` to the annotation's `y` position. +If the `x` or `y` positions of an annotation reference a log axis, you need to provide that position as a `log10` value when adding the annotation. In this example, the `yaxis` is a log axis so we pass the `log10` value of `1000` to the annotation's `y` position. ```python import plotly.graph_objects as go @@ -243,7 +243,6 @@ fig.add_annotation( ) fig.show() - ``` ### 3D Annotations From d42b6b3ffb936530d45804aa60ee458e14e40ed3 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 5 Feb 2024 08:59:38 -0500 Subject: [PATCH 15/18] Update doc/python/marker-style.md --- doc/python/marker-style.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/marker-style.md b/doc/python/marker-style.md index 91d136bcc58..f68030e096e 100644 --- a/doc/python/marker-style.md +++ b/doc/python/marker-style.md @@ -380,7 +380,7 @@ fig.show() #### Open Marker Colors -In the previous example, each marker has two colors, a marker color (set in Plotly Express with `color="species"`) and a line color (set on the line with `color="DarkSlateGrey"`. When using open markers, like `"diamond-open"` in the following example, the marker always uses only the marker color. Adding a line color won't update the marker. +In the previous example, each marker has two colors, a marker color (set in Plotly Express with `color="species"`) and a line color (set on the line with `color="DarkSlateGrey"`. All open markers, like "diamond-open" in the following example, have a transparent fill, which means you can specify only one color. Specify this color using the marker color parameter. This controls the outline color and any dot or cross. For open markers, the line color does nothing. ```python import plotly.express as px From ef247e786d7f03abc425b739e63d5d0554a1d275 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 6 Feb 2024 16:38:00 -0500 Subject: [PATCH 16/18] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef17bac91d7..3afbedd8dc4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -370,7 +370,7 @@ jobs: - run: name: Create conda environment command: | - conda create -n env --yes python=3.9 conda-build conda-verify + conda create -n env --yes python=3.9 conda-build=3.28.4 conda-verify conda install -n env -c conda-forge jupyterlab=3 nodejs=16 conda init bash mkdir output From 0b80f5ce3b7a6557a9a83a81ed394fb5e0348afb Mon Sep 17 00:00:00 2001 From: mikekinde <144503748+mikekinde@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:58:48 -0600 Subject: [PATCH 17/18] Update bubble-maps.md In the python code that sets the variable "limits", the range numbers are resulting in missed values. This is because the first number in the list pair is inclusive while the second number is exclusive. For example, the limit pair of (0,2) only iterates through two loops (0 & 1) instead of three. The net result is that the map doesn't include the "2" city (Chicago). --- doc/python/bubble-maps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/bubble-maps.md b/doc/python/bubble-maps.md index ccd78306bc2..23e1d543824 100644 --- a/doc/python/bubble-maps.md +++ b/doc/python/bubble-maps.md @@ -85,7 +85,7 @@ df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_ df.head() df['text'] = df['name'] + '
Population ' + (df['pop']/1e6).astype(str)+' million' -limits = [(0,2),(3,10),(11,20),(21,50),(50,3000)] +limits = [(0,3),(3,11),(11,21),(21,50),(50,3000)] colors = ["royalblue","crimson","lightseagreen","orange","lightgrey"] cities = [] scale = 5000 From 5496d361e027a53a1fca32cb2746468e4c04f9ac Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Thu, 15 Feb 2024 10:59:18 -0500 Subject: [PATCH 18/18] remove limitation --- doc/python/mapbox-layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/mapbox-layers.md b/doc/python/mapbox-layers.md index 993e4d0bca9..ac651d3ac02 100644 --- a/doc/python/mapbox-layers.md +++ b/doc/python/mapbox-layers.md @@ -64,7 +64,7 @@ The word "mapbox" in the trace names and `layout.mapbox` refers to the Mapbox GL The accepted values for `layout.mapbox.style` are one of: - `"white-bg"` yields an empty white canvas which results in no external HTTP requests -- `"open-street-map"`, `"carto-positron"`, and `"carto-darkmatter"` yield maps composed of _raster_ tiles from various public tile servers which do not require signups or access tokens. There is currently a known issue with `"stamen-terrain"`, `"stamen-toner"` and `"stamen-watercolor"` tiles, which will be fixed in a future Plotly.py release. +- `"open-street-map"`, `"carto-positron"`, and `"carto-darkmatter"` yield maps composed of _raster_ tiles from various public tile servers which do not require signups or access tokens. - `"basic"`, `"streets"`, `"outdoors"`, `"light"`, `"dark"`, `"satellite"`, or `"satellite-streets"` yield maps composed of _vector_ tiles from the Mapbox service, and _do_ require a Mapbox Access Token or an on-premise Mapbox installation. - A Mapbox service style URL, which requires a Mapbox Access Token or an on-premise Mapbox installation. - A Mapbox Style object as defined at https://docs.mapbox.com/mapbox-gl-js/style-spec/