The problem occurs if legend = list(orientation = "h") (in R) or layout = {legend: {"orientation": "h"}}; (in JS) is set and the frame width is large enough to place all legend items on one line.
The logic to align the legend items in a grid (see also #786) is generally a good thing for responsiveness, but doesn't look good if the resulting grid consists of only one row as in the example below:

(note the spacing between SRG SSR, Schweizer Privatsender and Ausländische Sender; here is the same chart hosted on plot.ly)
Some more information I could find: