glvis
glvis copied to clipboard
Change colorbar number format
Hello,
Looking at the documentation I wasn't sure how to change the string format on the colorbar, or is this even possible? I would like it to be more consistent. Depending on the amount of significant figures you may get a float or scientific notation in the same colorbar.
It would be nice to have more control, such as show sign (+ and -) and control the significant figures after the decimal, e.g. +3.145e+00 and -3.145e+00. Again, I apologize if I have missed this option
Or is there a better way to export this for plotting?
Thanks in advance!
PS I believe glvis
was installed through pip install glvis==0.3.3
, which I think pulled in the latest binary 4.2
There is unfortunately no way currently to control this at user level.
Do you think it would be a desired feature? I may look into it trying to add it once I defend.
Do you think it would be a desired feature? I may look into it trying to add it once I defend.
Definitely!
If you can build GLVis yourself, the change is not hard -- the corresponding code is in the following lines:
- https://github.com/GLVis/glvis/blob/master/lib/vsdata.cpp#L500
- https://github.com/GLVis/glvis/blob/master/lib/vsdata.cpp#L512
and maybe you want a diff like:
diff --git a/lib/vsdata.cpp b/lib/vsdata.cpp
index 1934414..9e69eac 100644
--- a/lib/vsdata.cpp
+++ b/lib/vsdata.cpp
@@ -497,7 +497,7 @@ void VisualizationSceneScalarData::PrepareColorBar (double minval,
val = ULogVal(i / 4.0);
ostringstream buf;
- buf << setprecision(4) << val;
+ buf << fixed << showpos << val;
color_bar.addText(text_x,Y,posz, buf.str());
}
}
@@ -509,7 +509,7 @@ void VisualizationSceneScalarData::PrepareColorBar (double minval,
Y = miny + (maxy - miny) * LogUVal(val);
ostringstream buf;
- buf << setprecision(4) << val;
+ buf << fixed << showpos << val;
color_bar.addText(text_x,Y,posz, buf.str());
}
}
@ddkn, were you able to resolve this?