epezent / implot

Immediate Mode Plotting
MIT License
4.5k stars 495 forks source link

all plot be hidden default. #572

Open Sologala opened 1 month ago

Sologala commented 1 month ago

I will plot multi lines in one frame, but do not want show all of them in beginning. Is there some way to disable all lines in legend?

image

Sologala commented 1 month ago

I can directly modify plotitem's member variable to achive that, but it needs to include implot_internal.h. Is there some elegant way to do this?


      if (first_draw) {
                    first_draw = false;
                    ImPlotContext *ctx = ImPlot::GetCurrentContext();
                    ImPlotPlot *plot = ctx->CurrentPlot;
                    const int num_items = plot->Items.GetLegendCount();
                    for (int i = 0; i < num_items; ++i) {
                        ImPlotItem *item = plot->Items.GetLegendItem(i);
                        item->Show = false;
                    }
                }

``