Skip to content

Commit e32a760

Browse files
committed
docs: add progress_bar example
1 parent 7766109 commit e32a760

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ tiled = imgviz.tile(
151151
<td><pre><a href="examples/pie.py">examples/pie.py</a></pre></td>
152152
<td><img src="examples/assets/pie.jpg" width="20.0%" /></td>
153153
</tr>
154+
<tr>
155+
<td><pre><a href="examples/progress_bar.py">examples/progress_bar.py</a></pre></td>
156+
<td><img src="examples/assets/progress_bar.jpg" width="20.0%" /></td>
157+
</tr>
154158
<tr>
155159
<td><pre><a href="examples/resize.py">examples/resize.py</a></pre></td>
156160
<td><img src="examples/assets/resize.jpg" width="52.21052631578947%" /></td>

examples/assets/progress_bar.jpg

64.3 KB
Loading

examples/progress_bar.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
3+
import matplotlib.pyplot as plt
4+
5+
import imgviz
6+
7+
8+
def progress_bar() -> None:
9+
img = imgviz.data.lena()
10+
_, width = img.shape[:2]
11+
values = [0.15, 0.4, 0.65, 0.9]
12+
13+
viz = img
14+
for i, value in enumerate(values):
15+
y1 = 40 + i * 60
16+
viz = imgviz.draw.progress_bar(
17+
viz,
18+
yx1=(y1, 40),
19+
yx2=(y1 + 36, width - 40),
20+
value=value,
21+
fill=(0, 200, 0),
22+
background=(0, 0, 0),
23+
outline=(255, 255, 255),
24+
)
25+
viz = imgviz.draw.text(
26+
viz,
27+
yx=(y1 + 8, 52),
28+
text=f"{round(value * 100)}%",
29+
size=22,
30+
color=(255, 255, 255),
31+
)
32+
33+
plt.figure(dpi=200)
34+
plt.imshow(viz)
35+
plt.axis("off")
36+
37+
38+
if __name__ == "__main__":
39+
from _base import run_example
40+
41+
run_example(progress_bar)

0 commit comments

Comments
 (0)