mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-06-24 06:41:13 +08:00
more guide plots
This commit is contained in:
parent
940d862a4a
commit
e257640b0a
1760
guide/guide-15.svg
1760
guide/guide-15.svg
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 91 KiB |
2021
guide/guide-16.svg
2021
guide/guide-16.svg
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 99 KiB |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 58 KiB |
@ -117,9 +117,9 @@ perl -nE '$thdeg = $_/100.*360.;
|
||||
$s = sin($th);
|
||||
$c = cos($th);
|
||||
say "$c $s $thdeg";' | \
|
||||
feedgnuplot --lines --points --domain --square \
|
||||
feedgnuplot --domain --square \
|
||||
--tuplesizeall 3 \
|
||||
--styleall 'with points palette'
|
||||
--styleall 'with linespoints palette'
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
@ -281,6 +281,9 @@ feedgnuplot --dataid \
|
||||
#+RESULTS:
|
||||
[[file:guide-10.svg]]
|
||||
|
||||
Here we used =--set= to set the range of the colorbar. =--set= (and =--unset=)
|
||||
map to the gnuplot =set= (and =--unset=) command.
|
||||
|
||||
** Error bars
|
||||
As before, the =gnuplot= documentation has the styling details:
|
||||
|
||||
@ -388,3 +391,63 @@ feedgnuplot --domain \
|
||||
|
||||
#+RESULTS:
|
||||
[[file:guide-14.svg]]
|
||||
|
||||
** 3D plots
|
||||
We can plot in 3D by passing =--3d=. When plotting interactively, you can use
|
||||
the mouse to rotate the plot, and look at it from different directions.
|
||||
Otherwise, the viewing angle can be set with =--set 'view ...'=. See
|
||||
|
||||
#+BEGIN_SRC sh :results none :exports code
|
||||
gnuplot -e 'help set view'
|
||||
#+END_SRC
|
||||
|
||||
Unlike 2D plots, 3D plots have a 2-dimensional domain, and =--domain= is
|
||||
/required/. So each line is interpreted =x y z0 z1 z2...=.
|
||||
|
||||
A double-helix with variable color and variable pointsize
|
||||
|
||||
#+BEGIN_SRC sh :results file link :exports both
|
||||
seq 200 | \
|
||||
perl -nE '$, = " ";
|
||||
$th = $_/10;
|
||||
$z = $_/40;
|
||||
$c = cos($th);
|
||||
$s = sin($th);
|
||||
$size = 0.5 + abs($c);
|
||||
$color = $z;
|
||||
say $c, $s, 0, $z, $size, $color;
|
||||
say -$c, -$s, 1, $z, $size, $color;' | \
|
||||
feedgnuplot --domain --dataid --3d \
|
||||
--with 'points pointsize variable pointtype 7 palette' \
|
||||
--tuplesizeall 5 \
|
||||
--title "Double helix" \
|
||||
--squarexy
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
[[file:guide-15.svg]]
|
||||
|
||||
** Histograms
|
||||
=gnuplot= (and =feedgnuplot=) has support for histograms. So we can give it
|
||||
data, and have it bin it for us. Pre-sorting the data is unnecessary. Let's look
|
||||
at the central limit theorem: we look at the distribution of sums of 10 uniform
|
||||
samples in [-1,1]: it should be normal-ish. And let's draw the expected perfect
|
||||
PDF on top (as an equation, evaluated by =gnuplot=).
|
||||
|
||||
#+BEGIN_SRC sh :results file link :exports both
|
||||
N=1000;
|
||||
Nsum=200;
|
||||
var=$((Nsum/3));
|
||||
binwidth=0.2;
|
||||
seq $N | \
|
||||
perl -nE '$Nsum = '$Nsum';
|
||||
$s = 0; for $i (1..$Nsum) { $s += rand()*2-1; }
|
||||
say $s;' | \
|
||||
feedgnuplot --histo 0 --binwidth $binwidth \
|
||||
--equation-above "($N * sqrt(2.*pi*$var) * erf($binwidth/(2.*sqrt(2.*$var)))) * \
|
||||
exp(-(x*x)/(2.*$var)) / \
|
||||
sqrt(2.*pi*$var) title \"Limit gaussian\" with lines lw 2"
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
[[file:guide-16.svg]]
|
||||
|
Loading…
Reference in New Issue
Block a user