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 colorbar number format #260

Closed
ddkn opened this issue Jun 30, 2023 · 5 comments
Closed

Change colorbar number format #260

ddkn opened this issue Jun 30, 2023 · 5 comments
Assignees

Comments

@ddkn
Copy link

ddkn commented Jun 30, 2023

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.

image

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

@tzanio
Copy link
Member

tzanio commented Jun 30, 2023

There is unfortunately no way currently to control this at user level.

@ddkn
Copy link
Author

ddkn commented Jul 1, 2023

Do you think it would be a desired feature? I may look into it trying to add it once I defend.

@tzanio
Copy link
Member

tzanio commented Jul 2, 2023

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:

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());
       }
    }

@tzanio tzanio self-assigned this Jul 2, 2023
@tzanio
Copy link
Member

tzanio commented Aug 27, 2023

@ddkn, were you able to resolve this?

@tzanio tzanio mentioned this issue Jun 19, 2024
22 tasks
@justinlaughlin justinlaughlin self-assigned this Jun 20, 2024
This was referenced Jul 10, 2024
@tzanio
Copy link
Member

tzanio commented Jul 22, 2024

Discussion continued in #288

@tzanio tzanio closed this as completed Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants