Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicolor Plot Shaded #247

Closed
Davido71 opened this issue Jun 12, 2021 · 2 comments
Closed

Multicolor Plot Shaded #247

Davido71 opened this issue Jun 12, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@Davido71
Copy link

I have been using your plot library quite a lot lately and I'm hoping you can give me some direction on my latest issue.

I'm trying to use PlotShaded() to render different colors when the lines intersect. For example green when line 1 is above line 2 and red when line 1 is below line 2. Is there a way to do this?

Here is what I have so far:

static ImPlotPoint zeroLine(void* data, int i)
{
    return ImPlotPoint(i, 0);
}

static ImPlotPoint getDataSet(void* data, int i)
{
    dataset_t* ptr = reinterpret_cast<dataset_t*>(data);
    return ImPlotPoint(i, ptr->at(i));
}

ImPlot::SetNextFillStyle(ImVec4(0.0f, 0.8f, 0.0f, 1.0f));
ImPlot::PlotShadedG("##wt1", getDataSet, const_cast<dataset_t*>(&data.wt1), zeroLine, nullptr, static_cast<int>(data.wt1.size()), 0.0);

I filled in the lower area red to show what I'm trying to do:

AreaPlotExample

@epezent
Copy link
Owner

epezent commented Jun 16, 2021

@Davido71 , take a look at this PR and let me know if it meets your needs: #161

@epezent epezent added the enhancement New feature or request label Jun 16, 2021
@Davido71
Copy link
Author

Yes, that points me in the right direction. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants