Skip to content

Commit a4c51c9

Browse files
committed
DOC: fix
1 parent 4c25392 commit a4c51c9

File tree

5 files changed

+79
-15
lines changed

5 files changed

+79
-15
lines changed

doc/_static/image-rotator.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// accessible JavaScript tab switcher
2+
// modified from https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role
3+
4+
function getRandomInt(max) {
5+
return Math.floor(Math.random() * max);
6+
}
7+
8+
var images_rotate = [
9+
{"image": "sphx_glr_plot_001_2_00x.png", "caption": "plot(x, y)", "link": "plot_types/basic/plot.html"},
10+
{"image": "sphx_glr_step_001_2_00x.png", "caption": "step(x, y)", "link": "plot_types/basic/step.html"},
11+
{"image": "sphx_glr_scatter_plot_001_2_00x.png", "caption": "scatter(x, y)", "link": "plot_types/basic/scatter_plot.html"},
12+
{"image": "sphx_glr_pcolormesh_001_2_00x.png", "caption": "pcolormesh(X, Y, Z)", "link": "plot_types/arrays/pcolormesh.html"},
13+
{"image": "sphx_glr_contourf_001_2_00x.png", "caption": "contourf(X, Y, Z)", "link": "plot_types/arrays/contourf.html"},
14+
{"image": "sphx_glr_step_001_2_00x.png", "caption": "step(x, y)", "link": "plot_types/basic/step.html"},
15+
{"image": "sphx_glr_streamplot_001_2_00x.png", "caption": "streamplot(X, Y, U, V)", "link": "plot_types/arrays/streamplot.html"},
16+
{"image": "sphx_glr_bar_001_2_00x.png", "caption": "bar(x, height) / barh(y, width)", "link": "plot_types/basic/bar.html"},
17+
{"image": "sphx_glr_hist_plot_001_2_00x.png", "caption": "hist(x)", "link": "plot_types/stats/hist_plot.html"},
18+
{"image": "sphx_glr_imshow_001_2_00x.png", "caption": "imshow(Z)", "link": "plot_types/arrays/imshow.html"},
19+
];
20+
21+
document.addEventListener("DOMContentLoaded", function(event) {
22+
///////////////////////////////////////
23+
// rotate images in images-rotate directory:
24+
var ind = getRandomInt(images_rotate.length);
25+
var info = images_rotate[ind];
26+
var img_src = "../_images/" + info.image;
27+
var caption = info.caption;
28+
var link = "https://matplotlib.org/stable/" + info.link;
29+
var html = '<a href="' + link + '">' +
30+
'<img class="imrot-img" src="' + img_src + '" aria-labelledby="sample-plot-caption"/>' +
31+
'<div class="imrot-cap" id="sample-plot-caption">' + caption + '</div>' +
32+
'</a>';
33+
document.getElementById('image_rotator').innerHTML = html;
34+
35+
ind = getRandomInt(images_rotate.length);
36+
info = images_rotate[ind];
37+
img_src = "../_images/" + info.image;
38+
caption = info.caption;
39+
link = "https://matplotlib.org/stable/" + info.link;
40+
html = '<a href="' + link + '">' +
41+
'<img class="imrot-img" src="' + img_src + '" aria-labelledby="sample-plot-caption"/>' +
42+
'<div class="imrot-cap" id="sample-plot-caption">' + caption + '</div>' +
43+
'</a>';
44+
document.getElementById('image_rotator2').innerHTML = html;
45+
46+
});

doc/_static/mpl.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,16 @@ div.wide-table table th.stub {
120120
left: 0;
121121
position: sticky;
122122
}
123+
124+
.imrot-img {
125+
display: flex;
126+
margin: auto;
127+
max-width:15em;
128+
align-self: center;
129+
}
130+
131+
.imrot-cap {
132+
text-align: center;
133+
font-style: italic;
134+
font-size: large;
135+
}

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,4 +772,5 @@ def setup(app):
772772
bld_type = 'rel'
773773
app.add_config_value('skip_sub_dirs', 0, '')
774774
app.add_config_value('releaselevel', bld_type, 'env')
775+
app.add_js_file('image-rotator.js')
775776
app.connect('html-page-context', add_html_cache_busting, priority=1000)

doc/users/index.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
.. redirect-from:: /contents
44

5-
65
##########
76
User guide
87
##########
98

10-
119
.. grid:: 1 1 2 2
1210

1311
.. grid-item-card::
1412

13+
.. raw:: html
14+
15+
<div class="grid__intro" id="image_rotator"></div>
16+
17+
1518
.. toctree::
1619
:maxdepth: 1
1720

@@ -20,6 +23,16 @@ User guide
2023
faq/index.rst
2124
resources/index.rst
2225

26+
.. grid-item-card::
27+
28+
.. toctree::
29+
:maxdepth: 2
30+
31+
explain/index.rst
32+
33+
34+
.. grid:: 1 1 2 2
35+
2336
.. grid-item-card::
2437

2538
.. toctree::
@@ -31,21 +44,10 @@ User guide
3144
../tutorials/index.rst
3245
../gallery/index.rst
3346

47+
.. raw:: html
3448

49+
<div class="grid__intro" id="image_rotator2"></div>
3550

36-
.. toctree::
37-
:hidden:
38-
:maxdepth: 1
39-
40-
41-
.. grid:: 1 1 2 2
42-
43-
.. grid-item-card::
44-
45-
.. toctree::
46-
:maxdepth: 2
47-
48-
explain/index.rst
4951

5052
.. grid-item-card::
5153

galleries/users_explain/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
.. redirect-from:: /users/explain
55

6+
7+
68
Using Matplotlib
79
----------------
810

0 commit comments

Comments
 (0)