Skip to content

LegendRv

LegendRv used kivy recycle view widget to create interactive legend. At the moment this widget can only be used with 1 axis with lines. To be functional, this widget need a figure_wgt object and need to set all figure lines with set_data function. See example_legend for more detail.

For horizonal kivy legend, use LegendRvHorizontal.

Note

Matplotlib legend can also be converted into interactive legend. See MatplotlibInteractiveLegend function to archive this purpose. Also look example_legend_matplotlib in the examples folder.

legendrv example

touch behavior

  • single tap : hide or show selected line
  • double tap : show all lines if selected line is the only visible line, otherwise it isolate the selected line

Some useful kivy properties

  • text_color (color property) : text color (default black)
  • text_font (str) : text font (default Roboto)
  • text_font_size (numeric property) : font size (default dp(18.5))
  • box_height (numeric property) : box height of all legend element (default dp(48))

How to use in Kv language :

MatplotFigure:
    id:figure_wgt
LegendRv:
    figure_wgt:figure_wgt
    size_hint_x:0.3  
    text_color: 1,0,1,1
    text_font:'DejaVuSans'
    text_font_size:dp(24)
    box_height:dp(60)  

Examples using this widget

  • example_legend
  • example_legend_horizontal