☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

rbokeh: How do I layer ly_points while using the glyph, color, and legend arguments?

Community Support
jeremiah_rounds
jeremiah_rounds

This is basically what I want to do:

data(iris)

colors = c("red","blue","black")

glyphs = c(13,14,15)

data0 = split(iris,  list(Species=iris$Species))

legends = unlist(lapply(data0, function(s) unique(s$Species)))

p = figure()

for(i in seq_along(data0)){

	p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

}

p

#try again...

i = 1

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

p

But it doesn’t work. I don’t want to use the built in glyph and color by factor level because in actual fact I am layering Kaplan Meier survival plots and I need fine control over the color and glyphs, and I am happy to use ly_points in a loop to manage that, but I can’t figure out the correct call to do so.

⌁   Link to post
jeremiah_rounds
jeremiah_rounds

I decided there was an issue in certain arguments, so I put it in the github issue list.

···

On Thursday, October 8, 2015 at 11:18:24 AM UTC-7, jeremiah rounds wrote:

This is basically what I want to do:

data(iris)

colors = c(“red”,“blue”,“black”)

glyphs = c(13,14,15)

data0 = split(iris, list(Species=iris$Species))

legends = unlist(lapply(data0, function(s) unique(s$Species)))

p = figure()

for(i in seq_along(data0)){

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

}

p

#try again…

i = 1

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

p

But it doesn’t work. I don’t want to use the built in glyph and color by factor level because in actual fact I am layering Kaplan Meier survival plots and I need fine control over the color and glyphs, and I am happy to use ly_points in a loop to manage that, but I can’t figure out the correct call to do so.

⌁   Link to post
Ryan_Hafen
Ryan_Hafen

There are two things to get this to work. First, glyph “14” is not a valid glyph so it thinks it needs to map that to the theme. See point_types() to see possible values for glyph. Second, specifying the “data” argument makes rbokeh try to look for other things in the supplied data frame. We are actively working on making this more robust. But for now, here’s what you want to do to get things to work:

library(rbokeh)

data(iris)

colors ← c(“red”, “blue”, “black”)

glyphs ← c(13,15,16)

data0 ← split(iris, list(Species = iris$Species))

legends ← as.character(unlist(lapply(data0, function(s) unique(s$Species))))

p ← figure()

for(i in seq_along(data0)) {

p ← p %>% ly_points(data0[[i]]$Sepal.Length, data0[[i]]$Sepal.Width, color = colors[i], glyph = glyphs[i], legend = legends[i])

}

···

On Oct 8, 2015, at 11:54 AM, jeremiah rounds roundsjeremiah@gmail.com wrote:

I decided there was an issue in certain arguments, so I put it in the github issue list.
https://github.com/bokeh/rbokeh/issues/132

On Thursday, October 8, 2015 at 11:18:24 AM UTC-7, jeremiah rounds wrote:

This is basically what I want to do:

data(iris)

colors = c(“red”,“blue”,“black”)

glyphs = c(13,14,15)

data0 = split(iris, list(Species=iris$Species))

legends = unlist(lapply(data0, function(s) unique(s$Species)))

p = figure()

for(i in seq_along(data0)){

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

}

p

#try again…

i = 1

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

p

But it doesn’t work. I don’t want to use the built in glyph and color by factor level because in actual fact I am layering Kaplan Meier survival plots and I need fine control over the color and glyphs, and I am happy to use ly_points in a loop to manage that, but I can’t figure out the correct call to do so.

–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0ee71dc9-eca0-4c34-8211-34d433231491%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
jeremiah_rounds
jeremiah_rounds

oh. Didn’t think to skip the data argument. Thanks Ryan.

···

On Friday, October 9, 2015 at 8:31:18 AM UTC-7, Ryan Hafen wrote:

There are two things to get this to work. First, glyph “14” is not a valid glyph so it thinks it needs to map that to the theme. See point_types() to see possible values for glyph. Second, specifying the “data” argument makes rbokeh try to look for other things in the supplied data frame. We are actively working on making this more robust. But for now, here’s what you want to do to get things to work:

library(rbokeh)

data(iris)

colors ← c(“red”, “blue”, “black”)

glyphs ← c(13,15,16)

data0 ← split(iris, list(Species = iris$Species))

legends ← as.character(unlist(lapply(data0, function(s) unique(s$Species))))

p ← figure()

for(i in seq_along(data0)) {

p ← p %>% ly_points(data0[[i]]$Sepal.Length, data0[[i]]$Sepal.Width, color = colors[i], glyph = glyphs[i], legend = legends[i])

}

On Oct 8, 2015, at 11:54 AM, jeremiah rounds roundsj...@gmail.com wrote:

I decided there was an issue in certain arguments, so I put it in the github issue list.
https://github.com/bokeh/rbokeh/issues/132

On Thursday, October 8, 2015 at 11:18:24 AM UTC-7, jeremiah rounds wrote:

This is basically what I want to do:

data(iris)

colors = c(“red”,“blue”,“black”)

glyphs = c(13,14,15)

data0 = split(iris, list(Species=iris$Species))

legends = unlist(lapply(data0, function(s) unique(s$Species)))

p = figure()

for(i in seq_along(data0)){

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

}

p

#try again…

i = 1

p = p %>% ly_points(Sepal.Length, Sepal.Width, data= data0[[i]],color=colors[i], glyph=glyphs[i], legend=legends[i])

p

But it doesn’t work. I don’t want to use the built in glyph and color by factor level because in actual fact I am layering Kaplan Meier survival plots and I need fine control over the color and glyphs, and I am happy to use ly_points in a loop to manage that, but I can’t figure out the correct call to do so.

–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
To post to this group, send email to bo...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0ee71dc9-eca0-4c34-8211-34d433231491%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post

End of archived discussion · Replies are disabled