mirror of
https://github.com/gwm17/implot.git
synced 2024-11-13 22:48:50 -05:00
shaded plots complete
This commit is contained in:
parent
fee873d74a
commit
808856dcc3
4
implot.h
4
implot.h
|
@ -48,8 +48,8 @@ enum ImPlotFlags_ {
|
|||
ImPlotFlags_CullData = 1 << 7, // plot data outside the plot area will be culled from rendering
|
||||
ImPlotFlags_AntiAliased = 1 << 8, // lines and fills will be anti-aliased (not recommended)
|
||||
ImPlotFlags_NoChild = 1 << 9, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 10, // enable a 2nd y axis
|
||||
ImPlotFlags_YAxis3 = 1 << 11, // enable a 3rd y axis
|
||||
ImPlotFlags_YAxis2 = 1 << 10, // enable a 2nd y-axis
|
||||
ImPlotFlags_YAxis3 = 1 << 11, // enable a 3rd y-axis
|
||||
ImPlotFlags_Default = ImPlotFlags_MousePos | ImPlotFlags_Legend | ImPlotFlags_Highlight | ImPlotFlags_BoxSelect | ImPlotFlags_ContextMenu | ImPlotFlags_CullData
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.3 WIP
|
||||
// ImPlot v0.4 WIP
|
||||
|
||||
#include "implot.h"
|
||||
#include <math.h>
|
||||
|
@ -198,32 +198,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Shaded Plots")) {
|
||||
static t_float xs[1001], ys[1001], ys1[1001], ys2[1001], ys3[1001], ys4[1001];
|
||||
srand(0);
|
||||
for (int i = 0; i < 1001; ++i) {
|
||||
xs[i] = i * 0.001f;
|
||||
ys[i] = 0.25f + 0.25f * Sin(25 * xs[i]) * Sin(5 * xs[i]) + RandomRange(-0.01f, 0.01f);
|
||||
ys1[i] = ys[i] + RandomRange(0.1f, 0.12f);
|
||||
ys2[i] = ys[i] - RandomRange(0.1f, 0.12f);
|
||||
ys3[i] = 0.75f + 0.2f * Sin(25 * xs[i]);
|
||||
ys4[i] = 0.75f + 0.1f * Cos(25 * xs[i]);
|
||||
}
|
||||
static float alpha = 0.25f;
|
||||
ImGui::DragFloat("Alpha",&alpha,0.01f,0,1);
|
||||
if (ImPlot::BeginPlot("Shaded Plots")) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, alpha);
|
||||
ImPlot::PlotShaded("Uncertain Data",xs,ys1,ys2,1001);
|
||||
ImPlot::PlotLine("Uncertain Data", xs, ys, 1001);
|
||||
ImPlot::PlotShaded("Overlapping",xs,ys3,ys4,1001);
|
||||
ImPlot::PlotLine("Overlapping",xs,ys3,1001);
|
||||
ImPlot::PlotLine("Overlapping",xs,ys4,1001);
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Filled Plots")) {
|
||||
if (ImGui::CollapsingHeader("Filled Line Plots")) {
|
||||
static t_float xs1[101], ys1[101], ys2[101], ys3[101];
|
||||
srand(0);
|
||||
for (int i = 0; i < 101; ++i) {
|
||||
|
@ -256,6 +231,31 @@ void ShowDemoWindow(bool* p_open) {
|
|||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Shaded Plots")) {
|
||||
static t_float xs[1001], ys[1001], ys1[1001], ys2[1001], ys3[1001], ys4[1001];
|
||||
srand(0);
|
||||
for (int i = 0; i < 1001; ++i) {
|
||||
xs[i] = i * 0.001f;
|
||||
ys[i] = 0.25f + 0.25f * Sin(25 * xs[i]) * Sin(5 * xs[i]) + RandomRange(-0.01f, 0.01f);
|
||||
ys1[i] = ys[i] + RandomRange(0.1f, 0.12f);
|
||||
ys2[i] = ys[i] - RandomRange(0.1f, 0.12f);
|
||||
ys3[i] = 0.75f + 0.2f * Sin(25 * xs[i]);
|
||||
ys4[i] = 0.75f + 0.1f * Cos(25 * xs[i]);
|
||||
}
|
||||
static float alpha = 0.25f;
|
||||
ImGui::DragFloat("Alpha",&alpha,0.01f,0,1);
|
||||
if (ImPlot::BeginPlot("Shaded Plots")) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, alpha);
|
||||
ImPlot::PlotShaded("Uncertain Data",xs,ys1,ys2,1001);
|
||||
ImPlot::PlotLine("Uncertain Data", xs, ys, 1001);
|
||||
ImPlot::PlotShaded("Overlapping",xs,ys3,ys4,1001);
|
||||
ImPlot::PlotLine("Overlapping",xs,ys3,1001);
|
||||
ImPlot::PlotLine("Overlapping",xs,ys4,1001);
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Scatter Plots")) {
|
||||
srand(0);
|
||||
static t_float xs1[100], ys1[100];
|
||||
|
@ -446,9 +446,9 @@ void ShowDemoWindow(bool* p_open) {
|
|||
static int rt_axis = ImPlotAxisFlags_Default & ~ImPlotAxisFlags_TickLabels;
|
||||
if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1,150), ImPlotFlags_Default, rt_axis, rt_axis | ImPlotAxisFlags_LockMin)) {
|
||||
ImPlot::PlotLine("Data 1", &sdata1.Data[0].x, &sdata1.Data[0].y, sdata1.Data.size(), sdata1.Offset, 2 * sizeof(t_float));
|
||||
ImPlot::PushStyleColor(ImPlotCol_Fill, ImVec4(1,0,0,0.25f));
|
||||
ImPlot::PlotLine("Data 2", &sdata2.Data[0].x, &sdata2.Data[0].y, sdata2.Data.size(), sdata2.Offset, 2 * sizeof(t_float));
|
||||
ImPlot::PopStyleColor();
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, 0.25f);
|
||||
ImPlot::PlotShaded("Data 2", &sdata2.Data[0].x, &sdata2.Data[0].y, sdata2.Data.size(), 0, sdata2.Offset, 2 * sizeof(t_float));
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
ImPlot::SetNextPlotLimitsX(0, history, ImGuiCond_Always);
|
||||
|
|
Loading…
Reference in New Issue
Block a user