Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update master with recent doc prod updates #4515

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5985930
Update dendrogram.md
MartinoMensio Sep 18, 2023
7b602dc
Merge pull request #4399 from plotly/master
archmoj Oct 25, 2023
e1e2eed
Fix broken markdown link in figure-labels.md
mahotd Oct 27, 2023
dbaf309
Merge pull request #4403 from mahotd/fix-markdown-link
LiamConnors Oct 27, 2023
97a2950
Merge branch 'doc-prod' into patch-1
LiamConnors Nov 6, 2023
f36ef1f
Merge pull request #4364 from MartinoMensio/patch-1
LiamConnors Nov 6, 2023
90b29f6
Fix `suplot` typo in doc
mahotd Nov 30, 2023
c2c9b4b
Merge pull request #4447 from mahotd/fix-suplot-typo-in-doc
LiamConnors Dec 1, 2023
054938b
remove stamen
LiamConnors Dec 14, 2023
5e8bfee
Update config.yml
LiamConnors Dec 14, 2023
1e551da
Merge pull request #4457 from plotly/update-docs
LiamConnors Dec 15, 2023
8cdc5ab
adding a jinja2 example to the interactive HTML export
rl-utility-man Dec 27, 2023
4d8baf4
Update interactive-html-export.md based on Plotly comments
rl-utility-man Jan 6, 2024
bb55df0
Update doc/python/interactive-html-export.md
rl-utility-man Jan 8, 2024
e285e63
Merge pull request #4472 from rl-utility-man/patch-2
alexcjohnson Jan 9, 2024
30d0deb
Update interactive-html-export.md
LiamConnors Jan 9, 2024
7a909ca
Update interactive-html-export.md
LiamConnors Jan 9, 2024
cf7c5a8
Update interactive-html-export.md
LiamConnors Jan 9, 2024
4001477
Merge pull request #4479 from plotly/fix-page
LiamConnors Jan 9, 2024
5014eae
Update marker-style.md
LiamConnors Jan 19, 2024
c5cff44
Update text-and-annotations.md
LiamConnors Feb 2, 2024
6f2db21
Update text-and-annotations.md
LiamConnors Feb 2, 2024
d42b6b3
Update doc/python/marker-style.md
LiamConnors Feb 5, 2024
ef247e7
Update config.yml
LiamConnors Feb 6, 2024
0ac909c
Merge pull request #4509 from plotly/update-build
LiamConnors Feb 7, 2024
6e64760
Merge branch 'doc-prod' into annotations-example
LiamConnors Feb 7, 2024
f6365c4
Merge pull request #4504 from plotly/annotations-example
LiamConnors Feb 7, 2024
5432c58
Merge branch 'doc-prod' into update-marker-docs
LiamConnors Feb 7, 2024
f5bc9b1
Merge pull request #4485 from plotly/update-marker-docs
LiamConnors Feb 7, 2024
672a0ab
Merge branch 'master' into update-master-with-doc-prod
LiamConnors Feb 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/python/dendrogram.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/python/figure-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/python/filled-area-on-mapbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})

Expand All @@ -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': {
Expand Down
2 changes: 1 addition & 1 deletion doc/python/icicle-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 42 additions & 3 deletions doc/python/interactive-html-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -55,6 +55,45 @@ 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. 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`.

<!-- #region -->

```
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
&lt;h1&gt;Here's a Plotly graph!&lt;/h1&gt;
{{ fig }}
&lt;p&gt;And here's some text after the graph.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
```


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

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))
```
<!-- #endregion -->

### HTML export in Dash

Expand Down
6 changes: 3 additions & 3 deletions doc/python/lines-on-mapbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
```

Expand Down Expand Up @@ -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})

Expand Down
1 change: 0 additions & 1 deletion doc/python/mapbox-density-heatmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jupyter:

To plot on Mapbox maps with Plotly, you may need a [Mapbox account and token](https://www.mapbox.com/studio) or a [Stadia Maps account and token](https://www.stadiamaps.com), depending on base map (`mapbox_style`) you use. On this page, we show how to use the "open-street-map" base map, which doesn't require a token, and a "stamen" base map, which requires a Stadia Maps token. See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more examples.


### 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/).
Expand Down
31 changes: 28 additions & 3 deletions doc/python/marker-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"`. 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

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


Expand Down
2 changes: 1 addition & 1 deletion doc/python/sunburst-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 41 additions & 3 deletions doc/python/text-and-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -207,6 +207,44 @@ fig.update_layout(showlegend=False)
fig.show()
```

#### 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.

```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
Expand Down