|
From: theozh <th...@gm...> - 2018-10-28 11:53:48
|
It should be a rather simple task, but I have several problems (using gnuplot 5.2rc4, Win7) Imagine the following data: $Data <<EOD xxxx ColA ColB ColC ColD Row1 1.10 1.20 1.30 1.40 Row2 2.10 2.20 2.30 2.40 Row3 3.10 3.20 3.30 3.40 Row4 4.10 4.20 4.30 4.40 EOD The tasks and questions are: 1. plot circles with size which correspond to the datanumber and at a position which correspond to the number of col and row of datafield 2. take ytics from the first column 3. take xtics from the first row 4. the number of columns can depend on the datafile. How to autmatically account for this? 5. how to adjust the right xrange and yrange (i.e., such that the Row1 and Row2 ytics are not at the very edge of the graph. ad 1. ok ad 2. ok ad 3. how do I put columnheader not as key but as xtics? Had no success with columnhead(x) ad 4. if I use plot for [i=2:*] $Data... gnuplot get's stuck and does not respond anymore. Why? How to solve? ad 5. maybe there is a way without doing stats $Data first? I tried with the code below. Thank you for hints. ### gnuplot code reset session $Data <<EOD xxxx ColA ColB ColC ColD Row1 1.10 1.20 1.30 1.40 Row2 2.10 2.20 2.30 2.40 Row3 3.10 3.20 3.30 3.40 Row4 4.10 4.20 4.30 4.40 EOD stats $Data u 0 nooutput set yrange[STATS_min-0.5:STATS_max-0.5] plot for [i=2:5] $Data u (i-2):0:(column(i)/10.):ytic(1) every ::1 with circles notitle ### end code |
|
From: theozh <th...@gm...> - 2018-10-28 18:24:25
|
... in the meantime I think I have found a way to display the columnheaders as xtics.
A pretty strange workaround, and I am pretty sure there must be a simpler way.
Still, the issue with
plot for [i=2:*] $Data u ...
remains. Gnuplot will be blocked...
# put the columnheaders into xtics
...
set xtics ("" 0) # remove all tics
set table $Nowhere
do for [i=2:5] {
plot $Data u (head=stringcolumn(i),0) every ::0::0 with table
set xtics add (head i-2)
}
unset table
...
###
|
|
From: Ethan A M. <eam...@gm...> - 2018-10-28 20:09:01
|
On Sunday, 28 October 2018 12:53:35 theozh wrote:
> It should be a rather simple task, but I have several problems (using gnuplot 5.2rc4, Win7)
> Imagine the following data:
>
$Data <<EOD
xxxx ColA ColB ColC ColD
Row1 1.10 1.20 1.30 1.40
Row2 2.10 2.20 2.30 2.40
Row3 3.10 3.20 3.30 3.40
Row4 4.10 4.20 4.30 4.40
EOD
>
> The tasks and questions are:
> 1. plot circles with size which correspond to the datanumber and at a position which correspond to the number of col and row of datafield
So you want column# for x and row# for y?
set key autotitle columnhead # Tells gnuplot the first row is not data
unset key # But we aren't really using it for the key
set xrange [0:5]; set yrange [0:5]
plot for [j=2:5] $Data using (real(j-1)):($0+1):(column(j)/10.) with circles
> 2. take ytics from the first column
Same plot command but add :ytic(1)
> 3. take xtics from the first row
Same plot but add :xtic(columnhead(j))
> 4. the number of columns can depend on the datafile. How to autmatically account for this?
set key autotitle columnhead
unset key
set style data circles
set xrange [0:5]; set yrange [0:5]
plot for [j=2:*] $Data using (real(j-1)) \
: (column(0)+1) \
: (column(j)/10.) \
: ytic(1) \
: xtic(columnhead(j))
> 5. how to adjust the right xrange and yrange (i.e., such that the Row1 and Row2 ytics are not at the very edge of the graph.
>
> ad 1. ok
> ad 2. ok
> ad 3. how do I put columnheader not as key but as xtics? Had no success with columnhead(x)
> ad 4. if I use plot for [i=2:*] $Data... gnuplot get's stuck and does not respond anymore. Why? How to solve?
That was a bug in the original 5.2 release. Fixed in 5.2.1
If you are stuck with 5.2.0 then a work-around would be to determine
the number of columns first and use that explicitly rather than using *.
Ethan
> ad 5. maybe there is a way without doing stats $Data first?
>
> I tried with the code below. Thank you for hints.
>
>
> ### gnuplot code
> reset session
>
> $Data <<EOD
> xxxx ColA ColB ColC ColD
> Row1 1.10 1.20 1.30 1.40
> Row2 2.10 2.20 2.30 2.40
> Row3 3.10 3.20 3.30 3.40
> Row4 4.10 4.20 4.30 4.40
> EOD
>
> stats $Data u 0 nooutput
> set yrange[STATS_min-0.5:STATS_max-0.5]
>
> plot for [i=2:5] $Data u (i-2):0:(column(i)/10.):ytic(1) every ::1 with circles notitle
> ### end code
|
|
From: theozh <th...@gm...> - 2018-10-28 20:54:30
|
Thank you for your suggestions. >> ad 4. if I use plot for [i=2:*] $Data... gnuplot get's stuck and does not respond anymore. Why? How to solve? > > That was a bug in the original 5.2 release. Fixed in 5.2.1 > If you are stuck with 5.2.0 then a work-around would be to determine > the number of columns first and use that explicitly rather than using *. > I just downloaded gnuplot 5.2.5 ... same issue! gnuplot blocked... when using plot for [i=2:*] ... How would you actually determine the number of columns of a datafile? |
|
From: theozh <th...@gm...> - 2018-10-28 22:19:30
|
ok... you can get get the number of columns via stats $Data and STATS_columns.
The following code does what I intended to do.
(as long as there is only one headerline...)
### gnuplot code
reset session
$Data <<EOD
xxxx ColA ColB ColC ColD
Row1 1.10 1.20 1.30 1.40
Row2 2.10 2.20 2.30 2.40
Row3 3.10 3.20 3.30 3.40
Row4 4.10 4.20 4.30 4.40
EOD
stats $Data u 0 nooutput
ColCount = STATS_columns
RowCount = STATS_records
set xrange[-0.5:ColCount-1.5]
set yrange[-0.5:RowCount-1.5]
plot for [j=2:ColCount] \
$Data using (j-2) \
: ($0-1) \
: (column(j)/10.) \
: ytic(1) \
: xtic(columnhead(j)) with circles notitle,\
for [j=2:ColCount] \
$Data using (j-2):($0-1):(stringcolumn(j)) with labels notitle
### end code
|
|
From: Ethan A M. <eam...@gm...> - 2018-10-29 00:55:47
|
On Sunday, 28 October 2018 21:54:21 theozh wrote: > Thank you for your suggestions. > >> ad 4. if I use plot for [i=2:*] $Data... gnuplot get's stuck and does not respond anymore. Why? How to solve? > > > > That was a bug in the original 5.2 release. Fixed in 5.2.1 > > If you are stuck with 5.2.0 then a work-around would be to determine > > the number of columns first and use that explicitly rather than using *. > > > I just downloaded gnuplot 5.2.5 ... same issue! gnuplot blocked... when using plot for [i=2:*] ... That is strange unexpected. Are you sure you ran the new executable rather than the old one? When I run that series of commands on 5.2.5 I get a plot and no errors. When I run it on 5.2.2 or 5.2.3 I get the correct plot but it prints an informational message: Ending * iteration at 5 Ethan |
|
From: theozh <th...@gm...> - 2018-10-29 07:08:14
|
> > That is strange unexpected. > Are you sure you ran the new executable rather than the old one? > Strange. I was pretty sure I was running 5.2.5, it showed: Version 5.2 patchlevel 5 last modified 2018-10-06 Maybe, I had some other strange/special prior settings. If I can reproduce, I will post. Anyway, seems to work now :-) Thanks! |