[Python] With openpyxl how can I hide certain titles from my legend?

Discussão em 'Python' iniciado por Stack, Agosto 15, 2025.

  1. Stack

    Stack Membro Participativo

    I want to create a graph with different series. But for example I have some series I want to show with a single label instead of each having their own label.

    [​IMG]

    for i in range(len(slope_values)):
    x_segmentation_series = Reference(ws, min_col=5, max_col=6, min_row=i+3)
    y_segmentation_series = Reference(ws, min_col=7, max_col=8, min_row=i+3)
    if i == 0:
    segmentation_series = Series(values=y_segmentation_series,
    xvalues=x_segmentation_series, title="Segmentos")
    else:
    segmentation_series = Series(values=y_segmentation_series,
    xvalues=x_segmentation_series)
    segmentation_series.graphicalProperties.line.solidFill = "000000"
    c1.series.append(segmentation_series)


    This is the code generating the black lines, but I want to hide all but one of the labels on the right. As I have other data I can't just erase the legend of my graph.

    Using Series(... title=None | False | "") or segmentation_series.title = None | '' | False did not work at all

    This is the code generating the black lines, but I want to hide all but one of the labels on the right. As I have other data I can't just erase the legend of my graph.

    Using Series(... title=None | False | "") or segmentation_series.title = None | '' | False did not work at all

    Continue reading...

Compartilhe esta Página