forked from epezent/implot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplot.cpp
More file actions
3684 lines (3239 loc) · 155 KB
/
implot.cpp
File metadata and controls
3684 lines (3239 loc) · 155 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// MIT License
// Copyright (c) 2020 Evan Pezent
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// ImPlot v0.5 WIP
/*
API BREAKING CHANGES
====================
Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix.
Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code.
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all implot files.
You can read releases logs https://github.com/epezent/implot/releases for more details.
- 2020/06/13 (0.4) - The flags `ImPlotAxisFlag_Adaptive` and `ImPlotFlags_Cull` were removed. Both are now done internally by default.
- 2020/06/03 (0.3) - The signature and behavior of PlotPieChart was changed so that data with sum less than 1 can optionally be normalized. The label format can now be specified as well.
- 2020/06/01 (0.3) - SetPalette was changed to `SetColormap` for consistency with other plotting libraries. `RestorePalette` was removed. Use `SetColormap(ImPlotColormap_Default)`.
- 2020/05/31 (0.3) - Plot functions taking custom ImVec2* getters were removed. Use the ImPlotPoint* getter versions instead.
- 2020/05/29 (0.3) - The signature of ImPlotLimits::Contains was changed to take two doubles instead of ImVec2
- 2020/05/16 (0.2) - All plotting functions were reverted to being prefixed with "Plot" to maintain a consistent VerbNoun style. `Plot` was split into `PlotLine`
and `PlotScatter` (however, `PlotLine` can still be used to plot scatter points as `Plot` did before.). `Bar` is not `PlotBars`, to indicate
that multiple bars will be plotted.
- 2020/05/13 (0.2) - `ImMarker` was change to `ImPlotMarker` and `ImAxisFlags` was changed to `ImPlotAxisFlags`.
- 2020/05/11 (0.2) - `ImPlotFlags_Selection` was changed to `ImPlotFlags_BoxSelect`
- 2020/05/11 (0.2) - The namespace ImGui:: was replaced with ImPlot::. As a result, the following additional changes were made:
- Functions that were prefixed or decorated with the word "Plot" have been truncated. E.g., `ImGui::PlotBars` is now just `ImPlot::Bar`.
It should be fairly obvious what was what.
- Some functions have been given names that would have otherwise collided with the ImGui namespace. This has been done to maintain a consistent
style with ImGui. E.g., 'ImGui::PushPlotStyleVar` is now 'ImPlot::PushStyleVar'.
- 2020/05/10 (0.2) - The following function/struct names were changes:
- ImPlotRange -> ImPlotLimits
- GetPlotRange() -> GetPlotLimits()
- SetNextPlotRange -> SetNextPlotLimits
- SetNextPlotRangeX -> SetNextPlotLimitsX
- SetNextPlotRangeY -> SetNextPlotLimitsY
- 2020/05/10 (0.2) - Plot queries are pixel based by default. Query rects that maintain relative plot position have been removed. This was done to support multi-y-axis.
*/
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
#include "implot.h"
#include "imgui_internal.h"
#ifdef _MSC_VER
#define sprintf sprintf_s
#endif
#define IM_NORMALIZE2F_OVER_ZERO(VX, VY) \
{ \
float d2 = VX * VX + VY * VY; \
if (d2 > 0.0f) { \
float inv_len = 1.0f / ImSqrt(d2); \
VX *= inv_len; \
VY *= inv_len; \
} \
}
// The maximum number of support y-axes
#define MAX_Y_AXES 3
// static inline float ImLog10(float x) { return log10f(x); }
static inline double ImLog10(double x) { return log10(x); }
ImPlotStyle::ImPlotStyle() {
LineWeight = 1;
Marker = ImPlotMarker_None;
MarkerSize = 4;
MarkerWeight = 1;
FillAlpha = 1;
ErrorBarSize = 5;
ErrorBarWeight = 1.5;
DigitalBitHeight = 8;
DigitalBitGap = 4;
Colors[ImPlotCol_Line] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_Fill] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_MarkerOutline] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_MarkerFill] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_ErrorBar] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_FrameBg] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_PlotBg] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_PlotBorder] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_XAxis] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_YAxis] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_YAxis2] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_YAxis3] = IMPLOT_COL_AUTO;
Colors[ImPlotCol_Selection] = ImVec4(1,1,0,1);
Colors[ImPlotCol_Query] = ImVec4(0,1,0,1);
}
ImPlotRange::ImPlotRange() {
Min = NAN;
Max = NAN;
}
bool ImPlotRange::Contains(double v) const {
return v >= Min && v <= Max;
}
double ImPlotRange::Size() const {
return Max - Min;
}
ImPlotLimits::ImPlotLimits() {}
bool ImPlotLimits::Contains(const ImPlotPoint& p) const {
return Contains(p.x, p.y);
}
bool ImPlotLimits::Contains(double x, double y) const {
return X.Contains(x) && Y.Contains(y);
}
ImPlotInputMap::ImPlotInputMap() {
PanButton = ImGuiMouseButton_Left;
PanMod = ImGuiKeyModFlags_None;
FitButton = ImGuiMouseButton_Left;
ContextMenuButton = ImGuiMouseButton_Right;
BoxSelectButton = ImGuiMouseButton_Right;
BoxSelectMod = ImGuiKeyModFlags_None;
BoxSelectCancelButton = ImGuiMouseButton_Left;
QueryButton = ImGuiMouseButton_Middle;
QueryMod = ImGuiKeyModFlags_None;
QueryToggleMod = ImGuiKeyModFlags_Ctrl;
HorizontalMod = ImGuiKeyModFlags_Alt;
VerticalMod = ImGuiKeyModFlags_Shift;
}
namespace ImPlot {
namespace {
//-----------------------------------------------------------------------------
// Private Utils
//-----------------------------------------------------------------------------
template <int Count>
struct OffsetCalculator {
OffsetCalculator(int* sizes) {
Offsets[0] = 0;
for (int i = 1; i < Count; ++i)
Offsets[i] = Offsets[i-1] + sizes[i-1];
}
int Offsets[Count];
};
template <typename T>
void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
buffer.resize(n);
T step = (vmax - vmin) / (n - 1);
for (int i = 0; i < n; ++i) {
buffer[i] = vmin + i * step;
}
}
// Returns true if a flag is set
template <typename TSet, typename TFlag>
inline bool HasFlag(TSet set, TFlag flag) {
return (set & flag) == flag;
}
// Flips a flag in a flagset
template <typename TSet, typename TFlag>
inline void FlipFlag(TSet& set, TFlag flag) {
HasFlag(set, flag) ? set &= ~flag : set |= flag;
}
// Linearly remaps x from [x0 x1] to [y0 y1].
template <typename T>
inline T Remap(T x, T x0, T x1, T y0, T y1) {
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
// Returns always positive modulo (r != 0)
inline int PosMod(int l, int r) {
return (l % r + r) % r;
}
// Returns the intersection point of two lines A and B (assumes they are not parallel!)
inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1, const ImVec2& b2) {
float v1 = (a1.x * a2.y - a1.y * a2.x);
float v2 = (b1.x * b2.y - b1.y * b2.x);
float v3 = ((a1.x - a2.x) * (b1.y - b2.y) - (a1.y - a2.y) * (b1.x - b2.x));
return ImVec2((v1 * (b1.x - b2.x) - v2 * (a1.x - a2.x)) / v3,
(v1 * (b1.y - b2.y) - v2 * (a1.y - a2.y)) / v3);
}
// Turns NANs to 0s
inline double ConstrainNan(double val) {
return isnan(val) ? 0 : val;
}
// Turns infinity to floating point maximums
inline double ConstrainInf(double val) {
return val == HUGE_VAL ? DBL_MAX : val == -HUGE_VAL ? - DBL_MAX : val;
}
// Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?)
inline double ConstrainLog(double val) {
return val <= 0 ? 0.001f : val;
}
// Returns true if val is NAN or INFINITY
inline bool NanOrInf(double val) {
return val == HUGE_VAL || val == -HUGE_VAL || isnan(val);
}
// Computes order of magnitude of double.
inline int OrderOfMagnitude(double val) {
return val == 0 ? 0 : (int)(floor(log10(fabs(val))));
}
// Returns the precision required for a order of magnitude.
inline int OrderToPrecision(int order) {
return order > 0 ? 0 : 1 - order;
}
// Returns a floating point precision to use given a value
inline int Precision(double val) {
return OrderToPrecision(OrderOfMagnitude(val));
}
// Draws vertical text. The position is the bottom left of the text rect.
inline void AddTextVertical(ImDrawList *DrawList, const char *text, ImVec2 pos, ImU32 text_color) {
pos.x = IM_ROUND(pos.x);
pos.y = IM_ROUND(pos.y);
ImFont * font = GImGui->Font;
const ImFontGlyph *glyph;
for (char c = *text++; c; c = *text++) {
glyph = font->FindGlyph(c);
if (!glyph)
continue;
DrawList->PrimReserve(6, 4);
DrawList->PrimQuadUV(
pos + ImVec2(glyph->Y0, -glyph->X0), pos + ImVec2(glyph->Y0, -glyph->X1),
pos + ImVec2(glyph->Y1, -glyph->X1), pos + ImVec2(glyph->Y1, -glyph->X0),
ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V0),
ImVec2(glyph->U1, glyph->V1), ImVec2(glyph->U0, glyph->V1), text_color);
pos.y -= glyph->AdvanceX;
}
}
// Calculates the size of vertical text
inline ImVec2 CalcTextSizeVertical(const char *text) {
ImVec2 sz = ImGui::CalcTextSize(text);
return ImVec2(sz.y, sz.x);
}
/// Returns white or black text given background color
inline ImU32 CalcTextColor(const ImVec4& bg) {
return (bg.x * 0.299 + bg.y * 0.587 + bg.z * 0.114) > 0.729 ? IM_COL32_BLACK : IM_COL32_WHITE;
}
} // private namespace
//-----------------------------------------------------------------------------
// Forwards
//-----------------------------------------------------------------------------
ImVec4 NextColor();
//-----------------------------------------------------------------------------
// Structs
//-----------------------------------------------------------------------------
// Tick mark info
struct ImPlotTick {
ImPlotTick(double value, bool major, bool render_label = true) {
PlotPos = value;
Major = major;
RenderLabel = render_label;
Labeled = false;
}
double PlotPos;
float PixelPos;
ImVec2 Size;
int TextOffset;
bool Major;
bool RenderLabel;
bool Labeled;
};
// Axis state information that must persist after EndPlot
struct ImPlotAxis {
ImPlotAxis() {
Dragging = false;
Hovered = false;
Range.Min = 0;
Range.Max = 1;
Flags = PreviousFlags = ImPlotAxisFlags_Default;
}
bool Dragging;
bool Hovered;
ImPlotRange Range;
ImPlotAxisFlags Flags, PreviousFlags;
};
// Axis state information only needed between BeginPlot/EndPlot
struct ImPlotAxisState {
ImPlotAxis* Axis;
bool HasRange;
ImGuiCond RangeCond;
bool Present;
int PresentSoFar;
bool Invert;
bool LockMin;
bool LockMax;
bool Lock;
ImPlotAxisState(ImPlotAxis& axis, bool has_range, ImGuiCond range_cond, bool present, int previous_present) :
Axis(&axis),
HasRange(has_range),
RangeCond(range_cond),
Present(present),
PresentSoFar(previous_present + (Present ? 1 : 0)),
Invert(HasFlag(Axis->Flags, ImPlotAxisFlags_Invert)),
LockMin(HasFlag(Axis->Flags, ImPlotAxisFlags_LockMin) || (HasRange && RangeCond == ImGuiCond_Always)),
LockMax(HasFlag(Axis->Flags, ImPlotAxisFlags_LockMax) || (HasRange && RangeCond == ImGuiCond_Always)),
Lock(!Present || ((LockMin && LockMax) || (HasRange && RangeCond == ImGuiCond_Always)))
{}
ImPlotAxisState() :
Axis(), HasRange(), RangeCond(), Present(), PresentSoFar(),Invert(),LockMin(), LockMax(), Lock()
{}
};
struct ImPlotAxisColor {
ImPlotAxisColor() : Major(), Minor(), Txt() {}
ImU32 Major, Minor, Txt;
};
// State information for Plot items
struct ImPlotItem {
ImPlotItem() {
Show = true;
SeenThisFrame = false;
Highlight = false;
Color = NextColor();
NameOffset = -1;
ID = 0;
}
~ImPlotItem() { ID = 0; }
bool Show;
bool SeenThisFrame;
bool Highlight;
ImVec4 Color;
int NameOffset;
ImGuiID ID;
};
// Holds Plot state information that must persist after EndPlot
struct ImPlotState {
ImPlotState() {
Selecting = Querying = Queried = DraggingQuery = false;
SelectStart = QueryStart = ImVec2(0,0);
Flags = PreviousFlags = ImPlotFlags_Default;
ColorIdx = 0;
CurrentYAxis = 0;
}
ImPool<ImPlotItem> Items;
ImRect BB_Legend;
ImVec2 SelectStart;
bool Selecting;
bool Querying;
bool Queried;
bool DraggingQuery;
ImVec2 QueryStart;
ImRect QueryRect; // relative to BB_Plot!!
ImPlotAxis XAxis;
ImPlotAxis YAxis[MAX_Y_AXES];
ImPlotFlags Flags, PreviousFlags;
int ColorIdx;
int CurrentYAxis;
};
struct ImPlotNextPlotData {
ImPlotNextPlotData() {
HasXRange = false;
ShowDefaultTicksX = true;
for (int i = 0; i < MAX_Y_AXES; ++i) {
HasYRange[i] = false;
ShowDefaultTicksY[i] = true;
}
}
ImGuiCond XRangeCond;
ImGuiCond YRangeCond[MAX_Y_AXES];
bool HasXRange;
bool HasYRange[MAX_Y_AXES];
ImPlotRange X;
ImPlotRange Y[MAX_Y_AXES];
bool ShowDefaultTicksX;
bool ShowDefaultTicksY[MAX_Y_AXES];
};
// Holds Plot state information that must persist only between calls to BeginPlot()/EndPlot()
struct ImPlotContext {
ImPlotContext() : RenderX(), RenderY() {
ChildWindowMade = false;
Reset();
SetColormap(ImPlotColormap_Default);
}
void Reset() {
// end child window if it was made
if (ChildWindowMade)
ImGui::EndChild();
ChildWindowMade = false;
// reset the next plot data
NextPlotData = ImPlotNextPlotData();
// reset items count
VisibleItemCount = 0;
// reset legend items
LegendIndices.shrink(0);
LegendLabels.Buf.shrink(0);
// reset ticks/labels
XTicks.shrink(0);
XTickLabels.Buf.shrink(0);
for (int i = 0; i < 3; ++i) {
YTicks[i].shrink(0);
YTickLabels[i].Buf.shrink(0);
}
// reset extents
FitX = false;
ExtentsX.Min = HUGE_VAL;
ExtentsX.Max = -HUGE_VAL;
for (int i = 0; i < MAX_Y_AXES; i++) {
ExtentsY[i].Min = HUGE_VAL;
ExtentsY[i].Max = -HUGE_VAL;
FitY[i] = false;
}
// reset digital plot items count
DigitalPlotItemCnt = 0;
DigitalPlotOffset = 0;
// nullify plot
CurrentPlot = NULL;
}
// ALl Plots
ImPool<ImPlotState> Plots;
// Current Plot
ImPlotState* CurrentPlot;
// Legend
ImVector<int> LegendIndices;
ImGuiTextBuffer LegendLabels;
// Bounding regions
ImRect BB_Frame;
ImRect BB_Canvas;
ImRect BB_Plot;
// Cached Colors
ImU32 Col_Frame, Col_Bg, Col_Border,
Col_Txt, Col_TxtDis,
Col_SlctBg, Col_SlctBd,
Col_QryBg, Col_QryBd;
ImPlotAxisColor Col_X;
ImPlotAxisColor Col_Y[MAX_Y_AXES];
ImPlotAxisState X;
ImPlotAxisState Y[MAX_Y_AXES];
// Tick marks
ImVector<ImPlotTick> XTicks, YTicks[MAX_Y_AXES];
ImGuiTextBuffer XTickLabels, YTickLabels[MAX_Y_AXES];
float AxisLabelReference[MAX_Y_AXES];
// Transformation cache
ImRect PixelRange[MAX_Y_AXES];
// linear scale (slope)
double Mx;
double My[MAX_Y_AXES];
// log scale denominator
double LogDenX;
double LogDenY[MAX_Y_AXES];
// Data extents
ImPlotRange ExtentsX;
ImPlotRange ExtentsY[MAX_Y_AXES];
int VisibleItemCount;
bool FitThisFrame; bool FitX;
bool FitY[MAX_Y_AXES];
// Hover states
bool Hov_Frame;
bool Hov_Plot;
// Render flags
bool RenderX, RenderY[MAX_Y_AXES];
// Lock info
bool LockPlot;
bool ChildWindowMade;
// Mouse pos
ImPlotPoint LastMousePos[MAX_Y_AXES];
// Style
ImVec4* Colormap;
int ColormapSize;
ImPlotStyle Style;
ImPlotInputMap InputMap;
ImVector<ImGuiColorMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
ImPlotNextPlotData NextPlotData;
// Digital plot item count
int DigitalPlotItemCnt;
int DigitalPlotOffset;
};
// Global plot context
static ImPlotContext gp;
//-----------------------------------------------------------------------------
// Context Utils
//-----------------------------------------------------------------------------
ImPlotInputMap& GetInputMap() {
return gp.InputMap;
}
// Returns the next unused default plot color
ImVec4 NextColor() {
ImVec4 col = gp.Colormap[gp.CurrentPlot->ColorIdx % gp.ColormapSize];
gp.CurrentPlot->ColorIdx++;
return col;
}
inline void FitPoint(const ImPlotPoint& p) {
ImPlotRange* extents_x = &gp.ExtentsX;
ImPlotRange* extents_y = &gp.ExtentsY[gp.CurrentPlot->CurrentYAxis];
if (!NanOrInf(p.x)) {
extents_x->Min = p.x < extents_x->Min ? p.x : extents_x->Min;
extents_x->Max = p.x > extents_x->Max ? p.x : extents_x->Max;
}
if (!NanOrInf(p.y)) {
extents_y->Min = p.y < extents_y->Min ? p.y : extents_y->Min;
extents_y->Max = p.y > extents_y->Max ? p.y : extents_y->Max;
}
}
//-----------------------------------------------------------------------------
// Coordinate Transforms
//-----------------------------------------------------------------------------
inline void UpdateTransformCache() {
// get pixels for transforms
for (int i = 0; i < MAX_Y_AXES; i++) {
gp.PixelRange[i] = ImRect(HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_Invert) ? gp.BB_Plot.Max.x : gp.BB_Plot.Min.x,
HasFlag(gp.CurrentPlot->YAxis[i].Flags, ImPlotAxisFlags_Invert) ? gp.BB_Plot.Min.y : gp.BB_Plot.Max.y,
HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_Invert) ? gp.BB_Plot.Min.x : gp.BB_Plot.Max.x,
HasFlag(gp.CurrentPlot->YAxis[i].Flags, ImPlotAxisFlags_Invert) ? gp.BB_Plot.Max.y : gp.BB_Plot.Min.y);
gp.My[i] = (gp.PixelRange[i].Max.y - gp.PixelRange[i].Min.y) / gp.CurrentPlot->YAxis[i].Range.Size();
}
gp.LogDenX = ImLog10(gp.CurrentPlot->XAxis.Range.Max / gp.CurrentPlot->XAxis.Range.Min);
for (int i = 0; i < MAX_Y_AXES; i++) {
gp.LogDenY[i] = ImLog10(gp.CurrentPlot->YAxis[i].Range.Max / gp.CurrentPlot->YAxis[i].Range.Min);
}
gp.Mx = (gp.PixelRange[0].Max.x - gp.PixelRange[0].Min.x) / gp.CurrentPlot->XAxis.Range.Size();
}
inline ImPlotPoint PixelsToPlot(float x, float y, int y_axis_in = -1) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PixelsToPlot() needs to be called between BeginPlot() and EndPlot()!");
const int y_axis = y_axis_in >= 0 ? y_axis_in : gp.CurrentPlot->CurrentYAxis;
ImPlotPoint plt;
plt.x = (x - gp.PixelRange[y_axis].Min.x) / gp.Mx + gp.CurrentPlot->XAxis.Range.Min;
plt.y = (y - gp.PixelRange[y_axis].Min.y) / gp.My[y_axis] + gp.CurrentPlot->YAxis[y_axis].Range.Min;
if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_LogScale)) {
double t = (plt.x - gp.CurrentPlot->XAxis.Range.Min) / gp.CurrentPlot->XAxis.Range.Size();
plt.x = ImPow(10, t * gp.LogDenX) * gp.CurrentPlot->XAxis.Range.Min;
}
if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) {
double t = (plt.y - gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.CurrentPlot->YAxis[y_axis].Range.Size();
plt.y = ImPow(10, t * gp.LogDenY[y_axis]) * gp.CurrentPlot->YAxis[y_axis].Range.Min;
}
return plt;
}
ImPlotPoint PixelsToPlot(const ImVec2& pix, int y_axis) {
return PixelsToPlot(pix.x, pix.y, y_axis);
}
// This function is convenient but should not be used to process a high volume of points. Use the Transformer structs below instead.
inline ImVec2 PlotToPixels(double x, double y, int y_axis_in = -1) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotToPixels() needs to be called between BeginPlot() and EndPlot()!");
const int y_axis = y_axis_in >= 0 ? y_axis_in : gp.CurrentPlot->CurrentYAxis;
ImVec2 pix;
if (HasFlag(gp.CurrentPlot->XAxis.Flags, ImPlotAxisFlags_LogScale)) {
double t = ImLog10(x / gp.CurrentPlot->XAxis.Range.Min) / gp.LogDenX;
x = ImLerp(gp.CurrentPlot->XAxis.Range.Min, gp.CurrentPlot->XAxis.Range.Max, (float)t);
}
if (HasFlag(gp.CurrentPlot->YAxis[y_axis].Flags, ImPlotAxisFlags_LogScale)) {
double t = ImLog10(y / gp.CurrentPlot->YAxis[y_axis].Range.Min) / gp.LogDenY[y_axis];
y = ImLerp(gp.CurrentPlot->YAxis[y_axis].Range.Min, gp.CurrentPlot->YAxis[y_axis].Range.Max, (float)t);
}
pix.x = (float)(gp.PixelRange[y_axis].Min.x + gp.Mx * (x - gp.CurrentPlot->XAxis.Range.Min));
pix.y = (float)(gp.PixelRange[y_axis].Min.y + gp.My[y_axis] * (y - gp.CurrentPlot->YAxis[y_axis].Range.Min));
return pix;
}
// This function is convenient but should not be used to process a high volume of points. Use the Transformer structs below instead.
ImVec2 PlotToPixels(const ImPlotPoint& plt, int y_axis) {
return PlotToPixels(plt.x, plt.y, y_axis);
}
//-----------------------------------------------------------------------------
// Legend Utils
//-----------------------------------------------------------------------------
ImPlotItem* RegisterItem(const char* label_id) {
ImGuiID id = ImGui::GetID(label_id);
ImPlotItem* item = gp.CurrentPlot->Items.GetOrAddByKey(id);
if (item->SeenThisFrame)
return item;
item->SeenThisFrame = true;
int idx = gp.CurrentPlot->Items.GetIndex(item);
item->ID = id;
if (ImGui::FindRenderedTextEnd(label_id, NULL) != label_id) {
gp.LegendIndices.push_back(idx);
item->NameOffset = gp.LegendLabels.size();
gp.LegendLabels.append(label_id, label_id + strlen(label_id) + 1);
}
else {
item->Show = true;
}
if (item->Show)
gp.VisibleItemCount++;
return item;
}
int GetLegendCount() {
return gp.LegendIndices.size();
}
ImPlotItem* GetLegendItem(int i) {
return gp.CurrentPlot->Items.GetByIndex(gp.LegendIndices[i]);
}
ImPlotItem* GetLegendItem(const char* label_id) {
ImGuiID id = ImGui::GetID(label_id);
return gp.CurrentPlot->Items.GetByKey(id);
}
const char* GetLegendLabel(int i) {
ImPlotItem* item = gp.CurrentPlot->Items.GetByIndex(gp.LegendIndices[i]);
IM_ASSERT(item->NameOffset != -1 && item->NameOffset < gp.LegendLabels.Buf.Size);
return gp.LegendLabels.Buf.Data + item->NameOffset;
}
//-----------------------------------------------------------------------------
// Tick Utils
//-----------------------------------------------------------------------------
// Utility function to that rounds x to powers of 2,5 and 10 for generating axis labels
// Taken from Graphics Gems 1 Chapter 11.2, "Nice Numbers for Graph Labels"
inline double NiceNum(double x, bool round) {
double f; /* fractional part of x */
double nf; /* nice, rounded fraction */
int expv = (int)floor(ImLog10(x));
f = x / ImPow(10.0, (double)expv); /* between 1 and 10 */
if (round)
if (f < 1.5)
nf = 1;
else if (f < 3)
nf = 2;
else if (f < 7)
nf = 5;
else
nf = 10;
else if (f <= 1)
nf = 1;
else if (f <= 2)
nf = 2;
else if (f <= 5)
nf = 5;
else
nf = 10;
return nf * ImPow(10.0, expv);
}
inline void AddDefaultTicks(const ImPlotRange& range, int nMajor, int nMinor, bool logscale, ImVector<ImPlotTick> &out) {
if (logscale) {
if (range.Min <= 0 || range.Max <= 0)
return;
int exp_min = (int)ImLog10(range.Min);
int exp_max = (int)(ceil(ImLog10(range.Max)));
for (int e = exp_min - 1; e < exp_max + 1; ++e) {
double major1 = ImPow(10, (double)(e));
double major2 = ImPow(10, (double)(e + 1));
double interval = (major2 - major1) / 9;
if (major1 >= (range.Min - DBL_EPSILON) && major1 <= (range.Max + DBL_EPSILON))
out.push_back(ImPlotTick(major1, true));
for (int i = 1; i < 9; ++i) {
double minor = major1 + i * interval;
if (minor >= (range.Min - DBL_EPSILON) && minor <= (range.Max + DBL_EPSILON))
out.push_back(ImPlotTick(minor, false, false));
}
}
}
else {
const double nice_range = NiceNum(range.Size() * 0.99, 0);
const double interval = NiceNum(nice_range / (nMajor - 1), 1);
const double graphmin = floor(range.Min / interval) * interval;
const double graphmax = ceil(range.Max / interval) * interval;
for (double major = graphmin; major < graphmax + 0.5 * interval; major += interval) {
if (major >= range.Min && major <= range.Max)
out.push_back(ImPlotTick(major, true));
for (int i = 1; i < nMinor; ++i) {
double minor = major + i * interval / nMinor;
if (minor >= range.Min && minor <= range.Max)
out.push_back(ImPlotTick(minor, false));
}
}
}
}
inline void AddCustomTicks(const double* values, const char** labels, int n, ImVector<ImPlotTick>& ticks, ImGuiTextBuffer& buffer) {
for (int i = 0; i < n; ++i) {
ImPlotTick tick(values[i],false);
tick.TextOffset = buffer.size();
if (labels != NULL) {
buffer.append(labels[i], labels[i] + strlen(labels[i]) + 1);
tick.Size = ImGui::CalcTextSize(labels[i]);
tick.Labeled = true;
}
ticks.push_back(tick);
}
}
inline void LabelTicks(ImVector<ImPlotTick> &ticks, bool scientific, ImGuiTextBuffer& buffer) {
char temp[32];
for (int t = 0; t < ticks.Size; t++) {
ImPlotTick *tk = &ticks[t];
if (tk->RenderLabel && !tk->Labeled) {
tk->TextOffset = buffer.size();
if (scientific)
sprintf(temp, "%.0e", tk->PlotPos);
else
sprintf(temp, "%.10g", tk->PlotPos);
buffer.append(temp, temp + strlen(temp) + 1);
tk->Size = ImGui::CalcTextSize(buffer.Buf.Data + tk->TextOffset);
tk->Labeled = true;
}
}
}
inline float MaxTickLabelWidth(ImVector<ImPlotTick>& ticks) {
float w = 0;
for (int i = 0; i < ticks.Size; ++i)
w = ticks[i].Size.x > w ? ticks[i].Size.x : w;
return w;
}
class YPadCalculator {
public:
YPadCalculator(const ImPlotAxisState* axis_states, const float* max_label_widths, float txt_off)
: ImPlotAxisStates(axis_states), MaxLabelWidths(max_label_widths), TxtOff(txt_off) {}
float operator()(int y_axis) {
ImPlotState& plot = *gp.CurrentPlot;
if (!ImPlotAxisStates[y_axis].Present) { return 0; }
// If we have more than 1 axis present before us, then we need
// extra space to account for our tick bar.
float pad_result = 0;
if (ImPlotAxisStates[y_axis].PresentSoFar >= 3) {
pad_result += 6.0f;
}
if (!HasFlag(plot.YAxis[y_axis].Flags, ImPlotAxisFlags_TickLabels)) {
return pad_result;
}
pad_result += MaxLabelWidths[y_axis] + TxtOff;
return pad_result;
}
private:
const ImPlotAxisState* const ImPlotAxisStates;
const float* const MaxLabelWidths;
const float TxtOff;
};
//-----------------------------------------------------------------------------
// Axis Utils
//-----------------------------------------------------------------------------
void UpdateAxisColor(int axis_flag, ImPlotAxisColor* col) {
const ImVec4 col_Axis = gp.Style.Colors[axis_flag].w == -1 ? ImGui::GetStyle().Colors[ImGuiCol_Text] * ImVec4(1, 1, 1, 0.25f) : gp.Style.Colors[axis_flag];
col->Major = ImGui::GetColorU32(col_Axis);
col->Minor = ImGui::GetColorU32(col_Axis * ImVec4(1, 1, 1, 0.25f));
col->Txt = ImGui::GetColorU32(ImVec4(col_Axis.x, col_Axis.y, col_Axis.z, 1));
}
struct ImPlotAxisScale {
ImPlotAxisScale(int y_axis, float tx, float ty, float zoom_rate) {
Min = PixelsToPlot(gp.BB_Plot.Min - gp.BB_Plot.GetSize() * ImVec2(tx * zoom_rate, ty * zoom_rate), y_axis);
Max = PixelsToPlot(gp.BB_Plot.Max + gp.BB_Plot.GetSize() * ImVec2((1 - tx) * zoom_rate, (1 - ty) * zoom_rate), y_axis);
}
ImPlotPoint Min, Max;
};
//-----------------------------------------------------------------------------
// BeginPlot()
//-----------------------------------------------------------------------------
bool BeginPlot(const char* title, const char* x_label, const char* y_label, const ImVec2& size, ImPlotFlags flags, ImPlotAxisFlags x_flags, ImPlotAxisFlags y_flags, ImPlotAxisFlags y2_flags, ImPlotAxisFlags y3_flags) {
IM_ASSERT_USER_ERROR(gp.CurrentPlot == NULL, "Mismatched BeginPlot()/EndPlot()!");
// FRONT MATTER -----------------------------------------------------------
ImGuiContext &G = *GImGui;
ImGuiWindow * Window = G.CurrentWindow;
if (Window->SkipItems) {
gp.Reset();
return false;
}
const ImGuiID ID = Window->GetID(title);
const ImGuiStyle &Style = G.Style;
const ImGuiIO & IO = ImGui::GetIO();
bool just_created = gp.Plots.GetByKey(ID) == NULL;
gp.CurrentPlot = gp.Plots.GetOrAddByKey(ID);
ImPlotState &plot = *gp.CurrentPlot;
plot.CurrentYAxis = 0;
if (just_created) {
plot.Flags = flags;
plot.XAxis.Flags = x_flags;
plot.YAxis[0].Flags = y_flags;
plot.YAxis[1].Flags = y2_flags;
plot.YAxis[2].Flags = y3_flags;
}
else {
// TODO: Check which individual flags changed, and only reset those!
// There's probably an easy bit mask trick I'm not aware of.
if (flags != plot.PreviousFlags)
plot.Flags = flags;
if (y_flags != plot.YAxis[0].PreviousFlags)
plot.YAxis[0].PreviousFlags = y_flags;
if (y2_flags != plot.YAxis[1].PreviousFlags)
plot.YAxis[1].PreviousFlags = y2_flags;
if (y3_flags != plot.YAxis[2].PreviousFlags)
plot.YAxis[2].PreviousFlags = y3_flags;
}
plot.PreviousFlags = flags;
plot.XAxis.PreviousFlags = x_flags;
plot.YAxis[0].PreviousFlags = y_flags;
plot.YAxis[1].PreviousFlags = y2_flags;
plot.YAxis[2].PreviousFlags = y3_flags;
// capture scroll with a child region
const float default_w = 400;
const float default_h = 300;
if (!HasFlag(plot.Flags, ImPlotFlags_NoChild)) {
ImGui::BeginChild(title, ImVec2(size.x == 0 ? default_w : size.x, size.y == 0 ? default_h : size.y));
Window = ImGui::GetCurrentWindow();
Window->ScrollMax.y = 1.0f;
gp.ChildWindowMade = true;
}
else {
gp.ChildWindowMade = false;
}
ImDrawList &DrawList = *Window->DrawList;
// NextPlotData -----------------------------------------------------------
if (gp.NextPlotData.HasXRange) {
if (just_created || gp.NextPlotData.XRangeCond == ImGuiCond_Always)
{
plot.XAxis.Range = gp.NextPlotData.X;
}
}
for (int i = 0; i < MAX_Y_AXES; i++) {
if (gp.NextPlotData.HasYRange[i]) {
if (just_created || gp.NextPlotData.YRangeCond[i] == ImGuiCond_Always)
{
plot.YAxis[i].Range = gp.NextPlotData.Y[i];
}
}
}
// AXIS STATES ------------------------------------------------------------
gp.X = ImPlotAxisState(plot.XAxis, gp.NextPlotData.HasXRange, gp.NextPlotData.XRangeCond, true, 0);
gp.Y[0] = ImPlotAxisState(plot.YAxis[0], gp.NextPlotData.HasYRange[0], gp.NextPlotData.YRangeCond[0], true, 0);
gp.Y[1] = ImPlotAxisState(plot.YAxis[1], gp.NextPlotData.HasYRange[1], gp.NextPlotData.YRangeCond[1],
HasFlag(plot.Flags, ImPlotFlags_YAxis2), gp.Y[0].PresentSoFar);
gp.Y[2] = ImPlotAxisState(plot.YAxis[2], gp.NextPlotData.HasYRange[2], gp.NextPlotData.YRangeCond[2],
HasFlag(plot.Flags, ImPlotFlags_YAxis3), gp.Y[1].PresentSoFar);
gp.LockPlot = gp.X.Lock && gp.Y[0].Lock && gp.Y[1].Lock && gp.Y[2].Lock;
// CONSTRAINTS ------------------------------------------------------------
plot.XAxis.Range.Min = ConstrainNan(ConstrainInf(plot.XAxis.Range.Min));
plot.XAxis.Range.Max = ConstrainNan(ConstrainInf(plot.XAxis.Range.Max));
for (int i = 0; i < MAX_Y_AXES; i++) {
plot.YAxis[i].Range.Min = ConstrainNan(ConstrainInf(plot.YAxis[i].Range.Min));
plot.YAxis[i].Range.Max = ConstrainNan(ConstrainInf(plot.YAxis[i].Range.Max));
}
if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LogScale))
plot.XAxis.Range.Min = ConstrainLog(plot.XAxis.Range.Min);
if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LogScale))
plot.XAxis.Range.Max = ConstrainLog(plot.XAxis.Range.Max);
for (int i = 0; i < MAX_Y_AXES; i++) {
if (HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LogScale))
plot.YAxis[i].Range.Min = ConstrainLog(plot.YAxis[i].Range.Min);
if (HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LogScale))
plot.YAxis[i].Range.Max = ConstrainLog(plot.YAxis[i].Range.Max);
}
if (plot.XAxis.Range.Max <= plot.XAxis.Range.Min)
plot.XAxis.Range.Max = plot.XAxis.Range.Min + DBL_EPSILON;
for (int i = 0; i < MAX_Y_AXES; i++) {
if (plot.YAxis[i].Range.Max <= plot.YAxis[i].Range.Min)
plot.YAxis[i].Range.Max = plot.YAxis[i].Range.Min + DBL_EPSILON;
}
// COLORS -----------------------------------------------------------------
gp.Col_Frame = gp.Style.Colors[ImPlotCol_FrameBg].w == -1 ? ImGui::GetColorU32(ImGuiCol_FrameBg) : ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_FrameBg]);
gp.Col_Bg = gp.Style.Colors[ImPlotCol_PlotBg].w == -1 ? ImGui::GetColorU32(ImGuiCol_WindowBg) : ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_PlotBg]);
gp.Col_Border = gp.Style.Colors[ImPlotCol_PlotBorder].w == -1 ? ImGui::GetColorU32(ImGuiCol_Text, 0.5f) : ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_PlotBorder]);
UpdateAxisColor(ImPlotCol_XAxis, &gp.Col_X);
UpdateAxisColor(ImPlotCol_YAxis, &gp.Col_Y[0]);
UpdateAxisColor(ImPlotCol_YAxis2, &gp.Col_Y[1]);
UpdateAxisColor(ImPlotCol_YAxis3, &gp.Col_Y[2]);
gp.Col_Txt = ImGui::GetColorU32(ImGuiCol_Text);
gp.Col_TxtDis = ImGui::GetColorU32(ImGuiCol_TextDisabled);
gp.Col_SlctBg = ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_Selection] * ImVec4(1,1,1,0.25f));
gp.Col_SlctBd = ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_Selection]);
gp.Col_QryBg = ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_Query] * ImVec4(1,1,1,0.25f));
gp.Col_QryBd = ImGui::GetColorU32(gp.Style.Colors[ImPlotCol_Query]);
// BB AND HOVER -----------------------------------------------------------
// frame
const ImVec2 frame_size = ImGui::CalcItemSize(size, default_w, default_h);
gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size);
ImGui::ItemSize(gp.BB_Frame);
if (!ImGui::ItemAdd(gp.BB_Frame, 0, &gp.BB_Frame)) {
gp.Reset();
return false;
}
gp.Hov_Frame = ImGui::ItemHoverable(gp.BB_Frame, ID);
ImGui::RenderFrame(gp.BB_Frame.Min, gp.BB_Frame.Max, gp.Col_Frame, true, Style.FrameRounding);
// canvas bb
gp.BB_Canvas = ImRect(gp.BB_Frame.Min + Style.WindowPadding, gp.BB_Frame.Max - Style.WindowPadding);
// adaptive divisions
int x_divisions = ImMax(2, (int)IM_ROUND(0.003 * gp.BB_Canvas.GetWidth()));
int y_divisions[MAX_Y_AXES];
for (int i = 0; i < MAX_Y_AXES; i++) {
y_divisions[i] = ImMax(2, (int)IM_ROUND(0.003 * gp.BB_Canvas.GetHeight()));
}
gp.RenderX = (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_GridLines) ||
HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickMarks) ||
HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels)) && x_divisions > 1;
for (int i = 0; i < MAX_Y_AXES; i++) {
gp.RenderY[i] =
gp.Y[i].Present &&
(HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_GridLines) ||
HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickMarks) ||
HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_TickLabels)) && y_divisions[i] > 1;
}
// get ticks
if (gp.RenderX && gp.NextPlotData.ShowDefaultTicksX)
AddDefaultTicks(plot.XAxis.Range, x_divisions, 10, HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LogScale), gp.XTicks);
for (int i = 0; i < MAX_Y_AXES; i++) {
if (gp.RenderY[i] && gp.NextPlotData.ShowDefaultTicksY[i]) {
AddDefaultTicks(plot.YAxis[i].Range, y_divisions[i], 10, HasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LogScale), gp.YTicks[i]);
}
}
// label ticks
if (HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_TickLabels))
LabelTicks(gp.XTicks, HasFlag(plot.XAxis.Flags, ImPlotAxisFlags_Scientific), gp.XTickLabels);