Announcements and New Features #370
Replies: 5 comments
-
Plot Item Flags and More - (v0.14 - 6/18/2022)Plot Item FlagsEach of ImPlot's // Flags for ANY PlotX function enum ImPlotItemFlags_ { ImPlotItemFlags_None = 0, ImPlotItemFlags_NoLegend = 1 << 0, // the item won't have a legend entry displayed ImPlotItemFlags_NoFit = 1 << 1, // the item won't be considered for plot fits }; // Flags for PlotLine enum ImPlotLineFlags_ { ImPlotLineFlags_None = 0, // default ImPlotLineFlags_Segments = 1 << 10, // a line segment will be rendered from every two consecutive points ImPlotLineFlags_Loop = 1 << 11, // the last and first point will be connected to form a closed loop ImPlotLineFlags_SkipNaN = 1 << 12, // NaNs values will be skipped instead of rendered as missing data ImPlotLineFlags_NoClip = 1 << 13, // markers (if displayed) on the edge of a plot will not be clipped }; ... void PlotLine(const char* label_id, const T* xs, const T* ys, int count, ImPlotLineFlags flags=0, int offset=0, int stride=sizeof(T));As you can see, Here's a complete list of flags available for our current plotters: ImPlotItemFlags_NoLegend // the item won't have a legend entry displayed ImPlotItemFlags_NoFit // the item won't be considered for plot fits ImPlotLineFlags_Segments // a line segment will be rendered from every two consecutive points ImPlotLineFlags_Loop // the last and first point will be connected to form a closed loop ImPlotLineFlags_SkipNaN // NaNs values will be skipped instead of rendered as missing data ImPlotLineFlags_NoClip // markers (if displayed) on the edge of a plot will not be clipped ImPlotScatterFlags_NoClip // markers on the edge of a plot will not be clipped ImPlotStairsFlags_PreStep // the y value is continued constantly to the left from every x position, i.e. the interval (x[i-1], x[i]] has the value y[i] ImPlotBarsFlags_Horizontal // bars will be rendered horizontally on the current y-axis ImPlotBarGroupsFlags_Horizontal // bar groups will be rendered horizontally on the current y-axis ImPlotBarGroupsFlags_Stacked // items in a group will be stacked on top of each other ImPlotErrorBarsFlags_Horizontal // error bars will be rendered horizontally on the current y-axis ImPlotStemsFlags_Horizontal // stems will be rendered horizontally on the current y-axis ImPlotInfLinesFlags_Horizontal // lines will be rendered horizontally on the current y-axis ImPlotPieChartFlags_Normalize // force normalization of pie chart values (i.e. always make a full circle if sum < 0) ImPlotHeatmapFlags_ColMajor // data will be read in column major order ImPlotHistogramFlags_Horizontal // histogram bars will be rendered horizontally (not supported by PlotHistogram2D) ImPlotHistogramFlags_Cumulative // each bin will contain its count plus the counts of all previous bins (not supported by PlotHistogram2D) ImPlotHistogramFlags_Density // counts will be normalized, i.e. the PDF will be visualized, or the CDF will be visualized if Cumulative is also set ImPlotHistogramFlags_NoOutliers // exclude values outside the specifed histogram range from the count toward normalizing and cumulative counts ImPlotHistogramFlags_ColMajor // data will be read in column major order (not supported by PlotHistogram) ImPlotTextFlags_Vertical // text will be rendered verticallySUPER IMPORTANT NOTE: Each Besides that, items flags brings about a few other API breaking changes users should be aware of:
Again, this change will likely cause headaches for some users, but with this new system in place you can expect more plotting options to be added in future updates in a flexible and, importantly, maintainable way. Thanks for understanding. SetupAxisScalePreviously, users could define time and log scales with // Axis scale enum ImPlotScale_ { ImPlotScale_Linear = 0, // default linear scale ImPlotScale_Time, // date/time scale ImPlotScale_Log10, // base 10 logartithmic scale ImPlotScale_SymLog, // symmetric log scale }; // Sets an axis' scale using built-in options. void SetupAxisScale(ImAxis axis, ImPlotScale scale);
More built-in scales may be added in the future. Until then, you can also now define YOUR OWN scales using // Callback signature for axis transform. typedef double (*ImPlotTransform)(double value, void* user_data); // Sets an axis' scale using user supplied forward and inverse transfroms. void SetupAxisScale(ImAxis axis, ImPlotTransform forward, ImPlotTransform inverse, void* data=NULL);Example: static inline double TransformForward_Sqrt(double v, void*) { return sqrt(v); } static inline double TransformInverse_Sqrt(double v, void*) { return v*v; } ... if (ImPlot::BeginPlot("Sqrt")) { ImPlot::SetupAxis(ImAxis_X1, "Linear"); ImPlot::SetupAxis(ImAxis_Y1, "Sqrt"); ImPlot::SetupAxisScale(ImAxis_Y1, TransformForward_Sqrt, TransformInverse_Sqrt); ImPlot::PlotLine(...); ImPlot::EndPlot(); }New Axis ConstraintsYou can now constrain axes limits so that users can't pan beyond a min or max value, or zoom beyond a min or max width/height. This is nice if you don't want users straying away from displayed data or zooming too far into view. It is demonstrated in the candlestick demo in // Sets an axis' limits constraints. void SetupAxisLimitsConstraints(ImAxis axis, double v_min, double v_max); // Sets an axis' zoom constraints. void SetupAxisZoomConstraints(ImAxis axis, double z_min, double z_max);Misc. Improvements
|
Beta Was this translation helpful? Give feedback.
-
Legend Scrolling - (v0.17 - 8/20/2022)Long legend lists will now be clipped appropriately and can be scrolled with mouse wheel. This functions for both vertical and horizontal legends, inside or outside, and legends belonging to plots or subplots. This does not currently add a physical scroll bar to long legends. I will add this feature later if users absolutely need it. |
Beta Was this translation helpful? Give feedback.
-
Plot Bubbles - (v0.18 - 2026-02-13)It is now possible to plot bubbles thanks to @Luc16 in #611 // Plots a bubble graph. #szs are the radius of each bubble in plot units. IMPLOT_TMP void PlotBubbles(const char* label_id, const T* values, const T* szs, int count, double xscale=1, double xstart=0, ImPlotBubblesFlags flags=0, int offset=0, int stride=sizeof(T)); IMPLOT_TMP void PlotBubbles(const char* label_id, const T* xs, const T* ys, const T* szs, int count, ImPlotBubblesFlags flags=0, int offset=0, int stride=sizeof(T));Kooha-2026-02-12-11-35-13.mp4 |
Beta Was this translation helpful? Give feedback.
-
ImPlotSpec - (v0.18 - 2026-02-14)
Usage Option 1 -- By declaring and defining a struct instance: ImPlotSpec spec; spec.LineColor = ImVec4(1,1,0,1); spec.LineWeight = 1.0f; spec.FillColor = ImVec4(1,0.5f,0,1); spec.FillAlpha = 0.5f; spec.Marker = ImPlotMarker_Square; spec.MarkerSize = 6; spec.Stride = sizeof(ImVec2); spec.Flags = ImPlotItemFlags_NoLegend | ImPlotLineFlags_Shaded; ImPlot::PlotLine("Line 1", &data1[0].x, &data1[0].y, 20, spec);Usage Option 2 -- Inline using ImPlotProp,value pairs (order does NOT matter): ImPlot::PlotLine("Line 2", &data2[0].x, &data2[0].y, 20, { ImPlotProp_LineColor, ImVec4(0,1,1,1), ImPlotProp_LineWeight, 1.0f, ImPlotProp_FillColor, ImVec4(0,0,1,1), ImPlotProp_FillAlpha, 0.5f, ImPlotProp_Marker, ImPlotMarker_Diamond, ImPlotProp_MarkerSize, 6, ImPlotProp_Stride, sizeof(ImVec2), ImPlotProp_Flags, ImPlotItemFlags_NoLegend | ImPlotLineFlags_Shaded });ImPlotSpec enum and structs: enum ImPlotProp_ { ImPlotProp_LineColor, // line color (applies to lines, bar edges); IMPLOT_AUTO_COL will use next Colormap color or current item color ImPlotProp_LineWeight, // line weight in pixels (applies to lines, bar edges, marker edges) ImPlotProp_FillColor, // fill color (applies to shaded regions, bar faces); IMPLOT_AUTO_COL will use next Colormap color or current item color ImPlotProp_FillAlpha, // alpha multiplier (applies to FillColor and MarkerFillColor) ImPlotProp_Marker, // marker type; specify ImPlotMarker_Auto to use the next unused marker ImPlotProp_MarkerSize, // size of markers (radius) *in pixels* ImPlotProp_MarkerLineColor, // marker edge color; IMPLOT_AUTO_COL will use LineColor ImPlotProp_MarkerFillColor, // marker face color; IMPLOT_AUTO_COL will use LineColor ImPlotProp_Size, // size of error bar whiskers (width or height), and digital bars (height) *in pixels* ImPlotProp_Offset, // data index offset ImPlotProp_Stride, // data stride in bytes; IMPLOT_AUTO will result in sizeof(T) where T is the type passed to PlotX ImPlotProp_Flags // optional item flags; can be composed from common ImPlotItemFlags and/or specialized ImPlotXFlags }; ... struct ImPlotSpec { ImVec4 LineColor = IMPLOT_AUTO_COL; // line color (applies to lines, bar edges); IMPLOT_AUTO_COL will use next Colormap color or current item color float LineWeight = 1.0f; // line weight in pixels (applies to lines, bar edges, marker edges) ImVec4 FillColor = IMPLOT_AUTO_COL; // fill color (applies to shaded regions, bar faces); IMPLOT_AUTO_COL will use next Colormap color or current item color float FillAlpha = 1.0f; // alpha multiplier (applies to FillColor and MarkerFillColor) ImPlotMarker Marker = ImPlotMarker_None; // marker type; specify ImPlotMarker_Auto to use the next unused marker float MarkerSize = 4; // size of markers (radius) *in pixels* ImVec4 MarkerLineColor = IMPLOT_AUTO_COL; // marker edge color; IMPLOT_AUTO_COL will use LineColor ImVec4 MarkerFillColor = IMPLOT_AUTO_COL; // marker face color; IMPLOT_AUTO_COL will use LineColor float Size = 4; // size of error bar whiskers (width or height), and digital bars (height) *in pixels* int Offset = 0; // data index offset int Stride = IMPLOT_AUTO; // data stride in bytes; IMPLOT_AUTO will result in sizeof(T) where T is the type passed to PlotX ImPlotItemFlags Flags = ImPlotItemFlags_None; // optional item flags; can be composed from common ImPlotItemFlags and/or specialized ImPlotXFlags ... } |
Beta Was this translation helpful? Give feedback.
-
Plot Polygon - (v0.18 - 2026-03-07)It is now possible to plot polygons! Requested by @ssteinbach in #631, implemented in #673. // Plots a polygon. Points are specified in counter-clockwise order. If concave, make sure to set the Concave flag. IMPLOT_TMP void PlotPolygon(const char* label_id, const T* xs, const T* ys, int count, const ImPlotSpec& spec=ImPlotSpec());if (ImPlot::BeginPlot("Polygon Plot", ImVec2(-1,0), ImPlotFlags_Equal)) { ImPlot::PlotPolygon("Triangle", tri_xs, tri_ys, 3, { ImPlotProp_FillAlpha, 0.5f, }); ImPlot::PlotPolygon("Pentagon", pent_xs, pent_ys, 5, { ImPlotProp_FillAlpha, 0.5f, ImPlotProp_FillColor, ImVec4(0,1,0,1), }); ImPlot::PlotPolygon("Star (Concave)", star_xs, star_ys, 10, { ImPlotProp_FillAlpha, 0.5f, ImPlotProp_FillColor, ImVec4(1,1,0,1), ImPlotProp_Flags, ImPlotPolygonFlags_Concave, }); ImPlot::EndPlot(); } |
Beta Was this translation helpful? Give feedback.







Uh oh!
There was an error while loading. Please reload this page.
-
Announcements of changes and new features will be posted here. Click
Subscribeto the right to receive updates!Feel free to comment on announcements, but please do not clutter the main thread with comments.
Previous Announcements:
Announcements and New Features (2021)
Announcements and New Features (2020)
Beta Was this translation helpful? Give feedback.
All reactions