Not sure why output includes <matplotlib.text.Text at 0x7f1f5faaa550>.

1,261 views
Skip to first unread message

Flemish Fakir

unread,
Jul 1, 2016, 8:12:21 AM7/1/16
to Project Jupyter
Hi

I've just started to play around with Jupyter and Scipy and I'm wondering why when I run this code (refer to image) why I get this (<matplotlib.text.Text at 0x7f1f5faaa550>) extra output. Can someone tell me thanks in advance.

Kind regards, Fakir

Eric Gentry

unread,
Jul 1, 2016, 8:50:50 AM7/1/16
to jup...@googlegroups.com
If you end a notebook cell with a function, but don't assign the result to a variable, the notebook will display the result as the output of the cell.

In this case, you ended the cell with the function "ylabel('Gamma')", which returns an object of type matplotlib.text.Text. (It's a little confusing because the "ylabel" function both changes the current figure and returns a new object)  You did not assign the function result to a variable, so it displays the result as the cell output (in addition to the figure).  The same thing happens for function results in the standard python shell -- if you enter the line "ylabel('Gamma')", it will show "<matplotlib.text.Text ... >"

Usually it does not cause any trouble, but if you really want to suppress the output you can:
  • put a semi-colon at the end of the last line: "ylabel('Gamma');"
  • assign the result of the function to a variable: "_ = ylabel('Gamma')"   (where "_" is a common name for a variable you don't want to use later)


- Eric

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/1edd8d4c-a015-4406-95d0-a1cc67032864%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Flemish Fakir

unread,
Jul 1, 2016, 8:53:04 AM7/1/16
to Project Jupyter
I see. Thank you.
Reply all
Reply to author
Forward
0 new messages