lets-plot-kotlin
lets-plot-kotlin copied to clipboard
incorrect legend
I have plotted a deprogram by combining geomSegment() and geomPoint(). When I apply color schemes to each function, I get a joined legend which I would want to be separated.

In the picture above I want to have different legends for "sex" and "age", not joined together.
Here is the part of code that creates a deprogram plot:
`operator fun Plot.plus(dendro: GeomDendroLayer) = run {
this + geomSegment(dendro.edgesData) {
x = "x1"
y = "y1"
xend = "x2"
yend = "y2"
linetype = dendro.ops.edgeLinetype
color = dendro.ops.edgeColor
} + geomPoint(
dendro.pointsData
) {
x = "x"
y = "y"
shape = dendro.ops.nodeShape
color = dendro.ops.nodeColor
}
}
var plot = letsPlot() plot += geomDendro(tree, connectionType = ConnectionType.rectangle, edgeMetaInheritance = EdgeMetaInheritance.up){ nodeColor = "age" edgeColor = "sex" } `
Hi, there can not be >1 legends for a single aesthetic (i.e. "color"). In the case of segments and points the workaround would be to use the "fill" aesthetic for the points layer. For that to work you will need to use a 'fillable' shape for points, like shape 19 or 21.
I tried that, but I get a weird result:
`operator fun Plot.plus(dendro: GeomDendroLayer) = run {
this +
geomSegment(dendro.edgesData) {
x = "x1"
y = "y1"
xend = "x2"
yend = "y2"
linetype = dendro.ops.edgeLinetype
color = dendro.ops.edgeColor
}+
geomPoint(
dendro.pointsData, shape = 19
) {
x = "x"
y = "y"
fill = dendro.ops.nodeColor
}
}`
Oh, sorry, shape 19 wont work, try shape 21.
Oh, sorry, shape 19 wont work, try shape 21.

Is there a way to use the same color for a counter or make it blank so its a solid circle?
Transparent color = "rgba(0, 0, 0, 0)" might work. May be size = 0 also but not sure. Upd: size - certainly not.