Replies: 7 comments 2 replies
-
This is part of a larger set of common statistical plots (e.g. pie charts, box plots, histograms, heat maps), so perhaps it's unfair for me to latch on to this one in particular. They're all possible to do in Bokeh, but we don't provide a higher level API for them. Is this something in the "we may want to do this sometime" bucket, or the "Bokeh doesn't want to be this" bucket? |
Beta Was this translation helpful? Give feedback.
-
Offhand, I would say the latter. In the past, this is exactly what we tried to do with the high level I don't really want to have a repeat of that, so to zero-th order I think this space is better filled by higher level packages like Holoviews, pandas_bokeh, Chartify, etc. We are/have considered adding a few higher level charts on an ad-hoc basis, e.g. we would like to add a contour plot, because computing the required multi-polygons is just too much work for users unless it is wrapped up somehow. We added I am not categorically opposed to considering higher level API in a more general way "for stats", but lots of questions/conditions would need to be met. There would have to be a real commitment from someone with a detailed vision, including what testing and maintenance would look like, how it could be implemented in a decoupled way, would it be better as a separate package, woudl it be better as simply some data-centric functions to adapt data in common ways for Bokeh, rather than schematized plots, etc. |
Beta Was this translation helpful? Give feedback.
-
Regarding the OP, I think it would be good to support force-direction in at least a couple of places, so it's definitely worth looking into, but it would be 100% preferable if we can find a small code or library to use w/o bringing in d3 proper. |
Beta Was this translation helpful? Give feedback.
-
Well this is fun. D3 has their force stuff in a standalone package. Using it with the BokehJS API is relatively easy. CodePen here |
Beta Was this translation helpful? Give feedback.
-
Ok that's pretty neat. It's nice that is is split out, and I guess it's only 15kb? I think I am still 👎 on adding a high level "swarm plot" as it's own named thing, but definitely I would not be opposed to including standalone force layout library and exposing its functionality in some way, so that users could build a swarm plot (it also seems like a graph layout provider could make use of it). |
Beta Was this translation helpful? Give feedback.
-
Seems like something that could be added to HoloViews, with perhaps some low-level plumbing in Bokeh... |
Beta Was this translation helpful? Give feedback.
-
Thinking about features to include in the API, but first I'll write up a high-level summary on how the simulation works. For full documentation: https://github.com/d3/d3-force Prepare NodesEach node is an object with and index, bi-variate position, bi-variate velocity, and optional fixed position. If velocities aren't provided, they're initialized at 0. The nodes are then arranged in a list of nodes. Example node:
Declare simulation and apply forces
Available forces are:
Loop through simulationStart/Stop ConditionsThe simulation runs by decaying a temperature/energy parameter Ticking with internal timerA typical "animated" simulation is started with
Ticking programmaticallyInstead of ticking with the internal timer, the simulation can be ticked in a loop:
|
Beta Was this translation helpful? Give feedback.
-
Edit: Cleaning up original post since discussion has moved on from a high-level "swarm plot" to providing a lower-level force direction API.
Swarm plots are one thing I wish I had when I first used Bokeh. I know now we generally stray away from providing pre-schemed plots, and, of course, new features don't happen without resources/time/etc.etc. but I'd like to run the idea past @bokeh/dev, maybe see what the HoloViz folks think... I spent some time compiling some "market research" below to see what's out there.
Plotly.express.box()
points=all
Seaborn.swarmplot()
RawGraphs
Bokeh models.scatter() with y=jitter()
Brainstorming...
models.swarm()
I wonder if most the functionality to make this happen can be added directly tojitter()
. Maybe we can accomplish a faux swarm plot similar to Plotly by making the jitter radius at each point proportional to data density?Beta Was this translation helpful? Give feedback.
All reactions