How to update figure title

In this page I want to update figure title when select change.
How can I do that using django ?

figure instances have a .title property, which retrieves a Title model… which has a .text property…

So in your callback you can update the title by altering “fig.title.text” where fig is the figure instance you’re targeting.

1 Like

where do you find in doc fig.title.text?

Basically I only “knew” about that from the object-oriented programming mentality. Anytime you make an instance of something, say “fig = figure()”, try typing dir(fig) into the console and see all the stuff that instance is comprised of. You’ll see “title” in that list, which returns an instance of a Title model… then go dir(fig.title) and you’ll see a .text attribute, and so the rabbit hole goes.

Bokeh model instances generally also have a .properties_with_values() method that retrieves the current stuff assigned to that instance too in dictionary form, I find that super helpful too to quickly see what’s there.

Alternatively you can browse the docs and get more long winded explanations of each property etc. Guaranteed in the figure() documentation you can find that it has a “title” property, and it’ll say that .title property points to a Title model, and in the docs for the Title model you’ll find a .text property describing exactly what it controls.

Not to get too meta about this but in general the docs are structured consistent with a library designed with maximum modularity in mind. Users are given obscene power: you can mix and match essentially an infinite number of combinations between the number of models available (not even considering the very possible concept of custom models), each containing a huge number of properties/options, and the ability to manipulate them via a massive number of callback triggers. This is amazing, but to have that modularity/flexibility sometimes seemingly simple things like changing a title text take sifting through a few more layers of abstraction than you’d expect. But trust me, it’s worth it :smiley:


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.