Closed KevinPoole closed 3 years ago
@KevinPoole thanks for the kind words, both about SigPlot and our assistance to you.
You are correct, the source code is pretty dense, lacks comments, and has a bunch of anachronisms because of its initial goal of pixel-perfect replication of the existing X-MIDAS plots (written in FORTRAN).
The tics are determined by mx.tics
. The purpose of mx.tics is given a range dmin=1500
to dmax=1700
to create ndiv=5
tics. The code in mx.tics
is a bit opaque and basically has a logic that was determine decades ago in the MIDAS plots as "what looks right". :)
Anyways, the result of mx.tics
will be dtic1=1500
(i.e. the first tic) and dtic=50
the space between tics. If you put something in like dmin=1505,dmax=1733
you will get dtic1=1550,dtic=50
. Can you put a breakpoint on mx.tics
and tell me what both the input and output is?
The function mx.drawaxis
is where the actually drawing occurs. Around this line:
https://github.com/spectriclabs/sigplot/blob/a7ac8f6daa847adb83e6299d60c38e5486c900bf/js/mx.js#L3088
Is where the tics created by mx.tics
are actually rendered using mx.format_f on:
https://github.com/spectriclabs/sigplot/blob/a7ac8f6daa847adb83e6299d60c38e5486c900bf/js/mx.js#L3112
If you put a break-point there what are the input values? My guess is that the tics are being drawn on round numbers (as described above) and the behavior of format_f
is to trim unnecessary trailing zeros.
How you are determining the tic marks are at something like 1500.12345? Are you hovering the mouse and reading the values? If so, the discrepancy might simply be due the conversion of pixel coordinated to real coordinates, since pixels and real values may not always be aligned.
Let me know what you find.
@maihde this should prove to be very helpful information. I am going to dig further right now.
Where I left off yesterday was actually trying to get set up in such a way that I could put breakpoints into the relevant sigplot code. So once I get that setup I should be able to use the above information you have provided to try and answer your questions.
Regarding:
How you are determining the tic marks are at something like 1500.12345? Are you hovering the mouse and reading the values?
No, you are likely correct that the tic marks themselves are landing on "round" values ending in zeroes which are getting trimmed. I just mean that It is not as if my x values are truly ranging from 1.5 to 1.7 and that I had been able to confirm that by seeing values such as 1500.12345 in the readout.
More to come...
Alright @maihde , so I have gotten set up with breakpoints and have the above info.
When I get to the line:
xlbl = mx.format_f(x * fmul, xlbl_maxlen, xlbl_maxlen / 2);
The following is true:
Inputs:
x: 1300
fmul: 0.001
xlbl_maxlen: 12
and subsequently:
Output:
xlbl: " 1.300000"
which checks out with what I have seen in practice.
And so to put my question in these terms specifically, I'm basically looking for how to get the above output to be 1300
instead of 1.300000
... thanks for your help thus far.
Eureka! I believe I figured it out.
Seems to be an undocumented flag that I discovered here:
so I added an xmult: 1
to my options and was able to achieve the desired effect.
Thanks again for the help troubleshooting!
All,
This is a bit of a shot in the dark, but ya'll have been outstandingly helpful to me with other Sigplot issues that I have run into, so I figured it would be worth asking...
Presently, I have a plot where the x values range from say 1500 to 1700. For some reason though, the tick mark labels are shown as things like 1.5, 1.6, etc. I can see in the readout that the corresponding x values really are things like 1500.12345 and such, but I can not for the life of me figure out how to get the tick mark labels to correspond. There is ample space for the full value to be displayed, I have even tried setting xdiv to 1 in order to guarantee as much.
The relevant code appears to be something in the vicinity of: https://github.com/LGSInnovations/sigplot/blob/480cec393280a41359924383d06bb6849eeab879/js/mx.js#L3132
but to be honest I have had a hard time making heads or tails of the source code. It seems very well written, just a bit dense to try and find a solid starting point as someone coming from the outside.
If anyone is willing to help me out once more then I'd be all the more grateful.
Thanks! -Kevin