Replies: 1 comment
-
|
Hey, I've modified the demo to test you code (shaded_scatter_demo.patch), but I'm not sure if it is working as expected. Kooha-2025-11-27-06-55-14.mp4From what I understood you want to separate the marker rendering into a marker fill rendering and a marker line rendering, so you would be able to render markers without fill color by using the flag instead of transparent fill color? If that's so, then I do think you would need to modify the renderers. If what you want, however, is to render each point with a different color, with colors sampled from a colormap, I would recommend calling
void Demo_GradientScatterPlots() {
// 1. Setup some dummy data (e.g., a spiral or sine wave)
static const int count = 100;
static float xs[count], ys[count];
static bool first_run = true;
if (first_run) {
for (int i = 0; i < count; ++i) {
float t = i / (float)(count - 1);
xs[i] = t * cosf(t * 10.0f); // Spiral x
ys[i] = t * sinf(t * 10.0f); // Spiral y
}
first_run = false;
}
if (ImPlot::BeginPlot("Gradient Scatter")) {
// 2. We want the markers to use the "Jet" or "Viridis" colormap
ImPlot::PushColormap(ImPlotColormap_Jet);
// 3. Loop through every point individually
for (int i = 0; i < count; ++i) {
// A. Calculate the percentage 't' (0.0 to 1.0)
float t = (float)i / (float)(count - 1);
// B. Sample the Colormap to get the RGBA color
ImVec4 color = ImPlot::SampleColormap(t);
// C. Set this color for the Marker Fill and Outline
ImPlot::SetNextMarkerStyle(IMPLOT_AUTO, IMPLOT_AUTO, color, IMPLOT_AUTO, color);
// D. Plot exactly ONE point
// Note: We pass &xs[i] to get the pointer to the current float
// and we set the count to '1'.
ImPlot::PlotScatter("##HiddenLabel", &xs[i], &ys[i], 1);
}
ImPlot::PopColormap();
ImPlot::EndPlot();
}
}Let me know if you have any questions about the code or if I misunderstood you. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am attempting to add the option to render the markers as per the selected heatmap, but on an item by item basis. I followed the example of how the shaded option was added to the line plots used in the table demo. For this change however the amount of lines touched seemed fairly high and I'm sure there might be a better way to do it.
I attempted to use the custom getter interface, but an ImPlotPoint is able to communicate it's color, and doing the same with ImRects seemed like too
much of a change.
The other sticking point that was surprising is that I had to add some specific context to the renderer to help traverse the colormap properly. I'd imagine that's me doing something wrong as it doesn't seem like state he should be holding. The getter counts didn't do quite what I needed.
Attached is the patch. Baseband IQ scatter plots might be a little off in the weeds to actually be supported, but it does look cool.
shaded_scatter.patch
Beta Was this translation helpful? Give feedback.
All reactions