Skip to content

Commit 35fbf23

Browse files
Change default render depth,
add third example...
1 parent 4e1eb30 commit 35fbf23

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fig.show()
4141
```
4242
![First example plot results, two views of the same plot.](https://user-images.githubusercontent.com/47544550/149814592-dd815f95-c3ef-406d-bd7e-504859c836bf.png)
4343

44-
An inset axes example .
44+
An inset axes example.
4545
```python
4646
from matplotlib import cbook
4747
import matplotlib.pyplot as plt
@@ -76,4 +76,47 @@ ax.indicate_inset_zoom(axins, edgecolor="black")
7676

7777
fig.show()
7878
```
79-
![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)
79+
![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)
80+
81+
Because views support recursive drawing, they can be used to create
82+
fractals also.
83+
```python
84+
import matplotlib.pyplot as plt
85+
import matplotview as mpv
86+
from matplotlib.patches import PathPatch
87+
from matplotlib.path import Path
88+
from matplotlib.transforms import Affine2D
89+
90+
outside_color = "black"
91+
inner_color = "white"
92+
93+
t = Affine2D().scale(-0.5)
94+
95+
outer_triangle = Path.unit_regular_polygon(3)
96+
inner_triangle = t.transform_path(outer_triangle)
97+
b = outer_triangle.get_extents()
98+
99+
fig, ax = plt.subplots(1)
100+
ax.set_aspect(1)
101+
102+
ax.add_patch(PathPatch(outer_triangle, fc=outside_color, ec=[0] * 4))
103+
ax.add_patch(PathPatch(inner_triangle, fc=inner_color, ec=[0] * 4))
104+
ax.set_xlim(b.x0, b.x1)
105+
ax.set_ylim(b.y0, b.y1)
106+
107+
ax_locs = [
108+
[0, 0, 0.5, 0.5],
109+
[0.5, 0, 0.5, 0.5],
110+
[0.25, 0.5, 0.5, 0.5]
111+
]
112+
113+
for loc in ax_locs:
114+
inax = mpv.inset_zoom_axes(ax, loc, render_depth=6)
115+
inax.set_xlim(b.x0, b.x1)
116+
inax.set_ylim(b.y0, b.y1)
117+
inax.axis("off")
118+
inax.patch.set_visible(False)
119+
120+
fig.show()
121+
```
122+
![Third example plot results, a Sierpiński triangle](https://user-images.githubusercontent.com/47544550/150047401-e9364f0f-becd-45c5-a6f4-062118ce713f.png)

matplotview/_view_axes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
DEFAULT_RENDER_DEPTH = 5
1111

12-
1312
class BoundRendererArtist:
1413
def __init__(self, artist: Artist, renderer: RendererBase, clip_box: Bbox):
1514
self._artist = artist

0 commit comments

Comments
 (0)