skip to Main Content

I want to publish an HTML (preferably) or PDF from a Jupyter notebook, however when I export from Visual Studio Code it also outputs some annoying text that I do not want for certain cells, alongside the expected output. See for example:

Input:

fig, axs = plt.subplots(2,5, figsize=(20,10))

axs[0,0].hist(pay_data_trim['amount'], bins=15, color = 'b')
axs[0,0].set_ylabel('Frequency', fontsize=14)
axs[0,0].set_title('amount', fontsize=14)
axs[1,0].boxplot(pay_data_trim['amount'])
axs[1,0].set_ylabel('IQR + Outliers', fontsize=14)

axs[0,1].hist(pay_data_trim['oldbalanceOrg'], bins=15, color = 'g')
axs[0,1].set_title('oldbalanceOrg', fontsize=14)
axs[1,1].boxplot(pay_data_trim['oldbalanceOrg'])

(by the way I haven’t finished this chunk, so the figure is incomplete)

Output:

{'whiskers': [<matplotlib.lines.Line2D at 0x7ff133493760>,
  <matplotlib.lines.Line2D at 0x7ff133493a30>],
 'caps': [<matplotlib.lines.Line2D at 0x7ff133493d00>,
  <matplotlib.lines.Line2D at 0x7ff133493fd0>],
 'boxes': [<matplotlib.lines.Line2D at 0x7ff133493370>],
 'medians': [<matplotlib.lines.Line2D at 0x7ff1334bc2e0>],
 'fliers': [<matplotlib.lines.Line2D at 0x7ff1334bc5b0>],
 'means': []}

As well as the figure (so no problems with that). However I don’t want to publish the meaningless output text. Does anyone know how to mute it in Visual Studio Code? Alternatively, if you can recommend a software/interface/anything that I can use to publish this without the unwanted text, I’m happy to take recommendations.

Thanks for your help!

2

Answers


  1. Chosen as BEST ANSWER

    Adding plt.show() at the end of the statement solved the problem, as suggested by @Michael S.

    Additionally, comments from @Wayne and @JialeDu were very helpful.


  2. Open the jupyter file with Chrome and convert it to PDF by printing.

    Export your Jupyter Notebook

    Note: For PDF export, you must have TeX installed. If you don’t, you will be notified that you need to install it when you select the PDF option. Also, be aware that if you have SVG-only output in your Notebook, they will not be displayed in the PDF. To have SVG graphics in a PDF, either ensure that your output includes a non-SVG image format or else you can first export to HTML and then save as PDF using your browser.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search