Initial release - v0.1.0
Very quick announcement of a package to view your plots in your browser (with its history).
I primarily use neovim as my coding interface, and one thing that’s added some friction is plotting. With GLMakie.jl an interactive window pops up that allows you to view your plots, but unlike VSCode with the plot viewer, it’s not possible to look at your plotting history (which I find helpful when I’m iterating on a figure). CairoMakie does allow this through the creation of the temporary static image files, but I haven’t found a good image viewer on my Mac that allows for the clean scrolling between version - I’ve tried many and none quite fit the bill (for me). Coming from R, I wanted something like the excellent httpgd package, where I could open up browser tab and connect to the port that shows all the plots generated in a session. That’s what this package aims to do.
How to
Install BrowserPlots directly from GitHub:
import Pkg
Pkg.add(url = "https://github.com/arnold-c/BrowserPlots.jl")
Install a plotting package separately if you do not already have one:
Pkg.add("CairoMakie")
Use a Makie backend capable of producing PNG output, such as CairoMakie (though I have tested it with GLMakie and it does work):
using BrowserPlots
using CairoMakie
browse()
x = range(0, 2π; length = 200)
lines(x, sin.(x); axis = (; title = "Sine wave"))
browse() starts a local server, registers the browser gallery with Julia’s display stack, and opens the gallery in a new tab. In an interactive session, plots displayed by Julia are added automatically. In a script—or whenever output is suppressed—call display explicitly:
p = plot(rand(20))
display(p)
browse(; port = 8008, silent = true) can be used to run the render the plots at a particular port (8008) and not launch a new browser tab (if you already have the port open and you are just starting the julia session, for example).
Once in the viewer, you can remove particular plots from the history, and/or clear the entire history. You can also clear the history from the terminal with the command clear_history!()
Headless development
One thing I’ve played around with is a headless environment - WGLMakie.jl and Bonito.jl do allow for this, but I never had great luck integrating them into my workflow (most likely just user error!). With BrowserPlots.jl I can just use Tailscale serve and access localhost as if it were the local machine.
tailscale serve --https=<port> localhost:<port>
Obviously this requires having access to your tailnet on both machines, which may not work for your environment.
AI Disclosure
All the code written in the package was written using codex - I have reviewed it to ensure it’s using a broadly reasonable approach, but this is just a quick package to fit my requirements, so the majority of my thought and time has been spent reviewing that the functionality I need works as expected. It’s very possible that in the (admittedly very small and simple) package there are some bugs that I haven’t discovered yet. If you’d prefer not to use it because of the AI development, that’s fine - I’m making it publicly available in case anyone else find this useful.
