Skip to content

Fill out example descriptions, including crossreferences #23

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

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ Wrappers

.. automodule:: data_prototype.wrappers
:members:
:undoc-members:

.. automodule:: data_prototype.patches
:members:
:undoc-members:
3 changes: 2 additions & 1 deletion examples/2Dfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
A functional 2D image
=====================


A 2D image generated using :class:`.containers.FuncContainer` and
:class:`wrappers.ImageWrapper`.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 2 additions & 0 deletions examples/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
An animated line
================

An animated line using a custom container class,
:class:`.wrappers.LineWrapper`, and :class:`.wrappers.FormatedText`.

"""
import time
Expand Down
7 changes: 4 additions & 3 deletions examples/data_frame.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
=================
===============
Show data frame
=================
===============

The hello-world
Wrapping a :class:`pandas.DataFrame` using :class:`.containers.DataFrameContainer`
and :class:`.wrappers.LineWrapper`.
"""

import matplotlib.pyplot as plt
Expand Down
9 changes: 5 additions & 4 deletions examples/errorbar.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
=================
Show data frame
=================
==============
Errorbar graph
==============

The hello-world
Using :class:`.containers.ArrayContainer` and :class:`.wrappers.ErrorbarWrapper`
to plot a graph with error bars.
"""

import matplotlib.pyplot as plt
Expand Down
3 changes: 2 additions & 1 deletion examples/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
A functional line
=================

The hello-world
Demonstrating the differences between :class:`.containers.FuncContainer` and
:class:`.containers.SeriesContainer` using :class:`.wrappers.LineWrapper`.
"""

import matplotlib.pyplot as plt
Expand Down
3 changes: 2 additions & 1 deletion examples/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
A re-binning histogram
======================


A :class:`.containers.HistContainer` which is used with :class:`.wrappers.StepWrapper`
to provide a histogram which recomputes the bins based on a range selected.
"""

import matplotlib.pyplot as plt
Expand Down
19 changes: 5 additions & 14 deletions examples/lissajous.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Inspired by https://twitter.com/_brohrer_/status/1584681864648065027

An animated scatter plot using a custom container and :class:`.wrappers.PathCollectionWrapper`

"""
import time
Expand All @@ -19,7 +20,7 @@

from data_prototype.containers import _MatplotlibTransform, Desc

from data_prototype.wrappers import PathCollectionWrapper, FormatedText
from data_prototype.wrappers import PathCollectionWrapper


class Lissajous:
Expand All @@ -31,7 +32,6 @@ def describe(self):
return {
"x": Desc([self.N], float),
"y": Desc([self.N], float),
"phase": Desc([], float),
"time": Desc([], float),
"sizes": Desc([], float),
"paths": Desc([], float),
Expand All @@ -53,7 +53,6 @@ def next_time():
return {
"x": np.cos(5 * phase),
"y": np.sin(3 * phase),
"phase": phase[0],
"sizes": np.array([256]),
"paths": [marker_obj.get_path().transformed(marker_obj.get_transform())],
"edgecolors": "k",
Expand All @@ -70,27 +69,19 @@ def update(frame, art):

sot_c = Lissajous()

fc = FormatedText(
sot_c,
{"text": lambda phase: f"ϕ={phase:.2f} "},
x=1,
y=1,
ha="right",
)
fig, ax = plt.subplots()
ax.set_xlim(-1.1, 1.1)
ax.set_ylim(-1.1, 1.1)
lw = PathCollectionWrapper(sot_c, offset_transform=ax.transData)
ax.add_artist(lw)
ax.add_artist(fc)
# ax.set_xticks([])
# ax.set_yticks([])
ax.set_aspect(1)
ani = FuncAnimation(
fig,
partial(update, art=(lw, fc)),
frames=60 * 15,
interval=1000 / 100,
partial(update, art=(lw,)),
frames=60,
interval=1000 / 100 * 15,
# TODO: blitting does not work because wrappers do not inherent from Artist
# blit=True,
)
Expand Down
4 changes: 4 additions & 0 deletions examples/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
(Infinitly) Zoomable Mandelbrot Set
===================================

A mandelbrot set which is computed using a :class:`.containers.FuncContainer`
and represented using a :class:`wrappers.ImageWrapper`.

The mandelbrot recomputes as it is zoomed in and/or panned.

"""

Expand Down
8 changes: 5 additions & 3 deletions examples/mulivariate_cmap.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""
=====================
A functional 2D image
=====================
=========================
Custom bivariate colormap
=========================


Using ``nu`` functions to account for two values when computing the color
of each pixel.
"""

import matplotlib.pyplot as plt
Expand Down
4 changes: 4 additions & 0 deletions examples/simple_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Simple patch artists
====================

Draw two fully specified rectangle patches.
Demonstrates :class:`.patches.RectangleWrapper` using
:class:`.containers.ArrayContainer`.

"""
import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion examples/simple_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
An simple scatter plot using PathCollectionWrapper
==================================================

A quick example using ``containers.ArrayContainer`` and ``wrappers.PathCollectionWrapper``.
A quick scatter plot using :class:`.containers.ArrayContainer` and
:class:`.wrappers.PathCollectionWrapper`.
"""
import numpy as np

Expand Down