I'm creating a legend in my print composer and only want "visible", or active, layers shown in the legend. This means I want only layers with the box checked in my layers panel.
Here is how I create my legend.
legend = QgsLayoutItemLegend(layout) legend.setTitle("Legend") layout.addLayoutItem(legend)
Looking at the documentation for QgsLayoutItemLegend there is a method: setLegendFilterByMapEnabled() whose description is:
This leads me to believe if I do something like:
My legend will only include "active" layers. But my legend still includes all layers, active and inactive.
What am I missing?