| 1580 | //----------------------------------------------------------------------------- |
| 1581 | |
| 1582 | void Demo_MultipleAxes() { |
| 1583 | IMGUI_DEMO_MARKER("Axes/Multiple Axes"); |
| 1584 | static float xs[1001], xs2[1001], ys1[1001], ys2[1001], ys3[1001]; |
| 1585 | for (int i = 0; i < 1001; ++i) { |
| 1586 | xs[i] = (i*0.1f); |
| 1587 | xs2[i] = xs[i] + 10.0f; |
| 1588 | ys1[i] = sinf(xs[i]) * 3 + 1; |
| 1589 | ys2[i] = cosf(xs[i]) * 0.2f + 0.5f; |
| 1590 | ys3[i] = sinf(xs[i]+0.5f) * 100 + 200; |
| 1591 | } |
| 1592 | |
| 1593 | static bool x2_axis = true; |
| 1594 | static bool y2_axis = true; |
| 1595 | static bool y3_axis = true; |
| 1596 | |
| 1597 | ImGui::Checkbox("X-Axis 2", &x2_axis); |
| 1598 | ImGui::SameLine(); |
| 1599 | ImGui::Checkbox("Y-Axis 2", &y2_axis); |
| 1600 | ImGui::SameLine(); |
| 1601 | ImGui::Checkbox("Y-Axis 3", &y3_axis); |
| 1602 | |
| 1603 | ImGui::BulletText("You can drag axes to the opposite side of the plot."); |
| 1604 | ImGui::BulletText("Hover over legend items to see which axis they are plotted on."); |
| 1605 | |
| 1606 | if (ImPlot::BeginPlot("Multi-Axis Plot", ImVec2(-1,0))) { |
| 1607 | ImPlot::SetupAxes("X-Axis 1", "Y-Axis 1"); |
| 1608 | ImPlot::SetupAxesLimits(0, 100, 0, 10); |
| 1609 | if (x2_axis) { |
| 1610 | ImPlot::SetupAxis(ImAxis_X2, "X-Axis 2",ImPlotAxisFlags_AuxDefault); |
| 1611 | ImPlot::SetupAxisLimits(ImAxis_X2, 0, 100); |
| 1612 | } |
| 1613 | if (y2_axis) { |
| 1614 | ImPlot::SetupAxis(ImAxis_Y2, "Y-Axis 2",ImPlotAxisFlags_AuxDefault); |
| 1615 | ImPlot::SetupAxisLimits(ImAxis_Y2, 0, 1); |
| 1616 | } |
| 1617 | if (y3_axis) { |
| 1618 | ImPlot::SetupAxis(ImAxis_Y3, "Y-Axis 3",ImPlotAxisFlags_AuxDefault); |
| 1619 | ImPlot::SetupAxisLimits(ImAxis_Y3, 0, 300); |
| 1620 | } |
| 1621 | |
| 1622 | ImPlot::PlotLine("f(x) = x", xs, xs, 1001); |
| 1623 | if (x2_axis) { |
| 1624 | ImPlot::SetAxes(ImAxis_X2, ImAxis_Y1); |
| 1625 | ImPlot::PlotLine("f(x) = sin(x)*3+1", xs2, ys1, 1001); |
| 1626 | } |
| 1627 | if (y2_axis) { |
| 1628 | ImPlot::SetAxes(ImAxis_X1, ImAxis_Y2); |
| 1629 | ImPlot::PlotLine("f(x) = cos(x)*.2+.5", xs, ys2, 1001); |
| 1630 | } |
| 1631 | if (x2_axis && y3_axis) { |
| 1632 | ImPlot::SetAxes(ImAxis_X2, ImAxis_Y3); |
| 1633 | ImPlot::PlotLine("f(x) = sin(x+.5)*100+200 ", xs2, ys3, 1001); |
| 1634 | } |
| 1635 | ImPlot::EndPlot(); |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | //----------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected