Dynamically change uniformly applied color of a large set of area series? #2529
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Looks like you attached the same code snippet under both "Color Picker Construction" and "Update color callback" 😂. Anyway... I bet that when you try to use themes, the area series remain transparent no matter what color you specify in the theme - correct? If so, here are some bad news for you: area series uses the fill color specified in with dpg.mutex():
for area in self.series['areas']:
dpg.configure_item(area, fill=...)How many areas do you have in your plot? Judging by the picture, it must be a lot - thousands maybe? Another piece of bad news is that functions like Unfortunately I don't know of any widget that would take colors from the theme (or from any other single source) and would render multiple arbitrary polygons. Looks like a loop is the only way to recolor them, be it Also, a couple of things I've noticed in your code. In FWIW you can actually do a self.fill_color_item = dpg.add_theme_color(dpg.mvPlotCol_Fill, app_data, category=dpg.mvThemeCat_Plots)
# ...
dpg.set_value(self.fill_color_item, new_color)Of course it won't help with the fill color on Also, it turns out plot axes ignore themes bound to them, so if you want to apply a theme to all series (e.g. to set line thickness), bind it once to the plot itself rather than to the Y axis. There's no need to bind the theme individually to every area series for that. If you still struggle with performance issues, take a look at DearCyGui. |
Beta Was this translation helpful? Give feedback.
-
|
I know it's frowned upon when writing additional comments on already solved topics, but I've stumbled onto some hurdles when imploying gpu module in resolving my task at hand so I would like to give some correct pointers to whoever is reading this in the future. So here it goes. As of right now, Blender's gpu module doesn't not allow for multithreading, since it's context for drawing management can only exist on the main thread, therefore I suggest switching to any other third party libraries or wrappers such as ModernGL that does allow for that. I have personally switched to using ModernGL, and in addition to it being multi-thread friendly it's also (to no one's surprise) light years faster than solely relying on DearpyGUI for mesh drawing, plus it's much more modular in that regard. |
Beta Was this translation helpful? Give feedback.

Looks like you attached the same code snippet under both "Color Picker Construction" and "Update color callback" 😂.
Anyway... I bet that when you try to use themes, the area series remain transparent no matter what color you specify in the theme - correct? If so, here are some bad news for you: area series uses the fill color specified in
add_area_series(defaults to transparent) and does not use the fill color from the theme at all. That is, the only way to recolor them is to doconfigure_itemon each one. You can wrap that inwith dpg.mutex():to prevent rendering with half the image recolored and half in the old color: