2.6. Code Cells

2.6.1. Maximum Line Length

We recommend you to set the maximum line length to be 78 to avoid automatic line break in PDF. You can enable the Ruler extension in nbextensions to add visual vertical line in Jupyter when writing codes.

'-' * 78

2.6.2. Hide Source and Outputs

We can hide the source of a code cell by adding a comment line # Hide code in the cell. We can also hide the code cell outputs using # Hide outputs

For example, here is the normal code cell:


Let’s hide the source codes


Also try hiding the outputs

# Hide outputs

2.6.3. Plotting

We recommend you to use the svg format to plot a figure. For example, the following code configures matplotlib

%matplotlib inline
from IPython import display
from matplotlib import pyplot as plt
import numpy as np


x = np.arange(0, 10, 0.1)
plt.plot(x, np.sin(x));