# Plot.show() in Quarto notebook after if statement is not showing

**URL:** <https://community.seqera.io/t/plot-show-in-quarto-notebook-after-if-statement-is-not-showing/1175>\
**Category:** Ask for help\
**Tags:** multiqc\
**Created:** [September 10, 2024, 7:05am UTC](https://community.seqera.io/t/plot-show-in-quarto-notebook-after-if-statement-is-not-showing/1175 "2024-09-10T07:05:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [September 10, 2024, 7:05am UTC](https://community.seqera.io/t/plot-show-in-quarto-notebook-after-if-statement-is-not-showing/1175/1 "2024-09-10T07:05:38Z")

</div>

I have a python cell in my Quarto notebook like:

```auto
#| echo: false

print(type(run_fastqc))
if run_fastqc:
    print(run_fastqc)
    fastqc_seqgc_plot = multiqc.get_plot("fastqc", "Per Sequence GC Content")
    fastqc_seqgc_plot.show()

```

However the plot is not showing up. The panel only shows:

```auto
<class 'bool'>
True

```

If I move the plot to outside the `if` statement

```auto
#| echo: false

print(type(run_fastqc))
if run_fastqc:
    print(run_fastqc)

fastqc_seqgc_plot = multiqc.get_plot("fastqc", "Per Sequence GC Content")
fastqc_seqgc_plot.show()

```

The plot shows up. Am I doing something silly (I have little understanding of python) or is this a bug?

Repo with reproducible example:[GitHub - mahesh-panchal/nextflow-quarto-multiqc-demo: Using Quarto within Nextflow to make a MultiQC report](https://github.com/mahesh-panchal/nextflow-quarto-multiqc-demo/tree/main)

Open in Gitpod and use

```auto
pixi run nextflow

```

The last process makes the quarto notebook. The qmd is located in `docs/multiqc_report`. The html is written to results/report.

---

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [September 17, 2024, 9:25pm UTC](https://community.seqera.io/t/plot-show-in-quarto-notebook-after-if-statement-is-not-showing/1175/2 "2024-09-17T21:25:15Z")

</div>

It seems using a ternary conditional is the solution here ( even with MultiQC 1.25 )

```auto
#| echo: false

# Have to use the ternary style syntax for if to make the plot show
# This doesn't work!
# if run_fastqc:
# multiqc.get_plot("fastqc", "Sequence Counts").show()
# This does!
multiqc.get_plot("fastqc", "Sequence Counts").show() if run_fastqc else ""

```

---

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [September 24, 2024, 9:25pm UTC](https://community.seqera.io/t/plot-show-in-quarto-notebook-after-if-statement-is-not-showing/1175/3 "2024-09-24T21:25:45Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![vlad.savelyev](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/vlad.savelyev/32/576_2.png) [@vlad.savelyev](https://community.seqera.io/u/vlad.savelyev)\
**Post date:** [October 28, 2024, 2:08pm UTC](https://community.seqera.io/t/plot-show-in-quarto-notebook-after-if-statement-is-not-showing/1175/4 "2024-10-28T14:08:58Z")

</div>

Thanks again to bring this up and sorry for not getting back to your question sooner.  
As we discussed in person, you are correct that `display` is needed to be called on `show` output unless it’s the last line in a cell. Jupyter automatically displays the output of the last line it called, but if it’s within a conditional, the output will be discarded.

Clarified that in the docs with [Document use of display to show plots in notebooks by vladsavelyev · Pull Request #2938 · MultiQC/MultiQC · GitHub](https://github.com/MultiQC/MultiQC/pull/2938)
