grass.jupyter: Add legend support to InteractiveMap (#5468)#7072
grass.jupyter: Add legend support to InteractiveMap (#5468)#7072saurabh12nxf wants to merge 8 commits intoOSGeo:mainfrom
Conversation
1f252e8 to
72fe5a9
Compare
…/grass into legend-feature-5468
|
Please include one or more screenshots, thank you. |
|
Hi @petrasovaa I have updated the description with the screenshots where i have shown the map without legend and map with legend |
Hey @saurabh12nxf, thanks for your contribution! Just a comment and question: the elevation map has continuous data, as you can see from the values; however, the legend appears as categories. Is that a default behaviour the user needs to change? d.legend in GRASS automatically creates a continuous bar for continuous data and categories for integer data. Why does the elevation map in your screenshot has a categorical legend? |
|
Good catch, thank you! @veroandreo I will push an update shortly. |
python/grass/jupyter/legend.py
Outdated
| if is_categorical: | ||
| label = f"Class {int(value)}" | ||
| else: | ||
| label = f"{value:g}" |
There was a problem hiding this comment.
[ruff] reported by reviewdog 🐶
| if is_categorical: | |
| label = f"Class {int(value)}" | |
| else: | |
| label = f"{value:g}" | |
| label = f"Class {int(value)}" if is_categorical else f"{value:g}" |
|
Thanks for the feedback @veroandreo @petrasovaa I updated the implementation to detect raster datatype using • elevation (FCELL/DCELL) - continuous gradient I also updated the screenshots in the PR description. Please let me know if anything else should be adjusted . And I have updated PR description which includes screenshots . |
|
Hi @petrasovaa and @veroandreo, Thank you again for all the helpful feedback during this PR! Seeing the legend feature come to life in the notebooks has been really satisfying. While looking at the codebase, I noticed that since legend.py I also noticed that the "Improve GRASS user experience in Jupyter Notebook" GSoC 2026 project idea has a Test of Skills that involves writing tests for grass.jupyter. I am planning to apply for this project, and writing test_legend.py feels like the perfect way to add genuine value to the codebase while also fulfilling that requirement. Would it be okay with you if I open a new PR dedicated to adding the pytest test suite for the legend |

Added raster legend support to
grass.jupyter.InteractiveMapas requested in #5468.Changes
Usage
Map without legend
Map with legend