|
From: Jim V. Z. <jr...@co...> - 2003-12-21 03:04:48
|
At present, gnuplot only knows about linear and log axes, and with a
log axis only the powers of 10 are labeled. I'd like to generalize
this, at least for the equivalent of "probability paper" and "weibull
plots", and preferably for any reasonable user-supplied function.
I've written a function that attempts to place tics according to these
rules:
- Place no tics or minitics outside the range specified by the user.
- Don't allow tic labels to overlap.
- Choose the "simplest" tics to label (i.e. those with the fewest
significant digits).
- Subject to the above, place tics with approximately even density.
- Ensure the value corresponding to each minitic is obvious.
- Subject to the above, place enough minitics that the user can
easily interpolate to find the value for any point on the graph.
I propose a four-step implementation process:
1. Provide for user mini-tics. Currently the user can provide tic marks
with a command like
set ytics ("bottom" 0, "" 10, "top" 20)
However, only full size tic marks can be generated by this mechanism.
I propose a patch below that will generate a minitic for a null label
"". The user can still get a full size tic with no label by putting
one or more spaces in the label string.
I propose that this part (only) be integrated into gnuplot version 4.0.
2. Algorithm. I have written a function to generate labels, tics, and
minitics for an axis that has undergone a user-supplied transform, and
a driver program with several transforms builtin, including log,
normal probability, and weibull probability. The driver program
writes out tic mark generating commands (as above). One example is
appended below. Please apply the patch to see the full effect. For
some other examples and the program sources, see
http://jrv.oddones.org
The algorithm is more complicated than I like, but I could not get any
of the simpler things I tried to work. There are still some cases
that don't come out right.
With the external program, a user can get a correctly labeled plot,
but she must include the transformation in the plot command. For
example:
set logscale x 10
set xlabel "yield strength, kg/mm^2"
set ylabel "unreliability"
set yrange [ -4.80000 : 2.00000 ] noreverse nowriteback
set label "see: http://www.reliasoft.com/newsletter/2q2001/classic_weibull.htm" \
at graph .98,.1 right
load 'steel.tic'
plot 'steel.dat' u ($3-38.57):(log(log(1/(1-$1/390))))
3. Decide on command syntax.
The current commands for specifying axes are:
set logscale <axes> <base>
unset logscale <axes>
set xtics {axis | border} {{no}mirror} {{no}rotate {by <ang>}}
{ autofreq
| <incr>
| <start>, <incr> {,<end>}
| ({"<label>"} <pos> {,{"<label>"} <pos>}...) }
{ font "name{,<size>}" }
{ textcolor <colorspec> }
unset xtics
I propose leaving "logscale" alone, but adding a "transform" option to
xtics as follows:
set xtics {axis | border} {{no}mirror} {{no}rotate {by <ang>}}
{ autofreq
| <incr>
| <start>, <incr> {,<end>}
| ({"<label>"} <pos> {,{"<label>"} <pos>}...)
| transform <function> }
{ font "name{,<size>}" }
{ textcolor <colorspec> }
The function must have exactly one variable.
So as an alternative to the above, the user could write
f(x) = log10(x)
set xtics transform f
g(y) = log(log(1/(1-y)))
set ytics transform g
plot 'steel.dat' u ($3-38.57):($1/390)
which would use the new algorithm to place minitics, regular tics, and
labels on both axes
4. Integration. I have not looked into this.
The patch for user-specified minitics follows.
- Jim Van Zandt
--- ./src/axis.c-orig Thu Feb 6 21:23:31 2003
+++ ./src/axis.c Thu Feb 6 21:42:48 2003
@@ -888,16 +888,20 @@
if (!inrange(internal, internal_min, internal_max))
continue;
-
+ /* use supplied format if any. If nothing is supplied, use
+ * default format.
+ */
if (axis_array[axis].is_timedata)
gstrftime(label, 24, mark->label ? mark->label : ticfmt[axis], mark->position);
else
gprintf(label, sizeof(label), mark->label ? mark->label : ticfmt[axis], log10_base, mark->position);
-
- (*callback) (axis, internal, label, lgrd);
+ /* if supplied format is empty, generate unlabeled minitic */
+ (*callback) (axis, internal,
+ mark->label ? (mark->label[0] ? label : 0) : label,
+ lgrd);
}
- return; /* NO MINITICS FOR USER-DEF TICS */
+ return;
/*}}} */
}
--- docs/gnuplot.doc-orig Sat Apr 12 10:08:42 2003
+++ docs/gnuplot.doc Sat Apr 12 10:18:53 2003
@@ -4399,9 +4399,11 @@
the same as `xy`). The length of the string representing a tic mark (after
formatting with 'printf') is restricted to 100 characters. If the format
string is omitted, the format will be returned to the default "%g". For
- LaTeX users, the format "$%g$" is often desirable. If the empty string "" is
- used, no label will be plotted with each tic, though the tic mark will still
- be plotted. To eliminate all tic marks, use `unset xtics` or `unset ytics`.
+ LaTeX users, the format "$%g$" is often desirable. If the format has
+ only a space " ", no label will be plotted with each tic, though the
+ tic mark will still be plotted. An empty string "" will result in an
+ unlabeled minitic. To eliminate all tic marks, use `unset xtics` or
+ `unset ytics`.
Newline (\n) is accepted in the format string. Use double-quotes rather than
single-quotes to enable such interpretation. See also `syntax`.
@@ -7861,9 +7863,11 @@
non-numeric tic labels. A set of tics is a set of positions, each with its
own optional label. Note that the label is a string enclosed by quotes. It
may be a constant string, such as "hello", may contain formatting information
- for converting the position into its label, such as "%3f clients", or may be
- empty, "". See `set format` for more information. If no string is given,
- the default label (numerical) is used. In this form, the tics do not need to
+ for converting the position into its label, such as "%3f clients". To get an
+ unlabeled minitic, use an empty string, "". For an unlabeled normal
+ size tic, use a string with a space " ". If no string is given, the
+ default label (numerical) is used. See `set format` for more
+ information. In this form, the tics do not need to
be listed in numerical order.
Examples:
|