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

Change mask color for nan/inf values to light grey for contour plots #180

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/plot/plcontourplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,20 @@ void wxPLContourPlot::RebuildContours() {
}
}
} else {
for (size_t k = 0; k < m_levels.size() - 1; k++) {
double zlow = m_levels[k];
double zhigh = m_levels[k + 1];
for (size_t k = 0; k < m_levels.size(); k++) {
double zlow = 0;
double zhigh = 0;
if (k == 0) {
zlow = m_levels[k] - (m_levels[1] - m_levels[0]);
zhigh = m_levels[k];
}
else {
zlow = m_levels[k-1];
zhigh = m_levels[k];
}

//double zlow = m_levels[k];
//double zhigh = m_levels[k + 1];

std::vector<QuadContourGenerator::VertexCodes *> list;
qcg.create_filled_contour(zlow, zhigh, list);
Expand Down Expand Up @@ -250,16 +261,17 @@ void wxPLContourPlot::Draw(wxPLOutputDevice &dc, const wxPLDeviceMapping &map) {
dc.NoPen();
// background set to min
// assume RebuildMask has been called
wxColor bgc(m_cmap->ColourForValue(m_zMin));
//wxColor bgc(m_cmap->ColourForValue(m_zMin));
wxColor bgc(*wxLIGHT_GREY);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be a defined value like CONTOUR_BG or COUNTOUR_NAN_COLOR for future maintenance - what do you think?

dc.Brush(bgc);
wxRealPoint pos, size;
map.GetDeviceExtents(&pos, &size);
dc.Rect(pos.x, pos.y, size.x, size.y);
// end background

// int ipoly = 0;
for (size_t i = 0; i < m_cPolys.size(); i++) {
double zmid = 0.5 * (m_cPolys[i].z + m_cPolys[i].zmax);
//double zmid = m_cPolys[i].z;
wxColour color(m_cmap->ColourForValue(zmid));
dc.Pen(color, 2);
dc.Brush(color);
Expand Down