Skip to content

Commit e4ce905

Browse files
Update css for docs and increment version...
1 parent 047355f commit e4ce905

25 files changed

+499
-272
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ result_images
66
dist
77
*.egg-info
88
docs/_build/
9-
docs/api/generated
9+
docs/api/generated
10+
docs/examples/

Diff for: README.md

+2-109
Original file line numberDiff line numberDiff line change
@@ -12,118 +12,11 @@ You can install matplotview using pip:
1212
pip install matplotview
1313
```
1414

15-
## Usage
16-
17-
matplotview provides two methods, `view`, and `inset_zoom_axes`. The `view`
18-
method accepts two `Axes`, and makes the first axes a view of the second. The
19-
`inset_zoom_axes` method provides the same functionality as `Axes.inset_axes`,
20-
but the returned inset axes is configured to be a view of the parent axes.
21-
2215
## Examples
2316

24-
An example of two axes showing the same plot.
25-
```python
26-
from matplotview import view
27-
import matplotlib.pyplot as plt
28-
import numpy as np
29-
30-
fig, (ax1, ax2) = plt.subplots(1, 2)
31-
32-
# Plot a line, circle patch, some text, and an image...
33-
ax1.plot([i for i in range(10)], "r")
34-
ax1.add_patch(plt.Circle((3, 3), 1, ec="black", fc="blue"))
35-
ax1.text(10, 10, "Hello World!", size=20)
36-
ax1.imshow(np.random.rand(30, 30), origin="lower", cmap="Blues", alpha=0.5,
37-
interpolation="nearest")
38-
39-
# Turn axes 2 into a view of axes 1.
40-
view(ax2, ax1)
41-
# Modify the second axes data limits to match the first axes...
42-
ax2.set_aspect(ax1.get_aspect())
43-
ax2.set_xlim(ax1.get_xlim())
44-
ax2.set_ylim(ax1.get_ylim())
45-
46-
fig.tight_layout()
47-
fig.show()
48-
```
49-
![First example plot results, two views of the same plot.](https://user-images.githubusercontent.com/47544550/149814592-dd815f95-c3ef-406d-bd7e-504859c836bf.png)
50-
51-
An inset axes example.
52-
```python
53-
from matplotlib import cbook
54-
import matplotlib.pyplot as plt
55-
import numpy as np
56-
from matplotview import inset_zoom_axes
57-
58-
def get_demo_image():
59-
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
60-
# z is a numpy array of 15x15
61-
return z, (-3, 4, -4, 3)
62-
63-
fig, ax = plt.subplots(figsize=[5, 4])
64-
65-
# Make the data...
66-
Z, extent = get_demo_image()
67-
Z2 = np.zeros((150, 150))
68-
ny, nx = Z.shape
69-
Z2[30:30+ny, 30:30+nx] = Z
17+
See the documentation
7018

71-
ax.imshow(Z2, extent=extent, interpolation='nearest', origin="lower")
19+
## Documentation and Usage
7220

73-
# Creates an inset axes with automatic view of the parent axes...
74-
axins = inset_zoom_axes(ax, [0.5, 0.5, 0.47, 0.47])
75-
# Set limits to sub region of the original image
76-
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
77-
axins.set_xlim(x1, x2)
78-
axins.set_ylim(y1, y2)
79-
axins.set_xticklabels([])
80-
axins.set_yticklabels([])
8121

82-
ax.indicate_inset_zoom(axins, edgecolor="black")
8322

84-
fig.show()
85-
```
86-
![Second example plot results, an inset axes showing a zoom view of an image.](https://user-images.githubusercontent.com/47544550/149814558-c2b1228d-2e5d-41be-86c0-f5dd01d42884.png)
87-
88-
Because views support recursive drawing, they can be used to create
89-
fractals also.
90-
```python
91-
import matplotlib.pyplot as plt
92-
import matplotview as mpv
93-
from matplotlib.patches import PathPatch
94-
from matplotlib.path import Path
95-
from matplotlib.transforms import Affine2D
96-
97-
outside_color = "black"
98-
inner_color = "white"
99-
100-
t = Affine2D().scale(-0.5)
101-
102-
outer_triangle = Path.unit_regular_polygon(3)
103-
inner_triangle = t.transform_path(outer_triangle)
104-
b = outer_triangle.get_extents()
105-
106-
fig, ax = plt.subplots(1)
107-
ax.set_aspect(1)
108-
109-
ax.add_patch(PathPatch(outer_triangle, fc=outside_color, ec=[0] * 4))
110-
ax.add_patch(PathPatch(inner_triangle, fc=inner_color, ec=[0] * 4))
111-
ax.set_xlim(b.x0, b.x1)
112-
ax.set_ylim(b.y0, b.y1)
113-
114-
ax_locs = [
115-
[0, 0, 0.5, 0.5],
116-
[0.5, 0, 0.5, 0.5],
117-
[0.25, 0.5, 0.5, 0.5]
118-
]
119-
120-
for loc in ax_locs:
121-
inax = mpv.inset_zoom_axes(ax, loc, render_depth=6)
122-
inax.set_xlim(b.x0, b.x1)
123-
inax.set_ylim(b.y0, b.y1)
124-
inax.axis("off")
125-
inax.patch.set_visible(False)
126-
127-
fig.show()
128-
```
129-
![Third example plot results, a Sierpiński triangle](https://user-images.githubusercontent.com/47544550/150047401-e9364f0f-becd-45c5-a6f4-062118ce713f.png)

Diff for: docs/_static/gallery_mods.css

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
.sphx-glr-thumbcontainer[tooltip]:hover:after {
3+
background: var(--sg-tooltip-background);
4+
-webkit-border-radius: 4px;
5+
-moz-border-radius: 4px;
6+
border-radius: 4px;
7+
color: var(--sg-tooltip-foreground);
8+
content: "";
9+
opacity: 0.35;
10+
padding: 10px;
11+
z-index: 98;
12+
width: 100%;
13+
height: 100%;
14+
position: absolute;
15+
pointer-events: none;
16+
top: 0;
17+
box-sizing: border-box;
18+
overflow: hidden;
19+
backdrop-filter: blur(3px);
20+
}

Diff for: docs/conf.py

+11
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@
2222
'numpydoc',
2323
'matplotlib.sphinxext.mathmpl',
2424
'matplotlib.sphinxext.plot_directive',
25+
'sphinx_gallery.gen_gallery'
2526
]
2627

2728
templates_path = ['_templates']
2829
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
2930

31+
from sphinx_gallery.sorting import FileNameSortKey
32+
33+
sphinx_gallery_conf = {
34+
"examples_dirs": "../examples",
35+
"gallery_dirs": "examples",
36+
"line_numbers": True,
37+
"within_subsection_order": FileNameSortKey
38+
}
3039

3140
# -- Options for HTML output -------------------------------------------------
3241
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3342

3443
html_theme = 'alabaster'
3544
html_static_path = ['_static']
45+
html_css_files = ['gallery_mods.css']
46+
3647
plot_include_source = True

Diff for: docs/examples/plots/multiple_artist_view.rst

-30
This file was deleted.

Diff for: docs/examples/plots/sierpinski_triangle.rst

-48
This file was deleted.

Diff for: docs/examples/plots/simple_inset_view.rst

-45
This file was deleted.

Diff for: docs/examples/plots/simplest_example.rst

-25
This file was deleted.

Diff for: docs/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ Additional Links
1919
================
2020

2121
* :ref:`genindex`
22-
* :ref:`modindex`
2322
* :ref:`search`

Diff for: docs/examples/index.rst renamed to examples/README.rst

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,4 @@ Examples
44
Because of the way matplotview is designed, it can work with any Axes and projection
55
types, and works with all the default projection modes included in matplotlib.
66
The following examples showcase using matplotview in several different scenarios and
7-
with different projections.
8-
9-
.. toctree::
10-
:maxdepth: 2
11-
:caption: Examples:
12-
13-
plots/simplest_example
14-
plots/multiple_artist_view
15-
plots/simple_inset_view
16-
plots/sierpinski_triangle
7+
with different projections.

Diff for: examples/plot_00_simplest_example.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
The Simplest View
3+
=================
4+
5+
The simplest example: We make a view of a line! Views can be created quickly
6+
using :meth:`matplotview.view` .
7+
"""
8+
9+
from matplotview import view
10+
import matplotlib.pyplot as plt
11+
12+
fig, (ax1, ax2) = plt.subplots(1, 2)
13+
14+
# Plot a line in the first axes.
15+
ax1.plot([i for i in range(10)], "-o")
16+
17+
# Create a view! Turn axes 2 into a view of axes 1.
18+
view(ax2, ax1)
19+
# Modify the second axes data limits so we get a slightly zoomed out view
20+
ax2.set_xlim(-5, 15)
21+
ax2.set_ylim(-5, 15)
22+
23+
fig.show()

0 commit comments

Comments
 (0)