Skip to content

Add legend to plot with multiple lines #91

Answered by jgreenyer
jgreenyer asked this question in Q&A
Discussion options

You must be logged in to vote

Dear Igor,
thanks for the hints. It works!

Just for others who come here with a similar question, this is what I ended up doing:
(learnEpsilonGreedy returns a list of "mean reward" values)

val numberOfPlays = 1000
val stepsList = (1..numberOfPlays).toList()
val data = mapOf<String, Any>(
    "t (step)" to stepsList + stepsList,
    "mean reward" to learnEpsilonGreedy(epsilon = 0.05, numberOfPlays) + learnEpsilonGreedy(epsilon = 0.1, numberOfPlays),
    "epsilon" to  List(numberOfPlays) { "0.05" } + List(numberOfPlays) { "0.1" }
)

val p = letsPlot(data) +
        geomLine(size=1.0) {
            x = "t (step)"
            y = "mean reward"
            color = "epsilon"
        }

p.show()

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by alshan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #74 on September 28, 2021 19:44.