QCustomPlot Discussion and Comments

Legend hide and show legend itemReturn to overview

Hello,
I use a qcustomplot to draw 4 lines in "realtime". I am also drawing a legend with all 4 lines. Is there a way to hide and show the legend items. In case only 2 of the 4 lines are needed (other 2 lines a set to invisibe, setVisible(false)), still all 4 items are visible in the legend. How to adjust the legend to the lines shown in the plot?

On the respective graph, call removeFromLegend() and addToLegend() depending on whether to show the graph in the legend or not. (Alternatively, you could also access the legend and remove/add items, but the previous technique is the easiest if you only have one legend.)

Hi,
I've only one plot, and when I use

removeFromLegend()
there is still an small rectangle ...

How to hide it ?
Thanks

Try

plot->legend->setVisible(false);

Of course you can then re-enable visibility if a plot is added again.

Many thanks !
It's so cool, keep qcustomplot alive !

Best regards

If I dynamically check that a series has any points and then hide or ad legend as the state changes, will it remove a legend from the middle of the list and show it back in that location or append it at the bottom?

Unfortunately, append it at the bottom.
Does anyone know how to insert it back to the origin location?