lets-plot-kotlin icon indicating copy to clipboard operation
lets-plot-kotlin copied to clipboard

incorrect legend

Open mizraelson opened this issue 3 years ago • 5 comments

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.

image

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" } `

mizraelson avatar Dec 29 '21 17:12 mizraelson

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.

image

alshan avatar Dec 29 '21 19:12 alshan

I tried that, but I get a weird result: image

`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
}

}`

mizraelson avatar Dec 29 '21 19:12 mizraelson

Oh, sorry, shape 19 wont work, try shape 21.

alshan avatar Dec 29 '21 20:12 alshan

Oh, sorry, shape 19 wont work, try shape 21.

image

Is there a way to use the same color for a counter or make it blank so its a solid circle?

mizraelson avatar Dec 29 '21 20:12 mizraelson

Transparent color = "rgba(0, 0, 0, 0)" might work. May be size = 0 also but not sure. Upd: size - certainly not.

alshan avatar Dec 29 '21 20:12 alshan

UPD:

  • support for multiple color scales was aded in v 4.3.0 - see aesthetics paint_a, paint_b, paint_c.
  • the stroke aesthetic was added in v 4.4.0 and provide grater control over points border.

alshan avatar Mar 11 '24 17:03 alshan