epezent / epezent/implot

Auto resize with linked axis

Open
#204 4 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 can't seem to get linked axis working to automatically scale once I have received data.
I need to auto scale the X axis for 2 Plots that are linked, but Auto scale the Y values. When I load data, it doesn't automatically fit the plots. It places them about half way across the axis, but then when I double click it it scales it properly.

```
ImPlot::LinkNextPlotLimits(&Get_Instance().m_Line_X_Min, &Get_Instance().m_Line_X_Max, NULL, NULL);

if (Get_Instance().m_ResizeLinePlot) { Get_Instance().m_ResizeLinePlot = false; ImPlot::FitNextPlotAxes(); }

if (ImPlot::BeginPlot("Line Graph##Line", "Day", "AUD", ImVec2(-1, 0), ImPlotFlags_NoBoxSelect | ImPlotFlags_AntiAliased, ImPlotAxisFlags_Time, ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_RangeFit)) {

//Plot line graph here

ImPlot::EndPlot();
}



ImPlot::LinkNextPlotLimits(&Get_Instance().m_Line_X_Min, &Get_Instance().m_Line_X_Max, NULL, NULL);

if (ImPlot::BeginPlot("Bar Graph##Line", "Day", NULL, ImVec2(-1, 0), ImPlotFlags_NoLegend | ImPlotFlags_NoBoxSelect | ImPlotFlags_AntiAliased, ImPlotAxisFlags_Time, ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_RangeFit)) {

//Plot a bar graph here

ImPlot::EndPlot();
}
```

`Get_Instance()` just allows me to access member variables. `m_ResizeLinePlot` gets set to `true` when I load the data.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.