Skip to content

Commit 0355c3a

Browse files
authored
Split pages (#20)
1 parent ec8706e commit 0355c3a

File tree

10 files changed

+108
-97
lines changed

10 files changed

+108
-97
lines changed

docs/source/examples.rst

Lines changed: 0 additions & 96 deletions
This file was deleted.

docs/source/examples/basic.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
basic
2+
=====
3+
4+
.. plotly::
5+
6+
import plotly.express as px
7+
8+
px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])

docs/source/examples/doctest.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
doctest
3+
=======
4+
5+
.. plotly::
6+
7+
>>> import plotly.express as px
8+
>>> px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])

docs/source/examples/fig-vars.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fig-vars
2+
========
3+
4+
Single
5+
~~~~~~
6+
7+
.. plotly::
8+
:fig-vars: fig1
9+
10+
import plotly.express as px
11+
12+
fig1 = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
13+
14+
15+
Multiple
16+
~~~~~~~~
17+
18+
.. plotly::
19+
:fig-vars: fig1, fig2
20+
21+
import plotly.express as px
22+
23+
fig1 = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
24+
fig2 = px.scatter(x=[4, 3, 2, 1, 0], y=[0, 1, 4, 9, 16])

docs/source/examples/function.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function
2+
========
3+
4+
test_func.py
5+
6+
.. literalinclude:: test_func.py
7+
:language: python
8+
9+
.. plotly:: examples/test_func.py func
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
iframe-size
2+
===========
3+
4+
.. plotly::
5+
:iframe-width: 500px
6+
:iframe-height: 300px
7+
8+
import plotly.express as px
9+
10+
px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
11+
12+
13+
You can set the default ``iframe-width`` and ``iframe-height`` by specifying ``plotly_iframe_width`` (default: ``"100%"``) and ``plotly_iframe_height`` (default: ``"500px"``) in ``conf.py``.
14+
15+
.. code-block:: python
16+
17+
# conf.py
18+
19+
plotly_iframe_width = "500px"
20+
plotly_iframe_height = "300px"

docs/source/examples/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. _examples:
2+
3+
Examples
4+
========
5+
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
10+
basic
11+
doctest
12+
function
13+
fig-vars
14+
precode
15+
iframe-size

docs/source/examples/precode.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
precode
3+
=======
4+
5+
By default, the following code will be executed before running each code block. This allows to use
6+
``np``, ``plotly``, ``go``, and ``px`` without importing them.
7+
8+
.. code-block:: python
9+
10+
import numpy as np
11+
import plotly
12+
import plotly.graph_objects as go
13+
import plotly.express as px
14+
15+
.. plotly::
16+
:fig-vars: fig1, fig2
17+
18+
x = np.arange(5)
19+
y = x ** 2
20+
21+
title = "plotly version: {}".format(plotly.__version__)
22+
fig1 = go.Figure(go.Scatter(x=x, y=y), layout=dict(title=title))
23+
fig2 = px.scatter(x=x, y=y, title=title)
File renamed without changes.

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Welcome to sphinx-plotly-directive's documentation!
1010
:maxdepth: 2
1111
:caption: Contents:
1212

13-
examples
13+
examples/index
1414

1515
Indices and tables
1616
==================

0 commit comments

Comments
 (0)