NimueSTEM
NimueSTEM

Reputation: 303

Output from matplotlib in Juptyter Notebook

I have functioning code in Juptyer notebook to simulate a game of snakes and ladders (chutes and ladders in some places). The code produces additional out that I have no idea where it is coming from our what parts of it mean. Ideally I'd like to (a) know why its there and (b) supress it.

Next to Out 1: Juptyer is displaying Text(0.5,1.0, 'Simulated Duration of Snakes & Ladders Games Board')

The 'Simulated Duration of Snakes & Ladders Games Board' is the title I've just set.

What does the 0.5,1.0 refer and can I supress the output -- so that just the image is displayed.

I am assuming this is a parameter somewhere I pass to matplotlib or seaborn?

Sorry for such a low level Q.

enter image description here

Upvotes: 3

Views: 1144

Answers (2)

mmore500
mmore500

Reputation: 101

The evaluated value of the last statement in a notebook cell will display in the output area.

For instance, a last statement abs(-7) will show a corresponding 7 in cell output.

You can suppress displayed values by appending a no-op like pass or ... after the last statement in a cell.

abs(-7)
pass

Alternately, assign to a dummy variable, like

__ = abs(-7)

`

Upvotes: 0

Sheldore
Sheldore

Reputation: 39072

Just add a semicolon ; at the end of the last line of your Jupyter cell to suppress the output. So use

plt.title("Simulated Duration of Snakes & Ladders Games Board"); # <--- Semicolon 

The printed line just shows the text (figure title) that you passed to the plt.title and the numbers 0.5, 1.0 tell the location of the title, which is 0.5 (centered) on the x-axis and 1 on the y-axis in relative (or fractional) coordinates.

Upvotes: 3

Related Questions