I just upgraded to IPython 1.0 and the new notebook interface performs really well. On my screen it now has a default width of about 50% of the page which improves readability. However, i often work with long timeseries which i prefer to display as wide as possible.
Very wide pictures will only extend further to the right. Is there a way to display output wider then the default to expand in a centered matter?
The attached picture shows a normal inline plot in the first cell, which is less wide then the default notebook width. The second plot is wider and expands to the right. This leaves about the left quarter of my screen unused.
The Plots in the Jupyter Notebook can be Centered by Using HTML CSS Code Snippet. The Code for aligning the plots at center is shown below, by using this Code Snippet all the plots can be centered in the Jupyter Notebook.
What I do is the following. This might help, but it also creates a beautifully rendered notebook.
Have a look at this online book about Bayesian Statistics. This is really nice.
They load a custom CSS at the end of the notebook using this code:
from IPython.core.display import HTML
def css_styling():
styles = open("custom.css", "r").read() #or edit path to custom.css
return HTML(styles)
css_styling()
You can download this custom CSS from the books github repo HERE: Drop it in the notebook folder and call the code above
Also note their nice matplotlibrc file. You can change the look and feel of the plots calling this code. Call this early in the notebook and all matplotlib plots will look pretty cool.
import json
s = json.load( open("bmh_matplotlibrc.json") ) #edit path to json file
matplotlib.rcParams.update(s)
Download the JSON file HERE from GITHUB
The Plots in the Jupyter Notebook can be Centered by Using HTML CSS Code Snippet.
The Code for aligning the plots at center is shown below, by using this Code Snippet all the plots can be centered in the Jupyter Notebook.
from IPython.core.display import HTML as Center
Center(""" <style>
.output_png {
display: table-cell;
text-align: center;
vertical-align: middle;
}
</style> """)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With