Search code examples
pythonbqplot

How to remove the frame around the legend with bqplot/pyplot


This is a very easy question for you to answer, I'm sure. I am using bqplot (with pyplot) and by default, the legend is framed. So my question is: how do I remove the frame? With matplotlib, I know that I can simply use plt.legend(frameon=False), do you know a direct equivalent for bqplot?

The piece of code looks like this:

import bqplot.pyplot as pl

plot_test = pl.figure()
test = pl.plot(x,y, colors = ["white"],labels=['blabla'])
pl.legend()
pl.show()

Thank you in advance!


Solution

  • The easiest way to remove the border is to change the legend border width to 0.

    plot_test.legend_style = {'stroke-width': 0}
    

    enter image description here

    Bqplot legend styling uses SVG CSS styling properties. Other legend styling examples include.....

    plot_test.legend_style = {
        'fill': 'white'  ,
        'stroke' : 'blue' ,
        'stroke-width':3,
        'opacity':0.7   
                      }