Closed schlegelp closed 3 months ago
As expected, adding a new backend has played havoc with the test suite but all tests are passing now. Visualisation-related testing is still a bit of a hack and relies mostly on the tutorial notebooks. For example, not every functionality is tested with every backend. I don't think I want to address that in this PR.
A couple more test-related notes:
test_lookupdistdotbuilder_builds
tests because they started hanging for no good reason. We've had issues with those and the use of threads in the past. Need to investigate.
This PR represents a medium-sized rework of the plotting system.
First up the unpleasant part as there are a few (minor) breaking changes:
synapse_layout
parameter was renamed tocn_layout
(matching e.g. other parameters such ascn_colors
)navis.plot2d
(e.g.view=("x", "-z")
) are now implemented by inverting axes rather than changing the underlying datamatplotlib
is now3.9
(was3.6
)plotly
backend is not part of a minimal install anymore (still installed withnavis[all]
)Now to the fun bits:
Octarine
This PR adds Octarine as the default backend for 3d plotting from terminal (it also works in Jupyter). With it comes a smart(er) backend selection where we check which backends are available and choose the nominally "best". For non-Jupyter the order is:
Octarine > Vispy > plotly
. For Jupyter the order is currentlyplotly > Octarine > k3d
. The latter may still change since this PR also makes the internalnavis.Viewer
Jupyter-capable.pip install navis[all]
will now install all supported backends. The minimal installpip install navis
installs onlymatplotlib
.Plot 2D style
The default style for
plot2d()
has been a bit of an eyesore and I noticed that in my own code I often heavily tinker with the defaults. With this PR we're changing the defaults so we get nice looking plots off the bat. Here are two examples:These are the major changes:
radius=True
by default (quietly ignored if skeleton has no radius)mesh_shade
parameter)view
parameter now also works with methods3d
and3d_complex
(previously it was quietly ignored)To account for the new
radius=True
default, thecolor_by
andshade_by
parameters should now also work when plotting skeletons withradius=True
(i.e. we internally map the skeleton node colors onto the derived mesh's vertices).Parameter validation
Previously, both
plot2d
andplot3d
accepted a vague number of keyword arguments, some of which were documented while others were not. Both plotting functions still accept keyword arguments but this PR introduces Python data classes to validate parameters. Here is a quick example of what this looks like:Advantages:
kwargs.get(parameter, default=XXX)
in multiple locationsIt's still not perfect because some features are backend-specific but definitely better than before.
Misc
legendgroup
parameter (plot3d
with plotly backend) now also sets the legend group's title (@Robbie1977)flybrains
andcloud-volume
are now treated as "specialised" dependency, meaning they aren't automatically installed withnavis[all]
(note to self: this may be an issue with e.g. the neuprint interface butneuprint-python
is also not installed by default)TODOs