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

WIP: Added a sphinx-gallery #746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,26 @@
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'jupyter_sphinx.embed_widgets',
'sphinx_gallery.gen_gallery',
]

sphinx_gallery_conf = {
# path to your examples scripts
'examples_dirs': '../../examples',
# path where to save gallery generated examples
'gallery_dirs': 'auto_examples',
# 'image_scrapers': ('matplotlib'),#, 'ipyvolume'),
'executor': 'notebook',
# 'show_memory': True,
'nbconvert': {
'snapshot': {
'port': 10101,
'page_opener_class': 'headless'
}
}
}


autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -128,6 +146,14 @@
# a list of builtin themes.
#html_theme = 'alabaster'

html_theme = 'default'
try:
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except:
print("rtd theme not found")

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ bqplot: Plotting for Jupyter
introduction
usage
api_documentation
auto_examples/index
38 changes: 38 additions & 0 deletions examples/plot_lines_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Line chart
==========

A simple line chart
"""
import numpy as np
from bqplot import pyplot as plt

np.random.seed(0)
n = 200
x = np.linspace(0.0, 10.0, n)
y = np.cumsum(np.random.randn(n))


fig = plt.figure(title='Line Chart')
plt.plot(x, y)
plt.show()

################################################
# Using the object model
# ----------------------
# A similar result can be obtained using the object model.

import bqplot
scales = {'x': bqplot.LinearScale(), 'y': bqplot.LinearScale()}

scatter = bqplot.Lines(x=x, y=y, default_size=100, scales=scales)

axis_x = bqplot.Axis(scale=scales['x'], grid_lines='solid', label='X')
axis_y = bqplot.Axis(scale=scales['y'], orientation='vertical', tick_format='0.2f',
grid_lines='solid', label='Y')

fig = bqplot.Figure(marks=[scatter], axes=[axis_x, axis_y], title='Line Chart')
fig.interaction = bqplot.PanZoom(scales={'x': [scales['x']], 'y': [scales['y']]})
fig


36 changes: 36 additions & 0 deletions examples/plot_ohlc_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Open-high-low-close chart
=========================

A simple OHLC chart
"""
import numpy as np
from bqplot import pyplot as plt
import datetime as dt


dates = np.arange(dt.datetime(2014, 1, 2), dt.datetime(2014, 1, 30), dt.timedelta(days=1))

prices = np.array([[ 187.21 , 187.4 , 185.2 , 185.53 ],
[ 185.83 , 187.35 , 185.3 , 186.64 ],
[ 187.15 , 187.355 , 185.3 , 186. ],
[ 186.39 , 190.35 , 186.38 , 189.71 ],
[ 189.33 , 189.4175, 187.26 , 187.97 ],
[ 189.02 , 189.5 , 186.55 , 187.38 ],
[ 188.31 , 188.57 , 186.28 , 187.26 ],
[ 186.26 , 186.95 , 183.86 , 184.16 ],
[ 185.06 , 186.428 , 183.8818, 185.92 ],
[ 185.82 , 188.65 , 185.49 , 187.74 ],
[ 187.53 , 188.99 , 186.8 , 188.76 ],
[ 188.04 , 190.81 , 187.86 , 190.09 ],
[ 190.23 , 190.39 , 186.79 , 188.43 ],
[ 181.28 , 183.5 , 179.67 , 182.25 ],
[ 181.43 , 183.72 , 180.71 , 182.73 ],
[ 181.25 , 182.8141, 179.64 , 179.64 ],
[ 179.605 , 179.65 , 177.66 , 177.9 ],
[ 178.05 , 178.45 , 176.16 , 176.85 ],
[ 175.98 , 178.53 , 175.89 , 176.4 ],
[ 177.17 , 177.86 , 176.36 , 177.36 ]])
plt.figure(title='Open-high-low-close chart')
plt.ohlc(dates, prices)
plt.show()
16 changes: 16 additions & 0 deletions examples/plot_pie_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Pie chart
=========

A simple pie chart
"""
import numpy as np
from bqplot import pyplot as plt

np.random.seed(0)
n = 5
y = np.cumsum(np.random.randn(n))

fig = plt.figure(title='Pie Chart')
plt.pie(y)
plt.show()
39 changes: 39 additions & 0 deletions examples/plot_scatter_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Scatter
=======

A simple scatter plot

Using the pylab API
-------------------
"""
import bqplot.pyplot as plt
import numpy as np
# create some random data
N = 1000
x, y = np.random.normal(0, 1, (2, N))

fig = plt.figure(title='Scatter plot')
s = plt.scatter(x, y, default_size=100)
plt.show()


################################################
# Using the object model
# ----------------------
# A similar result can be obtained using the object model.


import bqplot
scales = {'x': bqplot.LinearScale(), 'y': bqplot.LinearScale()}

scatter = bqplot.Scatter(x=x, y=y, default_size=100, scales=scales)

axis_x = bqplot.Axis(scale=scales['x'], grid_lines='solid', label='X')
axis_y = bqplot.Axis(scale=scales['y'], orientation='vertical', tick_format='0.2f',
grid_lines='solid', label='Y')

fig = bqplot.Figure(marks=[scatter], axes=[axis_x, axis_y], title='Scatter plot')
fig.interaction = bqplot.PanZoom(scales={'x': [scales['x']], 'y': [scales['y']]})
fig