Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Example in hello_world tutorial doesn't show the circuit image [Arch Linux] #2669

Open
1 of 5 tasks
OmegaTwiddle opened this issue Feb 24, 2025 · 1 comment
Open
1 of 5 tasks

Comments

@OmegaTwiddle
Copy link

URL to the relevant documentation

I'm following the tutorial at https://docs.quantum.ibm.com/guides/hello-world

If I follow Step 1 line for line, my script just exits without printing or displaying anything.

Select all that apply

  • typo
  • code bug
  • out-of-date content
  • broken link
  • other

Describe the fix.

I needed to add the below code to get it to show anything (this wasn't obvious to me).

import matplotlib.pyplot as plt 
plt.show()
@frankharkins
Copy link
Member

frankharkins commented Feb 27, 2025

Hi @OmegaTwiddle, how are you running the code examples?

I've seen this confusion before when users run code examples in a Python script: Our documentation is written in Jupyter notebooks. In notebooks, the output of the last line of a cell is displayed right after the cell. In the case of qc.draw(), the output is a matplotlib figure, which has a rich representation (image). That's why you see the image immediately after the cell.

I do wonder if there's a way we can make this clearer to users though.

EDIT: I've since realised we do have a comment about that in the same code cell:

# Return a drawing of the circuit using MatPlotLib ("mpl"). This is the
# last line of the cell, so the drawing appears in the cell output.
# Remove the "mpl" argument to get a text drawing.

Do you remember if you saw this comment? I'm wondering how we could make it clearer to future readers.

@javabster javabster removed the needs triage 🤔 this issue needs to be prioritized by the docs team label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

5 participants