mirror of
https://github.com/gwm17/implot.git
synced 2024-11-13 22:48:50 -05:00
Added whiskers for H error bars, now showing desired feature
This commit is contained in:
parent
3f84f43919
commit
ef549d1ab5
|
@ -2967,6 +2967,8 @@ void PlotErrorBarsHEx(const char* label_id, Getter getter) {
|
|||
ImPlotPointErrorH e = getter(i);
|
||||
FitPoint(ImPlotPoint(e.x, e.y - e.neg_v));
|
||||
FitPoint(ImPlotPoint(e.x, e.y + e.pos_v));
|
||||
FitPoint(ImPlotPoint(e.x - e.neg_h, e.y));
|
||||
FitPoint(ImPlotPoint(e.x + e.pos_h, e.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2974,10 +2976,15 @@ void PlotErrorBarsHEx(const char* label_id, Getter getter) {
|
|||
ImPlotPointErrorH e = getter(i);
|
||||
ImVec2 p1 = PlotToPixels(e.x, e.y - e.neg_v);
|
||||
ImVec2 p2 = PlotToPixels(e.x, e.y + e.pos_v);
|
||||
ImVec2 p3 = PlotToPixels(e.x - e.neg_h, e.y);
|
||||
ImVec2 p4 = PlotToPixels(e.x + e.pos_h, e.y);
|
||||
DrawList.AddLine(p1, p2, col, gp.Style.ErrorBarWeight);
|
||||
DrawList.AddLine(p3, p4, col, gp.Style.ErrorBarWeight);
|
||||
if (rend_whisker) {
|
||||
DrawList.AddLine(p1 - ImVec2(half_whisker, 0), p1 + ImVec2(half_whisker, 0), col, gp.Style.ErrorBarWeight);
|
||||
DrawList.AddLine(p2 - ImVec2(half_whisker, 0), p2 + ImVec2(half_whisker, 0), col, gp.Style.ErrorBarWeight);
|
||||
DrawList.AddLine(p3 - ImVec2(0, half_whisker), p3 + ImVec2(0, half_whisker), col, gp.Style.ErrorBarWeight);
|
||||
DrawList.AddLine(p4 - ImVec2(0, half_whisker), p4 + ImVec2(0, half_whisker), col, gp.Style.ErrorBarWeight);
|
||||
}
|
||||
}
|
||||
PopPlotClipRect();
|
||||
|
|
|
@ -285,6 +285,7 @@ void ShowDemoWindow(bool* p_open) {
|
|||
t_float bar[5] = {1,2,5,3,4};
|
||||
t_float err1[5] = {0.2f, 0.4f, 0.2f, 0.6f, 0.4f};
|
||||
t_float err2[5] = {0.4f, 0.2f, 0.4f, 0.8f, 0.6f};
|
||||
t_float err3[5] = {0.02f, 0.04f, 0.05f, 0.03f, 0.06f};
|
||||
ImPlot::SetNextPlotLimits(0, 6, 0, 10);
|
||||
if (ImPlot::BeginPlot("##ErrorBars",NULL,NULL)) {
|
||||
ImPlot::PlotBars("Bar", xs, bar, 5, 0.5f);
|
||||
|
@ -299,8 +300,8 @@ void ShowDemoWindow(bool* p_open) {
|
|||
ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Square);
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_MarkerSize, 3);
|
||||
ImPlot::PushStyleColor(ImPlotCol_ErrorBar, ImVec4(0, 1, 0, 1));
|
||||
ImPlot::PlotErrorBarsH("Line##ErrorBarH", xs, lin2, err1, err2, 5);
|
||||
ImPlot::PlotLine("Line##ErrorBarH", xs, lin2, 5);
|
||||
ImPlot::PlotErrorBarsH("Line2##ErrorBarH", xs, lin2, err1, err3, 5);
|
||||
ImPlot::PlotLine("Line2##ErrorBarH", xs, lin2, 5);
|
||||
ImPlot::PopStyleVar(2);
|
||||
ImPlot::PopStyleColor();
|
||||
ImPlot::EndPlot();
|
||||
|
|
Loading…
Reference in New Issue
Block a user