Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend override_aes #1115

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into legend-override-aes
  • Loading branch information
MKoroteev-HORIS committed Jun 13, 2024
commit 6eb9d12fb290aae696d40e4d95915c5ac506fffb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class LegendOptions constructor(
val colCount: Int? = null,
val rowCount: Int? = null,
val byRow: Boolean = false,
title: String? = null,
val overrideAesValues: Map<Aes<*>, Any>? = null,
isReverse: Boolean = false
) : GuideOptions(title, isReverse) {
Expand All @@ -29,7 +30,13 @@ class LegendOptions constructor(

override fun withReverse(reverse: Boolean): LegendOptions {
return LegendOptions(
colCount, rowCount, byRow, overrideAesValues, isReverse = reverse
colCount, rowCount, byRow, title, overrideAesValues, isReverse = reverse
)
}

override fun withTitle(title: String?): LegendOptions {
return LegendOptions(
colCount, rowCount, byRow, title = title, isReverse
)
}

Expand All @@ -42,6 +49,7 @@ class LegendOptions constructor(
if (colCount != other.colCount) return false
if (rowCount != other.rowCount) return false
if (byRow != other.byRow) return false
if (title != other.title) return false
if (overrideAesValues != other.overrideAesValues) return false

return true
Expand All @@ -51,6 +59,7 @@ class LegendOptions constructor(
var result = colCount ?: 0
result = 31 * result + (rowCount ?: 0)
result = 31 * result + byRow.hashCode()
result = 31 * result + (title?.hashCode() ?: 0)
result = 31 * result + (overrideAesValues?.hashCode() ?: 0)
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ import org.jetbrains.letsPlot.core.spec.Option.Guide.Legend.OVERRIDE_AES
import org.jetbrains.letsPlot.core.spec.Option.Guide.Legend.ROW_COUNT
import org.jetbrains.letsPlot.core.spec.Option.Guide.NONE
import org.jetbrains.letsPlot.core.spec.Option.Guide.REVERSE
import org.jetbrains.letsPlot.core.spec.Option.Guide.TITLE
import org.jetbrains.letsPlot.core.spec.conversion.AesOptionConversion
import kotlin.math.max

abstract class GuideConfig private constructor(opts: Map<String, Any>) : OptionsAccessor(opts) {

fun createGuideOptions(aopConversion: AesOptionConversion): GuideOptions {
val options = createGuideOptionsIntern(aopConversion)
return options.withReverse(getBoolean(REVERSE))
return options
.withTitle(getString(TITLE))
.withReverse(getBoolean(REVERSE))
}

protected abstract fun createGuideOptionsIntern(aopConversion: AesOptionConversion): GuideOptions
Expand Down
2 changes: 1 addition & 1 deletion python-package/lets_plot/plot/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__all__ = ['guide_legend', 'guide_colorbar', 'guides']


def guide_legend(nrow=None, ncol=None, byrow=None, override_aes=None):
def guide_legend(title=None, *, nrow=None, ncol=None, byrow=None, override_aes=None):
"""
Legend guide.

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.