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

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.

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.

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 [email protected] 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 [email protected].
To post to this group, send email to [email protected].
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.

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 [email protected] 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 [email protected].
To post to this group, send email to [email protected].
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.