Package: nbplot
nbplotCommand-line utility to quickly plot files in a Jupyter notebook.Tools like pandas+matplotlib are very powerful, but it takes some time to plot a file from scratch: run a Jupyter notebook instance, create a notebook, import the modules, go grab the path of the file, remember how to callread_csvproperly, create the matplotlib figure, etc. The goal ofnbplotis to remove that friction and make this as easy as launching a dedicated tool likegnuplot.DemoInstallationPython 3.7 or higher required.pip install nbplotFeaturesCan be fully configured via templates. A template is just a notebook with some special variables that will get replaced.Ships with a default template for numpy+matplotlib and one for pandas+matplotlib.Can guess the column delimiter of text files.Data can be directly read from stdin, and the string will be embedded in the generated notebook.Will try to reuse an existing instance of notebook server (inspired bynbopen).ExamplesPlots$ cat mydata.txt
1 1
2 4
3 9
4 16

$ nbplot mydata.txtGenerates a notebook~/nbplot/{{date}}-mydata.ipynbwith the code to loadmydata.txtwithpandas.read_csvand the guessed space delimiter.Opens the notebook in the browser, reusing existing instances of Jupyter if possible, starting a new one otherwise.$ nbplot -t numpy mydata.txtGenerates the notebook with thenumpytemplate, usingnumpy.genfromtxtto load the file.$ nbplot mydata1.txt mydata2.txt [...]Generates a notebook that loads all the input files in the same plot.$ for i in `seq -10 10`; do echo $i $((i*i)); done | nbplot -Reads the data to plot from stdin and generates a notebook to plot it, with the data embedded as a string.Images$ nbplot -t imshow image1.png image2.jpgUses theimshowtemplate to generate a notebook that loads and displays the 2 images with matplotlibimshowandPIL.Image.$ nbplot -t imshow paste-imageUse the specialpaste-imagefilename to directly plot an image from the clipboard. It will get embedded into the notebook via a base64 string.$ nbplot -t daltonize Ishihara_9_from_wikipedia.pngThedaltonizetemplate generates a notebook with the same image rendered with various color filters that can either help color-blind people to better see the contrasts, or designers to simulate different kinds of color blindness. Powered by thedaltonizemodule.Empty notebook, no input files$ nbplot -t empty -o empty.ipynbCreates an empty notebook in the current folder with the nameempty.ipynband opens it.Creating a custom templateTemplates are just regular.ipynbnotebooks, with special variables like the filenames to plot that will get replaced when generating the output notebook.The easiest way to create a custom template is to copy and adapt an existing one from thetemplates/folder of the repository, and put it in your~/.nbplot/folder, next to the configuration file. The name of the template is defined inmetadatadictionary defined in the special cell that stars with a# [[nbplot]] templateline.The search for template files is recursive, so it is possible to manage custom templates in e.g. an external repository and git clone it in a subfolder under~/.nbplot.Configuring the default behaviorWhen first launched,nbplotgenerates a configuration file in~/.nbplot/config.ipynb. It is also a notebook, and the config dictionary will be read after evaluating the cell. The main options are the default template, the folder from which to start the notebook instance, and the folder where the generated plots will be saved.ChangeLogv0.3 (April 6th, 2021)Add an empty template and accept to run without input filesFix the recursive globbing of user templates to follow symlinksFix the image type conversion in the daltonize templatev0.2 (April 4th, 2021)New features:Add animshowtemplate to show images withmatplotlib.imshow.Add adaltonizetemplate to show images enhanced for colorblind people.Glob templates recursively in~/.nbplot. This makes it possible to manage private templates via a git cloned subfolder.Add thepaste-imagespecial filename to grab an image from the clipboard and embed its content in the notebook.Fixes:Fix the metadata to automatically load a Python kernel.Don't fail when trying to determine the delimiter on binary files.pandas: handle files with multiple spaces / tabs between columns.v0.1 (April 1st, 2021)Initial release.