ocean-transport / cds_hacking

MIT License
0 stars 0 forks source link

Styling hvplot output in notebook #1

Open jbusecke opened 3 years ago

jbusecke commented 3 years ago

I was super impressed by the neat styling of @cisaacstern s work here.

I am wondering if I can apply similar things via a configuration file in all my notebooks?

cisaacstern commented 3 years ago

@jbusecke, the example you've linked is deployed on a Bokeh server using Panel's command line interface: https://panel.holoviz.org/user_guide/Deploy_and_Export.html#launching-a-server-on-the-commandline

In general, Panel objects in a notebook can be deployed in this way by appending .servable() to them, and then calling panel serve notebook_file.ipynb from the command line, as described above. The interactive object will then be viewable in its own browser tab, without any code.

This same command line syntax can also be used with .py files. (This is the tangent I started down during the meeting: I believe developing more complex Panel apps is easier to do in .py files, mainly because they play much more nicely with git. You can still experiment with these files line-by-line by using jupytext, which allows you to open and run .py files in Jupyter.)

To unlock more customization in the appearance of your final app, I'd recommend exploring Panel's Templates, and in particular the Custom Template, which is what I used to make the app you linked to above. This is a minimal Jinja HTML template to which you can add whatever custom CSS styles (or even JavaScript) you desire.

jbusecke commented 3 years ago

Awesome, thanks for the detailed description! I will def try to use something like this for the promo of my latest paper (and probably come back and bug you about it haha).

But am I correct that this is not possible to achieve for the 'regular' widget-notebook hvplots? This might be overkill, but I was curious to whether I can change the appearance of hvplots (linewidth, ticksize, etc.) for my exploratory work aswell.

cisaacstern commented 3 years ago

I believe most hvplots are actually Bokeh plots under the hood. So you might have luck adapting some of the methods described here: https://docs.bokeh.org/en/latest/docs/user_guide/styling.html

Let me know if that looks promising! If not, we'll go back to the drawing board.

jbusecke commented 3 years ago

That is exactly what I was looking for. Thanks!