cc @Timo
@jackwayneright This is a topical question, as we have just lately been discussion how to update the docs around this area. By and large the answer to your question is just “history”
-
When Bokeh was first conceived, one of the major priorities was to make it accessible to folks who are only incidentally coders, as part of their science/data science/analyst role, and not trained in computer science, or otherwise professional developers. Towards that end it was thought to center an API around simple functions, rather than starting from OO classes and objects.
-
There was also a time (in the past) when figure was needed in order to do real work. In addition to creating a Figure, the figure function also put the Figure inside a default layout and did some other things. These was necessary for uninteresting technical reasons that are no longer relevant. Nowadays figure just returns a new Figure and does nothing more.
However as far as I know, we don’t explicitly demonstrate Figure anywhere in the docs (outside the reference guide) or examples. So figure is by far the dominant and established API and it’s really not possible to consider changing that at this point, not even on a major release bump (not that I want to, either). It would still be good to find a way to simplify the situation to clarify the user documentation, but unfortunately there are drawbacks, problems, or breakages with all of these possible changes:
figure = Figure
class figure(Figure)
- renaming
Figure → figure and inheriting from a no-op Figure
I won’t get into the details but any real change is probably Bokeh 3.0 territory. What I would probably personally advocate for is just renaming Figure to figure and getting rid of Figure entirely. It’s a little unorthodox to have a lower-case class name in Python APIs but it is also not unheard of and I think would be justified in this instance.
As for why you should prefer figure it is because that is what we have settled on as most supported, what we officially demonstrate, and what is most unlikely to ever change.