|
From: <pl...@pi...> - 2016-04-01 09:16:57
|
On 01/04/16 04:35, sfeam wrote: > I have placed a patchset on SourceForge that introduces a general mechanism > for defining nonlinear axes in a plot. > > https://sourceforge.net/p/gnuplot/patches/728/ > > Demos here: > > http://skuld.bmsc.washington.edu/~merritt/gnuplot/#nonlinear > > It uses the linked-axis mechanism of forward and reverse mappings introduced > in the "set link {axis} via f(x) inverse g(x)" command with the major > difference that it links a non-linear visible axis with a hidden axis that is > always linear. > > One motivation is to eventually replace the current implementation of > logscale axes with something that is both more general and less expensive. > The effect of the existing command > set logscale x > can be achieved by the new command > set nonlinear x via log10(x) inverse 10**x > > A major advantage over the existing logscale implementation is that > coordinates are not transformed on input. The current logscale > code stores the log of the true coordinate, which then requires that > every single reference to that coordinate throughout the core gnuplot > code is mediated by macros AXIS_DO_LOG, AXIS_UNDO_LOG, AXIS_LOG_VALUE, > etc. Every time the coordinate is needed we check whether it was > stored as the log, unlog it if so, do whatever it was we wanted, > then reapply the log for comparison with other stored values. > By contrast the new nonlinear axis code simply stores the original > coordinate value. The nonlinear mapping (log in this case) is only > needed when we map it to a position on the output terminal canvas. > > The log()/exp() transform is an example of a nonlinear axis mapping, > but the new code is happy to accept other transforms as well. > This defines a probability plot axis: > set nonlinear x via norm(x) inverse invnorm(x) > See demo "probably_tux.dem". > > Another non-obvious example is creation of a "broken axis" plot. > This is a recurring feature request. In this case the hidden linear > axis spanning the full range [min:max] is mapped onto a visible axis > that shows only the first part and the last part of the range (see demo). > > Notes: > > The "set nonlinear x" command itself is sufficient to create a > log-scaled x axis. For backwards compatibility with the existing > behaviour, there is a second command "set xtics log" that reuses the > old tic-placement code. > > This version of the patch set only reserves space for hidden axes > shadowing the x and y axes. Extending it to handle the other visible > axes (x2 y2 z cb) should be trivial. > > The pieces are already in place to construct log-scaled or broken > axis plots, as shown by the demos. Once any bugs are shaken out, > I envision wrapping these in simple commands for easier use. > > For example, the command "set log" will continue to do what is has > always done but will use the new code rather than all those > LOG/DE_LOG macros underneath. > > The manual definition of mappings and axis markings for a broken axis > can be automated by introducing some new command analogous to the way > "set multiplot layout ..." automates manipulation of the scale and > offset parameters. > > Hi Ethan, This non-linear axis mechanism looks very flexible. I had a case a while ago where the broken axis format would have been useful. Nice feature. Reading these demos points out how many neat features I'm still not familiar with in the amazing software. The mix of 2D and 3D plots is very tidy. But it seems you may have missed out the usual link to the demo code that produced it. regards, Peter. |