Legend item size does not scale with legend font size

Hi there,

My use-case is that I’m exporting a plotly plot to an image. I’m exporting it to a large image (wXh = 4250x1930) and thus I’m increasing the font size for most of the plot components, including the legend.

The issue I’m running in to is that the legend item size does not change as the legend font increases.

Is there a way to produce a “large” plotly plot where the legend items maintain the same size ratio to their labels?

Hi @Patrick1 To get an image with readable legend, don’t set font for legend. Just increase the font for fig:

import plotly.graph_objs as go
from plotly.subplots import make_subplots
import numpy as np

r, c = 15, 7
fig = make_subplots(rows=r, cols=c)
for k in range(105):
    j = k%c
    i =(k-j)//c
                             showlegend=True), row=i+1, col=j+1)
fig.update_layout(width =4250, height=1930, font_size=20);  #tune the font_size to your needs                

import plotly.io as pio
pio.write_image(fig, 'large.png')

Hi @empet – this works, thank you! Apologies for the delay.

For those who have the weird use-case of both wanting to view a smaller image (ie in a notebook) then print a larger legend, ALSO with a different font size, you can save the image using the scale param:

fig.write_image(PLOT_DIR + filename, format='png', scale=5.0)