How to create a figure that can be switched from circles showing 'continous' data to bar plot showing categorical data dynamically

I would like to ask how to create a figure that can be switched depending on the data in the linked datasource to show the data using say circles or using bar plot. The issue is that if it is in the case of
circles the axis are continuous, but in the case of bar plot I want the x axis using factors. So I cannot just reat both the circles and barplots and set one of them to visible.

The data in the data source themselves dynamically change based on feedback from widgets.

I initially tried to solve this by creating two separate figures (one for circles one for bar plots) and tried to replace each other in the children array of a layout, but this seems to completely destroy several of the automatic bindings, and I could find much on such dynamical layout changes on the forums to work with other than warnings that exactly such bad things are likely to happen.

I would make two separate plots, and either:

  • add them both together and toggle their visibility appropriately
  • add one at a time and swap them out appropriately

It sounds like you tried the second approach, which I have seen used successfully on many occasions, but had some issues. But it is impossible to speculate without a Minimal Reproducible Example.

Can you please be a bit more specific on how to ‘add them both together and toggle their visibility appropriately’. From the documentation I read so far it is not possible to hide whole figures?

Maybe this thread can help? I made an example of what I think you’re looking for there.

1 Like

I see, so there is actually a visible property on figures. Somehow I thought I read somewhere there ins’t.
Also what wasn’t clear to me is if the layout is going to adjust if part of it becomes not visible, but apparently it does.

Thanks a lot!

1 Like

Yeah I don’t understand how it magically just adjusts the layout accordingly in a nice intuitive way either… it just works and i’m not complaining :joy:

1 Like

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