Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #3718 > unrolled thread
| Started by | Kevin Buchs <kevin.buchs@gmail.com> |
|---|---|
| First post | 2017-08-21 15:34 -0700 |
| Last post | 2017-08-22 09:27 -0700 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.graphics.apps.gnuplot
Few problems using GnuPlot 5.0 on Mac OS X Kevin Buchs <kevin.buchs@gmail.com> - 2017-08-21 15:34 -0700
Re: Few problems using GnuPlot 5.0 on Mac OS X Ethan A Merritt <EAMerritt@gmail.com> - 2017-08-21 22:47 -0700
Re: Few problems using GnuPlot 5.0 on Mac OS X Kevin Buchs <kevin.buchs@gmail.com> - 2017-08-22 07:11 -0700
Re: Few problems using GnuPlot 5.0 on Mac OS X Ethan A Merritt <EAMerritt@gmail.com> - 2017-08-22 09:27 -0700
| From | Kevin Buchs <kevin.buchs@gmail.com> |
|---|---|
| Date | 2017-08-21 15:34 -0700 |
| Subject | Few problems using GnuPlot 5.0 on Mac OS X |
| Message-ID | <cdf9e487-7206-4ac4-a4d1-c732fd2e6c34@googlegroups.com> |
I have tried gnuplot for a plotting need in the past, but found the overhead for the task I wanted to accomplish way too high. Still, I see people touting the application, so today I decided to go all in and figure out how to make it do what I wanted. I downloaded the source for 5.0.7 and the accompanying manual. I built it on OS X 10.12.5 with Gnu toolchain (./configure;make;make install) and took off. I wanted a vertical bar chart, with text labels overlaying the bars. Starting from several examples and the manual, along with a lot of hacking, I have what I want, sort of. However, along the way, I found numerous items that didn't work as documented. Maybe someone can help me determine if this is me, if what I don't know about gnuplot is lacking or if there are some opportunities for improvement. Here is my script. 8><---------------------------------------------------------------------------------- # I had to amend my data by adding 4th and 5th columns to control the label position and rotation. $Data <<EOD 1 13 "Abcd NOC Handling" 50 -90 2 43 "Abcd T3 Team for SLI" 50 -90 3 12 "Abcd BBNOC" 50 -90 4 53 "Abcd Efghij Support" 50 -90 5 21 "Efghij Response Time" 50 -90 6 47 "Efghij replicating problem" 50 -90 7 11 "Efghij workaround to staging" 50 -90 8 43 "Abcd/Jari verify staging" 50 -90 9 86 "Efghij workaround to production" 50 -90 10 5 "Abcd confirmation/resolution" 50 -90 EOD set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350 set title "Time for Major Steps In P1 Resolution" set style fill solid 1.0 set style textbox opaque noborder unset key set boxwidth 0.75 abs set bmargin at screen 0.1 set tmargin at screen 0.9 set angle degrees unset xtics set yrange [0:100] set ylabel "Seconds" set label right # does not work - seems to be stuck at center set output "p1-times.png" # Fails to rotate # set label rotate by 90 # plot $Data using 1:2:3 with labels # like to be able to insert constant values instead of columns 4 and 5, but how? plot $Data using 1:2 with boxes, '' using 1:4:3:5 with labels rotate variable ## set terminal aqua ## doesn't appear in list but in the manual ## ## (after I installed the aquaterm application). 8><---------------------------------------------------------------------------------- All my questions/problems are in-line, but just to reiterate 1) Right justification for the labels failed to work 2) Setting fixed rotation for the labels didn't work 3) Since I needed to specify a fixed y-value for my labels as well as their rotation, I thought it would be nice to be able to specify constant values instead of having to amend my data, but I could not determine how to do this. 4) I was seeking a rapid REPL since I tried about a thousand variations. I thought maybe the Tkcanvas or aquaterm would give me that, but didn't work. Perhaps those have to be present/specified at build time. Is there a better REPL? BTW, the data above is the extent of what I was working with. I probably could have drawn this by hand in a time much shorter than the 3 hours I spent on it. Steep learning curve.
[toc] | [next] | [standalone]
| From | Ethan A Merritt <EAMerritt@gmail.com> |
|---|---|
| Date | 2017-08-21 22:47 -0700 |
| Message-ID | <ongg9l$3dv$1@dont-email.me> |
| In reply to | #3718 |
Kevin Buchs wrote:
> I have tried gnuplot for a plotting need in the past, but found the
> overhead for the task I wanted to accomplish way too high. Still, I
> see people touting the application, so today I decided to go all in
> and figure out how to make it do what I wanted. I downloaded the
> source for 5.0.7 and the accompanying manual. I built it on OS X
> 10.12.5 with Gnu toolchain (./configure;make;make install) and took
> off.
>
> I wanted a vertical bar chart, with text labels overlaying the bars.
> Starting from several examples and the manual, along with a lot of
> hacking, I have what I want, sort of. However, along the way, I found
> numerous items that didn't work as documented. Maybe someone can help
> me determine if this is me, if what I don't know about gnuplot is
> lacking or if there are some opportunities for improvement.
>
> Here is my script.
>
> 8><----------------------------------------------------------------------------------
> # I had to amend my data by adding 4th and 5th columns to control the
> # label position and rotation.
>
> $Data <<EOD
> 1 13 "Abcd NOC Handling" 50 -90
> 2 43 "Abcd T3 Team for SLI" 50 -90
> 3 12 "Abcd BBNOC" 50 -90
> 4 53 "Abcd Efghij Support" 50 -90
> 5 21 "Efghij Response Time" 50 -90
> 6 47 "Efghij replicating problem" 50 -90
> 7 11 "Efghij workaround to staging" 50 -90
> 8 43 "Abcd/Jari verify staging" 50 -90
> 9 86 "Efghij workaround to production" 50 -90
> 10 5 "Abcd confirmation/resolution" 50 -90
> EOD
>
> set terminal pngcairo transparent enhanced font "arial,10" fontscale
> 1.0 size 500, 350 set title "Time for Major Steps In P1 Resolution"
> set style fill solid 1.0
> set style textbox opaque noborder
> unset key
> set boxwidth 0.75 abs
> set bmargin at screen 0.1
> set tmargin at screen 0.9
> set angle degrees
> unset xtics
> set yrange [0:100]
> set ylabel "Seconds"
>
> set label right # does not work - seems to be stuck at cente
> # Fails to rotate
> # set label rotate by 90
> # plot $Data using 1:2:3 with labels
"set label" defines a single label; it does not set any sort of default
for future labels. Since your label command contains neither a label number
nor a text string, it has no effect at all.
What you want, I think, is
plot $Data using 1:2:3 with labels rotate by 90
See also online demo:
http://gnuplot.sourceforge.net/demo_5.0/rotate_labels.html
>
> # like to be able to insert constant values instead of columns 4 and
> # 5, but how?
A using specifier can contain any expression, including a constant expression,
if given in parentheses. So
plot $Data using 1:2:3:(4.44):(5.55) ...
> plot $Data using 1:2 with boxes, '' using 1:4:3:5 with labels rotate
> variable
Works here.
>
>
> ## set terminal aqua ## doesn't appear in list but in the manual
> ## ## (after I installed the aquaterm application).
> 8><----------------------------------------------------------------------------------
>
> All my questions/problems are in-line, but just to reiterate
> 1) Right justification for the labels failed to work
You have not shown an example, so I don't know what went wrong.
Maybe the same error you show with rotation? right-justify isn't a default
that you set for future labels, it is a property that must be given as part of
each individual label command (or plot).
> 2) Setting fixed rotation for the labels didn't work
See above.
> 3) Since I needed to specify a fixed y-value for my labels as well as
> their rotation, I thought it would be nice to be able to specify
> constant values instead of having to amend my data, but I could not
> determine how to do this.
Put the constant in parentheses
> 4) I was seeking a rapid REPL since I tried
> about a thousand variations. I thought maybe the Tkcanvas or aquaterm
> would give me that, but didn't work. Perhaps those have to be
> present/specified at build time. Is there a better REPL?
The aqua terminal is an external program that does not support all
gnuplot commands. I suggest sticking with one of the cairo terminals
until you get the plot working. Then if you want you can see whether
it also works with the aqua terminal, but no guarantees there.
> BTW, the data above is the extent of what I was working with. I
> probably could have drawn this by hand in a time much shorter than the
> 3 hours I spent on it. Steep learning curve.
Have you looked through the online demo collection?
If you find a plot that looks more or less like you want, you can
use the sample commands as a starting point.
http://gnuplot.sourceforge.net/demo_5.0/
Ethan
[toc] | [prev] | [next] | [standalone]
| From | Kevin Buchs <kevin.buchs@gmail.com> |
|---|---|
| Date | 2017-08-22 07:11 -0700 |
| Message-ID | <c95b6052-9ca6-4a7c-b0d5-9569c0cc8cc5@googlegroups.com> |
| In reply to | #3720 |
Ethan, Thanks for the reply and setting me straight. The example of rotation you directed me toward indeed only pulls the rotation angle from the data. It sure is misleading that the manual only documents "label rotate xyz" and "label right" in the context of set. That really implies it is a global setting because so many other "set" values are global (through the next plot at least). I argue that rotation and justification should at least be sticky for the next plot command. The use of parentheses in the context of "using" is a fairly well kept secret. I found it in the manual in a single phrase of a sentence. I looked at dozens of examples and spent a lot of time with the manual. I suppose the major reason for posting is to identify the opportunity to improve. You probably didn't understand what I meant by REPL (https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop). It would be nice to see the plot interactively while in gnuplot's interactive interface. After being frustrated with that, I finally scripted my inputs and ran a compound command from a commandline to run gnuplot and then open the png file. Here is what I ended up with: 8><---------------------------------------------------------------------------------- $Data <<EOD 1 13 "Abcd NOC Handling" 2 43 "Abcd T3 Team for SLI" 3 12 "Abcd BBNOC" 4 53 "Abcd Efghij Support" 5 21 "Efghij Response Time" 6 47 "Efghij replicating problem" 7 11 "Efghij workaround to staging" 8 43 "Abcd/Jari verify staging" 9 86 "Efghij workaround to production" 10 5 "Abcd confirmation/resolution" EOD set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350 set title "Time for Major Steps In P1 Resolution" set style fill solid 1.0 set style textbox opaque noborder unset key set boxwidth 0.75 abs set bmargin at screen 0.1 set tmargin at screen 0.9 set angle degrees unset xtics set yrange [0:100] set ylabel "Seconds" set output "p1-times.png" plot $Data using 1:2 with boxes, '' using 1:(2):3:(-90) with labels rotate variable right 8><----------------------------------------------------------------------------------
[toc] | [prev] | [next] | [standalone]
| From | Ethan A Merritt <EAMerritt@gmail.com> |
|---|---|
| Date | 2017-08-22 09:27 -0700 |
| Message-ID | <onhlp4$m4f$1@dont-email.me> |
| In reply to | #3721 |
Kevin Buchs wrote:
> Ethan,
>
> Thanks for the reply and setting me straight.
>
> The example of rotation you directed me toward indeed only pulls the
> rotation angle from the data.
>
> It sure is misleading that the manual only documents "label rotate
> xyz" and "label right" in the context of set. That really implies it
> is a global setting because so many other "set" values are global
> (through the next plot at least). I argue that rotation and
> justification should at least be sticky for the next plot command.
They are sticky, but the stickiness is more fine-grained.
Try thinking of the command not as "set label" but as "set label N".
It permanently changes the properties of an object (label N) for
all future plots that it appears in. So
set label 4 "I am the fourth label" font "Times"
set label 4 at 0, sin(pi/2)
plot sin(x)
# Now that I see the plot I hate that font!
set label 4 font "Arial"
replot
# That's better, but let's try right justification
set label 4 right
replot
If you want to change some property for many labels in parallel,
one option is
set for [N=1:100] label N rotate by -45
Note that until you assign a text and location for a label it will
not appear in a plot.
Other set commands work the same way:
set linetype 3 <whatever>
set object 4 circle <circle properties>
set arrow 2 <arrow properties>
>The use of parentheses in the context of "using" is a fairly well kept
> secret. I found it in the manual in a single phrase of a sentence.
Hmm. Good to know. We can try to make it easier to find in the docs.
> I looked at dozens of examples and spent a lot of time with the
> manual. I suppose the major reason for posting is to identify the
> opportunity to improve.
>
> You probably didn't understand what I meant by REPL
> (https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop).
> It would be nice to see the plot interactively while in gnuplot's
> interactive interface. After being frustrated with that, I finally
> scripted my inputs and ran a compound command from a commandline to
> run gnuplot and then open the png file.
Could it be that you are looking for the "replot" command?
Coincidentally, you could type this as "repl" :-)
1) Choose an interactive terminal (x11, wxt, qt, domterm, sixel).
2) Issue your plot command
3) tweak any of the setting for fonts, linetypes, margins, etc
4) "replot"
5) rinse and repeat
6) when you are happy with the plot, either use a menu button to
save to file (wxt qt win) or change the terminal type and
again "replot". E.g.
set term pdf
set output 'final_version.pdf'
replot
> Here is what I ended up with:
>
>
> 8><----------------------------------------------------------------------------------
> $Data <<EOD
> 1 13 "Abcd NOC Handling"
> 2 43 "Abcd T3 Team for SLI"
> 3 12 "Abcd BBNOC"
> 4 53 "Abcd Efghij Support"
> 5 21 "Efghij Response Time"
> 6 47 "Efghij replicating problem"
> 7 11 "Efghij workaround to staging"
> 8 43 "Abcd/Jari verify staging"
> 9 86 "Efghij workaround to production"
> 10 5 "Abcd confirmation/resolution"
> EOD
>
> set terminal pngcairo transparent enhanced font "arial,10" fontscale
> 1.0 size 500, 350 set title "Time for Major Steps In P1 Resolution"
> set style fill solid 1.0
> set style textbox opaque noborder
> unset key
> set boxwidth 0.75 abs
> set bmargin at screen 0.1
> set tmargin at screen 0.9
> set angle degrees
> unset xtics
> set yrange [0:100]
> set ylabel "Seconds"
>
> set output "p1-times.png"
>
> plot $Data using 1:2 with boxes, '' using 1:(2):3:(-90) with labels
> rotate variable right
> 8><----------------------------------------------------------------------------------
[toc] | [prev] | [standalone]
Back to top | Article view | comp.graphics.apps.gnuplot
csiph-web