Colorbar labels

19 views
Skip to first unread message

Simone Campanini

unread,
Nov 3, 2020, 5:28:18 AM11/3/20
to MathGL
Dear Alexey,

That was very strange....

In the application I'm writing, I have to display some graphical maps obtained from
measured values. I followed the documentation, and everything goes quite well, the
map is extremely accurate, but with an exception: no way to display the colorbar (and only the colorbar)  labels!

This is the C++ code I use

m_gr->Clf();   

m_gr->SubPlot(1,1,0);

m_gr->SetFontSize(1.4);

m_gr->SetFunc("lg(x)","");

m_gr->Axis();

m_gr->SetTicksVal('x', m_tickVal, m_frqLabels);

m_gr->SetTickRotate(false);

m_gr->SetRange('x', 100, 20000);

m_gr->SetRange('y', -180, 180);

m_gr->SetRange('z',  -40, 0);

m_gr->SetRange('c',  -40, 0); 

m_gr->Label('x', "Frequency [Hz]");

m_gr->Label('y', "Azimut angle [degrees]");

m_gr->Dens(m_mapGrid);

m_gr->Box();

m_gr->Colorbar(">"); 

m_gr->Finish();


I tried a lot of different settings, but no way to show the labels on the colorbar (but 
the ticks are in the right places). In a moment of madness I decided to go deep in the
code to find out the reason...after digging and digging, following the glyph drawing
calls, I ended up in the trig_draw method of the backend I'm using - OpenGL -, discovering that the 'z' coordinates of all the points are always constant and > 1. 
According to OpenGL specifications, this means that these points are not drawable, 
because all coordinates are normalised to -1,+1, so the gliph of the labels weren't draw.

Tracing back, I found a solution that actually works for me, but is a dirty trick, indeed...
In the axis.cpp file of MathGL, I changed line 1129
from 

ac.org.Set(w+x, h+y, s3+1);

to

ac.org.Set(w+x, h+y, 1.5);

and now I see all my labels!

But now I'm curious on how this could happen...and maybe with a better solution for my problem...

Thank you!

Simone.

Reply all
Reply to author
Forward
0 new messages