FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

restore pre-5.2 logscale tic increment interpretation · gnuplot/gnuplot-old@fe9c29c · GitHub

Repository navigation

Commit fe9c29c

Browse files
sfeam
committed
restore pre-5.2 logscale tic increment interpretation
1 parent 425ad08 commit fe9c29c

5 files changed

Lines changed: 119 additions & 27 deletions

File tree

‎ChangeLog‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2017-09-23 Ethan A Merritt <merritt@u.washington.edu>
2+
3+
* src/axis.c (gen_tics) docs/gnuplot.doc demo/nonlinear6.dem:
4+
Revise documentation of "set xtics" to include examples and description
5+
of logscale keyword. Restore pre-5.2 behaviour that for log-scaled axes
6+
the increment in "set xtics {start,} incr {,end}" is interpreted as a
7+
multiplicative factor rather than a constant interval. However this is
8+
only true if the "logscale" attribute is set for axis tics.
9+
New demo nonlinear6.dem exercises this feature and also shows the use of
10+
"set tics rangelimit" with log-scaled axes.
11+
Bug #1971
12+
113
2017-09-21 Ethan A Merritt <merritt@u.washington.edu>
214

315
* term/cairo.trm (cairotrm_reset): Still trying to get this right.

‎demo/all.dem‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $Id: all.dem,v 1.79 2017-01-11 04:13:58 sfeam Exp $
2+
# $Id: all.dem,v 1.80 2017-09-23 04:48:03 sfeam Exp $
33
#
44
# Executes all demos (OK, MOST demos) in this directory.
55
# This serves as a series of unit tests for non-interactive capabilities.
@@ -390,6 +390,7 @@ load "nonlinear2.dem"
390390
load "nonlinear3.dem"
391391
load "nonlinear4.dem"
392392
load "nonlinear5.dem"
393+
load "nonlinear6.dem"
393394
reset
394395

395396
print "********************** file transparent.dem *********************"

‎demo/nonlinear6.dem‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Logscale axis tic placement has always been problematic.
3+
# This demo exercises both automatic tic placement and
4+
# user-specified tic series.
5+
#
6+
set log y
7+
set log y2
8+
set tics nomirror
9+
set border 11
10+
set key center title "rangelimited tics" samplen -1
11+
12+
set xrange [1:15000]
13+
14+
set ytics 10 logscale rangelimit
15+
set y2tics auto rangelimit
16+
17+
plot sample [x=2:14000] x axes x1y1 title "set ytics 10", \
18+
[x=2:14000] x axes x1y2 title "set y2tics auto"
19+
20+
pause -1 "<cr> to continue"
21+
reset

‎docs/gnuplot.doc‎

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
C RCS $Id: gnuplot.doc,v 1.1109 2017-09-19 18:38:01 sfeam Exp $
1+
C RCS $Id: gnuplot.doc,v 1.1110 2017-09-23 04:48:04 sfeam Exp $
22
C
33
C Copyright (C) 1986 - 1993, 1998, 1999, 2000, 2001, 2004 Thomas Williams, Colin Kelley et al.
44
C
@@ -13910,6 +13910,7 @@ Ffigure_multiple_keys
1391013910
| ({"<label>"} <pos> {<level>} {,{"<label>"}...) }
1391113911
{format "formatstring"} {font "name{,<size>}"} {{no}enhanced}
1391213912
{ numeric | timedate | geographic }
13913+
{{no}logscale}
1391313914
{ rangelimited }
1391413915
{ textcolor <colorspec> }
1391513916
unset xtics
@@ -13963,10 +13964,32 @@ Ffigure_multiple_keys
1396313964
being displayed; otherwise it has no effect. Any previously specified tic
1396413965
frequency or position {and labels} are retained.
1396513966

13966-
Positions of the tics are calculated automatically by default or if the
13967-
`autofreq` option is given; otherwise they may be specified in either of
13968-
two forms:
13967+
Tic positions are calculated automatically by default or if the `autofreq`
13968+
option is given.
1396913969

13970+
A series of tic positions can be specified by giving either a tic interval
13971+
alone, or a start point, interval, and end point (see `xtics series`).
13972+
13973+
Individual tic positions can be specified individually by providing an
13974+
eplicit list of positions, where each position may have an associated
13975+
text label. See `xtics list`.
13976+
13977+
However they are specified, tics will only be plotted when in range.
13978+
13979+
Format (or omission) of the tic labels is controlled by `set format`, unless
13980+
the explicit text of a label is included in the `set xtics ("<label>")` form.
13981+
13982+
Minor (unlabeled) tics can be added automatically by the `set mxtics`
13983+
command, or at explicit positions by the `set xtics ("" <pos> 1, ...)` form.
13984+
13985+
The appearance of the tics (line style, line width etc.) is determined by the
13986+
border line (see `set border`), even if the tics are drawn at the axes.
13987+
4 xtics series
13988+
?set xtics series
13989+
?xtics series
13990+
Syntax
13991+
set xtics <incr>
13992+
set xtics <start>, <incr>, <end>
1397013993
The implicit <start>, <incr>, <end> form specifies that a series of tics will
1397113994
be plotted on the axis between the values <start> and <end> with an increment
1397213995
of <incr>. If <end> is not given, it is assumed to be infinity. The
@@ -14003,13 +14026,22 @@ Ffigure_multiple_keys
1400314026
Make tics at 1, 100, 1e4, 1e6, 1e8.
1400414027
set logscale x; set xtics 1,100,1e8
1400514028

14006-
The explicit ("<label>" <pos> <level>, ...) form allows arbitrary tic
14029+
4 xtics list
14030+
?set xtics list
14031+
?set xtics add
14032+
?xtics list
14033+
?xtics add
14034+
Syntax
14035+
set xtics {add} ("label1" <pos1> <level1>, "label2" <pos2> <level2>, ...)
14036+
14037+
The explicit ("label" <pos> <level>, ...) form allows arbitrary tic
1400714038
positions or non-numeric tic labels. In this form, the tics do not
1400814039
need to be listed in numerical order. Each tic has a
14009-
position, optionally with a label. Note that the label is
14010-
a string enclosed by quotes. It may be a constant string, such as
14011-
"hello", may contain formatting information for converting the
14012-
position into its label, such as "%3f clients", or may be empty, "".
14040+
position, optionally with a label.
14041+
14042+
The label is a string enclosed by quotes or a string-valued expression.
14043+
It may contain formatting information for converting the position into its
14044+
label, such as "%3f clients", or it may be the empty string "".
1401314045
See `set format` for more information. If no string is given, the
1401414046
default label (numerical) is used.
1401514047

@@ -14042,17 +14074,6 @@ Ffigure_multiple_keys
1404214074

1404314075
This will automatically generate tic marks every 0.5 along x, but will
1404414076
also add an explicit labeled tic mark at pi.
14045-
14046-
However they are specified, tics will only be plotted when in range.
14047-
14048-
Format (or omission) of the tic labels is controlled by `set format`, unless
14049-
the explicit text of a label is included in the `set xtics ("<label>")` form.
14050-
14051-
Minor (unlabeled) tics can be added automatically by the `set mxtics`
14052-
command, or at explicit positions by the `set xtics ("" <pos> 1, ...)` form.
14053-
14054-
The appearance of the tics (line style, line width etc.) is determined by the
14055-
border line (see `set border`), even if the tics are drawn at the axes.
1405614077
4 xtics timedata
1405714078
?set xtics timedata
1405814079
?xtics timedata tics
@@ -14117,6 +14138,26 @@ Ffigure_multiple_keys
1411714138
To output degrees/minutes/seconds in a context other than axis tics, such as
1411814139
placing labels on a map, you can use the relative time format specifiers
1411914140
%tH %tM %tS for strptime. See `time_specifiers`, `strptime`.
14141+
4 xtics logscale
14142+
?set xtics logscale
14143+
?xtics logscale
14144+
=logscale
14145+
If the `logscale` attribute is set for a tic series along a log-scaled axis,
14146+
the tic interval is interpreted as a multiplicative factor rather than a
14147+
constant. For example:
14148+
# generate a series of tics at y=20 y=200 y=2000 y=20000
14149+
set log y
14150+
set ytics 20, 10, 50000 logscale
14151+
Note that no tic is placed at y=50000 because it is not in the series 2*10^x.
14152+
If the logscale property is disabled, the tic increment will be treated as
14153+
an additive constant even for a log-scaled axis. For example:
14154+
# generate a series of tics at y=20 y=40 y=60 ... y=200
14155+
set log y
14156+
set yrange [20:200]
14157+
set ytics 20 nologscale
14158+
The `logscale` attribute is set automatically by the `set log` command,
14159+
so normally you do not need this keyword unless you want to force a
14160+
constant tic interval as in the second example above.
1412014161
4 xtics rangelimited
1412114162
?set xtics rangelimited
1412214163
?xtics rangelimited

‎src/axis.c‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: axis.c,v 1.245 2017-09-11 03:40:51 sfeam Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: axis.c,v 1.246 2017-09-23 04:48:04 sfeam Exp $"); }
33
#endif
44

55
/* GNUPLOT - axis.c */
@@ -1106,6 +1106,18 @@ gen_tics(struct axis *this, tic_callback callback)
11061106
end = step * ceil(lmax / step);
11071107
else
11081108
end = def->def.series.end;
1109+
if (def->logscaling) {
1110+
/* This emulates earlier gnuplot versions in handling
1111+
* set log y; set ytics 10
1112+
*/
1113+
step = eval_link_function(this->linked_to_primary, step);
1114+
end = eval_link_function(this->linked_to_primary, end);
1115+
start = eval_link_function(this->linked_to_primary, start);
1116+
if (!(start > this->linked_to_primary->min))
1117+
start = this->linked_to_primary->min;
1118+
lmin = this->linked_to_primary->min;
1119+
lmax = this->linked_to_primary->max;
1120+
}
11091121
} else {
11101122
start = def->def.series.start;
11111123
step = def->def.series.incr;
@@ -1253,8 +1265,10 @@ gen_tics(struct axis *this, tic_callback callback)
12531265
internal = tic;
12541266
user = tic;
12551267
} else if (nonlinear(this)) {
1256-
if (def->type == TIC_COMPUTED)
1257-
user = eval_link_function(this->linked_to_primary->linked_to_secondary, tic);
1268+
if (def->type == TIC_SERIES && def->logscaling)
1269+
user = eval_link_function(this, tic);
1270+
else if (def->type == TIC_COMPUTED)
1271+
user = eval_link_function(this, tic);
12581272
else
12591273
user = tic;
12601274
internal = tic; /* It isn't really, but this makes the range checks work */
@@ -1318,7 +1332,9 @@ gen_tics(struct axis *this, tic_callback callback)
13181332
}
13191333

13201334
/* This is where we finally decided to put the tic mark */
1321-
if (nonlinear(this) && (def->type == TIC_COMPUTED))
1335+
if (nonlinear(this) && (def->type == TIC_SERIES && def->logscaling))
1336+
position = user;
1337+
else if (nonlinear(this) && (def->type == TIC_COMPUTED))
13221338
position = user;
13231339
else
13241340
position = internal;
@@ -1351,8 +1367,9 @@ gen_tics(struct axis *this, tic_callback callback)
13511367
if (this->tictype == DT_TIMEDATE) {
13521368
mtic_user = time_tic_just(this->timelevel - 1, internal + mplace);
13531369
mtic_internal = mtic_user;
1354-
} else if (nonlinear(this) && (def->type == TIC_COMPUTED)) {
1355-
/* FIXME: make up for bad calculation of ministart/ministep/miniend */
1370+
} else if ((nonlinear(this) && (def->type == TIC_COMPUTED))
1371+
|| (nonlinear(this) && (def->type == TIC_SERIES && def->logscaling))) {
1372+
/* Make up for bad calculation of ministart/ministep/miniend */
13561373
double this_major = eval_link_function(this, internal);
13571374
double next_major = eval_link_function(this, internal+step);
13581375
mtic_user = this_major + mplace/miniend * (next_major - this_major);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL