epezent / epezent/implot

Subplots within table, overflowing boundary

Open
#518 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
6.2k
Forks
693
PR merge metrics
No merged PRs in 30d

Description

I am writing a control that will have a table of elements, each with a subplot. All X axes should be locked to each other when scrolling/zooming the axes.
I have tried adapting the tables/plots demo code to use subplots but am getting strange behaviour. I can't tell if this use case is supported or not, so maybe I'll just have to modify ImPlot.

I've played with forcing the sizes on items and using autosize (-1) and same results.

Here's what I'm doing:

```
if (ImGui::Begin("Playback"))
{
static double t_min = 1609459200; // 01/01/2021 @ 12:00:00am (UTC)
static double t_max = 1640995200; // 01/01/2022 @ 12:00:00am (UTC)

static int rows = 5;
static int cols = 1;

static ImGuiTableFlags flags = ImGuiTableFlags_BordersOuter;

if (ImPlot::BeginSubplots("##AxisLinking", rows, cols, ImVec2(-1, 700), ImPlotSubplotFlags_LinkCols)) {

if (ImGui::BeginTable("##table", 3, flags, ImVec2(-1, -1))) {
ImGui::TableSetupColumn("Electrode", ImGuiTableColumnFlags_WidthFixed, 75.0f);
ImGui::TableSetupColumn("Voltage", ImGuiTableColumnFlags_WidthFixed, 75.0f);
ImGui::TableSetupColumn("EMG Signal");
ImGui::TableHeadersRow();

for (int row = 0; row < rows; row++) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("EMG %d", row);
ImGui::TableSetColumnIndex(1);
ImGui::Text("%.3f V", 123.456);
ImGui::TableSetColumnIndex(2);

if (ImPlot::BeginPlot("", ImVec2(-1, 0))) {
//if (row != rows - 1) ImPlot::SetupAxis(ImAxis_X1, nullptr, ImPlotAxisFlags_NoLabel | ImPlotAxisFlags_NoTickLabels);
ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);
ImPlot::SetupAxesLimits(t_min, t_max, -1, 1);
ImPlot::SetupAxis(ImAxis_Y1, nullptr, ImPlotAxisFlags_Lock);

//plot data
//...

ImPlot::EndPlot();
}

}
ImGui::EndTable();
}
ImPlot::EndSubplots();
}

}
ImGui::End();
```

The comment for `if (row != rows - 1)` is to only show the axes marks on the very last plot, but the issue shows up either way, so I left it out.

Here's what it does:

![image](https://github.com/epezent/implot/assets/16282043/495b8401-5b9e-4917-a192-04a20d9e0b1a)

No matter what I do, it cuts off the very last axes labels upon calling of 'EndSubplots'. It seems the table recognizes the size of the plot but 'EndSubplots' doesn't.

Any suggestions?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the supplied ImGui/ImPlot example using BeginSubplots, BeginTable, and BeginPlot, then inspect how the table and EndSubplots calculate their available bounds. Compare the final plot's axis-label area with the enclosing table and subplot sizes. Done means the last axis labels remain visible when the table is nested inside the subplots.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.