☰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

[R] How to keep legend a)outside the plot and b) horizontal

Community Support
sguha
sguha

Hello,

I’m using RBokeh, which is very nice. I would like to add a legend outside the plot (which can be done in bokeh)

Currently this is what I have

        a <- figure(width=400, height=300, logo=NULL,

                    tools=c("hover","box_zoom","reset"),

                    xlab = "Date",ylab=VLAB, legend_location="bottom_left")

        a <- ly_lines(a, x = date, y=V, data=d, color=Os, hover=list(date=date, value=V),line_width=1)

        if(!is.null(ylim)) a <- y_range(a,dat=ylim)

        a <- theme_legend(a,border_line_color='white')
  1. how can i place the legend outside?

  2. How can i make the legend background transparent (assuming (1) is not possible)

I’m using rbokeh version: 0.4.3

Thanks much in advance

Saptarshi

⌁   Link to post
Ryan_Hafen
Ryan_Hafen

In the development branch, you can now specify the background transparency of the legend (I believe this is new in Bokeh 0.12 and that’s why it isn’t available in the version you are using).

devtools::install_github(“bokeh/rbokeh@dev”)

figure() %>%

ly_points(Sepal.Length, Sepal.Width, data = iris,

color = Species, glyph = Species) %>%

theme_legend(background_fill_alpha = 0.5)

I’m hoping to have all these updates merged to master and released to CRAN by the end of the week.

I’m also looking into how to make the legend outside the plot.

Ryan

···

On Sep 6, 2016, at 11:27 AM, sguha@mozilla.com wrote:

Hello,

I’m using RBokeh, which is very nice. I would like to add a legend outside the plot (which can be done in bokeh)

Currently this is what I have

        a <- figure(width=400, height=300, logo=NULL,
                    tools=c("hover","box_zoom","reset"),
                    xlab = "Date",ylab=VLAB, legend_location="bottom_left")
        a <- ly_lines(a, x = date, y=V, data=d, color=Os, hover=list(date=date, value=V),line_width=1)
        if(!is.null(ylim)) a <- y_range(a,dat=ylim)
        a <- theme_legend(a,border_line_color='white')
  1. how can i place the legend outside?
  1. How can i make the legend background transparent (assuming (1) is not possible)

I’m using rbokeh version: 0.4.3

Thanks much in advance

Saptarshi

–

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/0f0d323a-759e-4430-92fc-66fbc50bc715%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