open-forest-observatory / geograypher

Multiview Semantic Reasoning with Geospatial Data
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

Remove unused colors from colorbar pyvista #59

Closed russelldj closed 3 months ago

russelldj commented 5 months ago

As seen in the right hand side, there are only three classes, but all ten levels of the colormap are shown. It would be nice to only show the classes that are used and labeled. Probably looking at this line would be a good place to start.

image

Ruprabhu25 commented 5 months ago

Looking at the pyvista docs for plotter.py and scalar_bars.py, I found that the argument to limit the colors is likely set by adding this key/value pair to scalar_bar_args before we pass it in to plotter.add_mesh(). The next step is determining how many colors there are before we call plotter.add_mesh(). Currently looking if we can determine that dynamically.

russelldj commented 5 months ago

Good find, that seems promising. You can use the self.IDs_to_labels here to compute the number of classes. It's a dictionary mapping from the integer class ID to the human-readable label. So the number of colors would be the max ID plus one to account for zero-indexing.

russelldj commented 5 months ago

To clarify, the reason you need to take the max class and not just the length of the dictionary is there may not be a ID/name pair for each sequential ID.