-
Notifications
You must be signed in to change notification settings - Fork 40
Add a Vega plotting library #77
Conversation
See this notebook for an example: https://github.com/scijava/scijava-jupyter-kernel/blob/2e2b8fe3af3bd9a36531336ace91ccf3e0a03752/notebooks/Vega.ipynb At the moment the rendering does not work in JLab because the library is using the soon-to-be-released Vega3/Vega-Lite2 specifications. See this PR for progress: jupyterlab/jupyter-renderers#15 |
To test plot you can copy paste the JSON string into https://vega.github.io/editor |
Something I am not willing to develop in a near future but that would be awesome to have is a Swing widget that can render the VegaLite JSON string as a plot (useful when used outside of the SJK). |
I think implementing a builder pattern would allow easy plotting. |
Here is an overview of the builder pattern I want to implement: builder = plt.builder().name("Bar Chart").
channel('x').field('a').type('ordinal').build().
channel('y').field('b').type('quantitative').build().
mark().type('bar').build().
data().values(data).build
plot = builder.build() or equivalent builder = plt.builder().name("Bar Chart")
builder = builder.channel('x').field('a').type('ordinal').build()
builder = builder.channel('y').field('b').type('quantitative').build()
builder = mark().type('bar').build()
builder = builder.data().values(data).build()
plot = builder.build() This is the most straightforward low-level way of creating plots I can think of. Then later, a layer of "convenient" functions will come on top of that. |
…lipse preferences
I have implemented a minimum working builder pattern to be able to reproduce the first example of the Vega Lite website. See this notebook for the code. I found it super convenient to use for a low-level API (you still need to understand how Vega Lite works to be able to use it). However, I find the implementation very complex. For each JSON field, I have a "regular" class that use Jackson annotations and provide getter and setter for all the child fields. Then for each of the previous classes, I have a Builder class that implements the builder pattern and almost the same setter as in the "regular" classes. If someone can think of a smaller and less complex-to-maintain architecture, I am all open. |
Hi @hadim, I'm working on a high-level API for plotting in ImageJ. |
Hi @maarzt That would be nice to have a "wrapper" to connect your high-level API with this low-level one. It could also be used to display plot outside of Jupyter and directly in Fiji. We would just need to write an HTML Swing layout that can display Vega-Lite JSON. It should not be too hard considering that Vegas is already doing it. |
Very low level at the moment and only a few part of the Vega Lite API is supported.
The goal is to implement all (or almost) the Vega Lite API at a very low level and then add convenient functions that make plotting as easy as with matplotlib.
The Vega Lite specification is pretty easy to understand and is not that complex: https://vega.github.io/vega-lite/docs/spec.html
Technically the library is using the Jackson JSON library (https://github.com/FasterXML/jackson) to automatically map attributes to JSON fields.
When stable enough and if @ctrueden agree, that plotting library should be moved to its own repository under the Scijava GitHub organization.