Skip to content

Commit 3801b67

Browse files
authored
Fix the aspect ratio and size of the heatmap in Reports (#815)
* Fix the aspect ratio and size of the heatmap in Reports * Update figures.py
1 parent be977f5 commit 3801b67

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

nimare/reports/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@
6060
]
6161

6262
IFRAME_SNIPPET = """\
63-
<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" \
64-
src="./{0}" height="800" width="100%"></iframe>
63+
<div class="igraph-container">
64+
<iframe class="igraph" src="./{0}"></iframe>
65+
</div>
6566
"""
6667

6768
PARAMETERS_DICT = {

nimare/reports/default.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ sections:
4949
- bids: {value: preliminary, suffix: figure-legend}
5050
- bids: {value: preliminary, suffix: figure-interactive}
5151
title: Explorer
52+
iframe: True
5253
- name: Meta-Analysis
5354
reportlets:
5455
- bids: {value: estimator, suffix: summary}
@@ -77,9 +78,7 @@ sections:
7778
subtitle: FocusCounter
7879
caption: *heatmap_text
7980
description: *focuscounter_text
80-
iframe: True
8181
- bids: {value: diagnostics, diag: Jackknife, tab: counts, suffix: figure}
8282
subtitle: Jackknife
8383
caption: *heatmap_text
84-
description: *jackknife_text
85-
iframe: True
84+
description: *jackknife_text

nimare/reports/figures.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ def plot_heatmap(contribution_table, out_filename):
285285
)
286286
new_df = pd.DataFrame(new_mat, columns=new_col_labels, index=new_row_labels)
287287

288-
fig = px.imshow(new_df, color_continuous_scale="Reds")
289-
fig.update_layout(
290-
autosize=False,
291-
width=800,
292-
height=800,
293-
)
288+
pxs_per_sqr = 50 # Number of pixels per square in the heatmap
289+
plot2bar_space = 2 # Number of pixels between the heatmap and the barplot
290+
width, height = (len(col_labels) + plot2bar_space) * pxs_per_sqr, len(row_labels) * pxs_per_sqr
291+
292+
fig = px.imshow(new_df, color_continuous_scale="Reds", aspect="auto")
293+
fig.update_layout(autosize=False, width=width, height=height)
294294
fig.write_html(out_filename, full_html=True, include_plotlyjs=True)
295295

296296

nimare/reports/report.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ body {
3636
padding: 65px 10px 10px;
3737
}
3838
39+
.igraph-container {
40+
position: relative;
41+
overflow: hidden;
42+
width: 100%;
43+
padding-top: 50%;
44+
}
45+
.igraph {
46+
position: absolute;
47+
border: none;
48+
top: 0;
49+
left: 0;
50+
bottom: 0;
51+
right: 0;
52+
width: 100%;
53+
height: 100%;
54+
}
55+
3956
.boiler-html {
4057
font-family: "Bitstream Charter", "Georgia", Times;
4158
margin: 20px 25px;

0 commit comments

Comments
 (0)