quick kandy question -- is there a way to make the...
# datascience
g
quick kandy question -- is there a way to make the legend more compact? (i've added the border for visibility/debugging but) i'd like to reduce the margins/padding elements, reduce the length of the coloured line, ...
Copy code
layout {
        title = plotTitle
        style {
            legend {
                justification(0.0, 1.0)
                position = LegendPosition.Custom(0.0, 1.0)
                direction = LegendDirection.VERTICAL

                background {
                    //fillColor = Color.rgba(0, 0, 0, 0.0)
                    borderLineColor=Color.RED
                    borderLineWidth = 2.0
                    borderLineType= LineType.SOLID
                }

                text {
                    fontSize = 6.0
                    //angle=45.0
                    margin = Margin(0.0)

                }
            }
        }
    }
margin doesn't seem to do anything here (nor angle, for that matter, not that i really needed this)
also i'm not sure what's going on but my
Copy code
direction = LegendDirection.VERTICAL
doesn't seem to work anymore (in the screenshot, i have a
color{legend{type = LegendType.DiscreteLegend(nCol = 2)}}
but when i remove it, the legend goes back to horizontal mode for some reason
a
Hello! Lets-Plot recently added margin customization (as well as many other parameters) in legend, and we haven't had time to add this to the Kandy API yet. I will create an issue about this, thank you for reporting it! For now, the only workaround is converting your plot to Lets-Plot and adjust style via its API:
Copy code
plot.toLetsPlot() + theme(legendMargin = 0)
Oh, and regarding direction - it's simply a bug in the implementation 😅
This should work
Copy code
plot.toLetsPlot() + theme(legendMargin = 0).legendDirectionVertical()
g
No rush on my end, I’ll wait for a next release - can you share the issue link when you have it? Thanks for confirming!
g
Perfect, thank you 🙏