|
From: Jonathan T. <jt...@as...> - 2013-06-27 23:26:43
|
I'm using gnuplot 4.6.3, freshly compiled from the sourceforge tarball.
(See below for my full 'show version long' output.)
I'm trying to produce a log-scale plot with labels at the 1, 2, and 5
positions of each decade. Alas, If I use the
"label" posn level
form of 'set xtics' or 'set ytics', the label disappears for level 1
(minor) tics. For example,
set xtics (1, 2 1, "" 3 1, "" 4 1, 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, 10)
or
set xtics ("1" 1, "2" 2 1, "" 3 1, "" 4 1, "5" 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10)
each produces a graph with the 2 and 5 labels missing (i.e., only 1 and
10 labels are present). This behavior is also present for a linear-scale
plot, i.e., the log-scale is actually irrelevant here (apart from providing
my original motivation).
This works
set xtics (1, 2, "" 3 1, "" 4 1, 5, "" 6 1, "" 7 1, "" 8 1, "" 9 1, 10)
and so does this
set xtics ("1" 1 0, "2" 2 0, "" 3 1, "" 4 1, "5" 5 0, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10 0)
(in the sense that each of these gives labels 1, 2, 5, and 10)
but both of those have the 2 and 5 tics as level-0 (major) instead of
level-1 (minor).
More generally, I can find no way to put a label on a level-1 tic.
It seems to me that is a bug, or at best a mis-feature.
Is there a known workaround (apart from puttting the labels on by hand,
or using multiplot to superimpose another plot)?
Here's a full script to reproduce the problem; comment or uncomment
one of the 'set xtics' command as desired:
--- begin script ---
set xrange [1:10]
# these work (but have 2 and 5 as level 0 (major) tics
##set xtics (1, 2, "" 3 1, "" 4 1, 5, "" 6 1, "" 7 1, "" 8 1, "" 9 1, 10)
##set xtics ("1" 1 0, "2" 2 0, "" 3 1, "" 4 1, "5" 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10 0)
# each of these omits the 2 and 5 labels
set xtics (1, 2 1, "" 3 1, "" 4 1, 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, 10)
##set xtics ("1" 1, "2" 2 1, "" 3 1, "" 4 1, "5" 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10)
##set xtics ("1" 1 0, "2" 2 1, "" 3 1, "" 4 1, "5" 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10 0)
plot sin(x)
--- end script ---
For completeness, here's my ~/.gnuplot file:
--- begin ~/.gnuplot ---
# gnuplot init file
set format "%g"
set term x11
set samples 1000
set style data lines
set zero 0.0
set xyplane 0.0
set clip two
set view ,,0.9
set view 30, 300
min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y
hypot(re,im) = sqrt(re**2 + im**2)
cnorm(re,im) = hypot(re,im)
fmod(x,y) = x - y*floor(x/y)
average(x,y) = x + 0.5*(y-x)
# map t in [0,1] --> [a,b]
map01(a,b,t) = a + t*(b-a)
--- end ~/.gnuplot ---
Here's my "show version long" output:
--- begin 'show version long' output ---
gnuplot> show version long
G N U P L O T
Version 4.6 patchlevel 3 last modified 2013-04-12
Build System: OpenBSD amd64
Copyright (C) 1986-1993, 1998, 2004, 2007-2013
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help FAQ"
immediate help: type "help" (plot window: hit 'h')
Compile options:
-READLINE +LIBREADLINE -HISTORY
-BACKWARDS_COMPATIBILITY +BINARY_DATA
+GD_PNG +GD_JPEG +GD_TTF +GD_GIF +ANIMATION
-USE_CWDRC +X11 +X11_POLYGON +MULTIBYTE +X11_EXTERNAL +USE_MOUSE +HIDDEN3D_QUADTREE
+DATASTRINGS +HISTOGRAMS +OBJECTS +STRINGVARS +MACROS +IMAGE +USER_LINETYPES +STATS
GNUPLOT_DRIVER_DIR = "/usr/local/libexec/gnuplot/4.6"
GNUPLOT_PS_DIR = "/usr/local/share/gnuplot/4.6/PostScript"
HELPFILE = "/usr/local/share/gnuplot/4.6/gnuplot.gih"
gnuplot>
--- end 'show version long' output ---
ciao,
--
-- "Jonathan Thornburg [remove -animal to reply]" <jt...@as...>
Dept of Astronomy & IUCSS, Indiana University, Bloomington, Indiana, USA
on sabbatical in Canada through late August 2013
"There was of course no way of knowing whether you were being watched
at any given moment. How often, or on what system, the Thought Police
plugged in on any individual wire was guesswork. It was even conceivable
that they watched everybody all the time." -- George Orwell, "1984"
|
|
From: Juhász P. <pet...@gm...> - 2013-06-28 17:06:07
|
On Thu, 2013-06-27 at 16:13 -0700, Jonathan Thornburg wrote:
[snip]
> the label disappears for level 1
> (minor) tics. For example,
> set xtics (1, 2 1, "" 3 1, "" 4 1, 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, 10)
> or
> set xtics ("1" 1, "2" 2 1, "" 3 1, "" 4 1, "5" 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10)
> each produces a graph with the 2 and 5 labels missing (i.e., only 1 and
> 10 labels are present). This behavior is also present for a linear-scale
> plot,
[snip]
I asked a similar question some months ago and I was told that minor
tics don't have labels, by definition.
As far as I know, there is no workaround, because you only have minor
tics (that don't have labels) and major tics (that may have labels), and
you can set different sizes for only these two, but all major tics have
the same length.
One possible solution that does not break compatibility with the
existing definition, but provides variable length tics:
Allow the third number (the tic level) in the "set tics" specification
to be a real number instead of an integer. There would still be two tic
length settings, one for major, the other for minor tics, and the actual
length of a tic would be calculated by interpolating between the two
pre-set lengths (tic_len = tic_level * (minor - major) + major).
Any tic level that is not 1 could have labels.
best regards,
Peter Juhasz
|
|
From: Ethan M. <merritt@u.washington.edu> - 2013-06-28 18:14:53
|
On Friday, 28 June 2013, Juhász Péter wrote:
> On Thu, 2013-06-27 at 16:13 -0700, Jonathan Thornburg wrote:
> [snip]
> > the label disappears for level 1
> > (minor) tics. For example,
> > set xtics (1, 2 1, "" 3 1, "" 4 1, 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, 10)
> > or
> > set xtics ("1" 1, "2" 2 1, "" 3 1, "" 4 1, "5" 5 1, "" 6 1, "" 7 1, "" 8 1, "" 9 1, "10" 10)
> > each produces a graph with the 2 and 5 labels missing (i.e., only 1 and
> > 10 labels are present). This behavior is also present for a linear-scale
> > plot,
> [snip]
>
> I asked a similar question some months ago and I was told that minor
> tics don't have labels, by definition.
>
> As far as I know, there is no workaround, because you only have minor
> tics (that don't have labels) and major tics (that may have labels), and
> you can set different sizes for only these two, but all major tics have
> the same length.
>
>
> One possible solution that does not break compatibility with the
> existing definition, but provides variable length tics:
Another option is to relax the restriction that tic levels can only be
"major" (level 0) and "minor" (level 1). The code already tracks tic level
as an integer but ignores requests for tic level 2 or 3 etc. It should be
easy to modify the code that so that you can add labels using
set xtics add ("Level 2" 2 2)
I'm not sure what length tic (if any) to assign at higher levels.
> Allow the third number (the tic level) in the "set tics" specification
> to be a real number instead of an integer. There would still be two tic
> length settings, one for major, the other for minor tics, and the actual
> length of a tic would be calculated by interpolating between the two
> pre-set lengths (tic_len = tic_level * (minor - major) + major).
Sounds too complicated.
> Any tic level that is not 1 could have labels.
Yes - this. Want to send a patch?
Ethan
|
|
From: Juhász P. <pet...@gm...> - 2013-06-28 21:03:22
|
On Fri, 2013-06-28 at 11:12 -0700, Ethan Merritt wrote:
> On Friday, 28 June 2013, Juhász Péter wrote:
[...]
>
> Another option is to relax the restriction that tic levels can only be
> "major" (level 0) and "minor" (level 1). The code already tracks tic level
> as an integer but ignores requests for tic level 2 or 3 etc. It should be
> easy to modify the code that so that you can add labels using
> set xtics add ("Level 2" 2 2)
> I'm not sure what length tic (if any) to assign at higher levels.
I think the goal is to have minor tics that nevertheless could have
labels.
>
> > Allow the third number (the tic level) in the "set tics" specification
> > to be a real number instead of an integer. There would still be two tic
> > length settings, one for major, the other for minor tics, and the actual
> > length of a tic would be calculated by interpolating between the two
> > pre-set lengths (tic_len = tic_level * (minor - major) + major).
>
> Sounds too complicated.
>
> > Any tic level that is not 1 could have labels.
>
> Yes - this. Want to send a patch?
I'll try, but of course it's more complicated than it first appeared.
The xtick2d_... etc. callback functions test the text pointer being null
to distinguish between minor and major tics. To break this coupling,
they need to get the tic level as a separate parameter. I'll do it
tomorrow.
Peter
>
> Ethan
|