Can we please get legend_orientation option?

Hi, I have the issue that my legend gets clipped if I place it at the bottom:

I don’t want to place it on the sides because it takes up too much space on mobile devices, making the app unusable.

In the docs, I found an option for legend_cols, but looking at the holoviews source code, I found out that the legend_orientation is forced to ‘horizontal’ when the legend position is above or below the chart:

def _process_legend(self, plot=None):
        plot = plot or self.handles['plot']
        if not plot.legend:
            return
        legend = plot.legend[0]
        cmappers = [cmapper for cmapper in self.handles.values()
                   if isinstance(cmapper, CategoricalColorMapper)]
        categorical = bool(cmappers)
        if ((not categorical and not self.overlaid and len(legend.items) == 1)
            or not self.show_legend):
            legend.items[:] = []
        else:
            plot.legend.orientation = 'horizontal' if self.legend_cols else 'vertical'
            pos = self.legend_position
            if pos in self.legend_specs:
                plot.legend[:] = []
                legend.location = self.legend_offset
                if pos in ['top', 'bottom']:
                    plot.legend.orientation = 'horizontal'
                plot.add_layout(legend, self.legend_specs[pos])
            else:
                legend.location = pos

            # Apply muting
            for leg in plot.legend:
                for item in leg.items:
                    for r in item.renderers:
                        r.muted = self.legend_muted

So, can we please get an option to set the legend_orientation when it’s above/below the chart?
I.e. configure the plot like shown below, but the legend_cols parameter actually taking effect and displacing the legend in 2 columns:

image

Also filed a feature request on GitHub.

1 Like