├── .gitignore
├── .idea
├── .gitignore
├── turtles.iml
├── vcs.xml
└── misc.xml
├── gnuplot
├── demo
│ ├── histopt.dat
│ ├── line.fnc
│ ├── steps.dat
│ ├── bldg.png
│ ├── demo.edf
│ ├── lena.rgb
│ ├── sine.bin
│ ├── using.bin
│ ├── blutux.rgb
│ ├── epslatex.dem
│ ├── fontfile.dem
│ ├── scatter2.bin
│ ├── fontfile_latex.dem
│ ├── lena-keypoints.bin
│ ├── ellipses.dat
│ ├── clip14in.dat
│ ├── histerror.dat
│ ├── gnu-valley
│ ├── empty-circles.dat
│ ├── gnuplot.cfg
│ ├── sound.par
│ ├── sound2.par
│ ├── candlesticks.dat
│ ├── big_peak.dat
│ ├── start.par
│ ├── borders.dem
│ ├── volatile.dem
│ ├── bolditalic.dem
│ ├── gen-random.inc
│ ├── named_var.dem
│ ├── nokey.dem
│ ├── multipalette.dem
│ ├── colorwheel.dem
│ ├── rugplot.dem
│ ├── nonlinear6.dem
│ ├── molecule.dem
│ ├── monotonic_spline.dem
│ ├── special_chars.dem
│ ├── binary.dem
│ ├── discrete.dem
│ ├── timedat.dat
│ ├── kdensity2d.dem
│ ├── table.dat
│ ├── break_continue.dem
│ ├── cities.dem
│ ├── controls.dem
│ ├── rotate_labels.dem
│ ├── battery.dat
│ ├── colorscheme.dem
│ ├── optimize.dat
│ ├── textbox.dem
│ ├── triangle.dat
│ ├── arrowstyle.dat
│ ├── density.fnc
│ ├── using.dem
│ ├── multiaxis.dem
│ ├── ctg-y2.dat
│ ├── macros.dem
│ ├── azimuth.dem
│ ├── hypertext.dem
│ ├── nonlinear5.dem
│ ├── 1.dat
│ ├── 2.dat
│ ├── 3.dat
│ ├── bins.dem
│ ├── mouselabels.dem
│ ├── ttics.dem
│ ├── ellipse.dem
│ ├── asciimat.dat
│ ├── pm3dgamma.dem
│ ├── barchart_art.dem
│ ├── fillbetween.dem
│ ├── textrotate.dem
│ ├── matrix_index.dem
│ ├── mouselab_1.dem
│ ├── tics.dem
│ ├── world2.dem
│ ├── animate.dem
│ ├── nonlinear3.dem
│ ├── hexa.fnc
│ ├── nonlinear4.dem
│ ├── srl.dat
│ ├── zerror.dem
│ ├── reflect.fnc
│ ├── probably_tux.dem
│ ├── rgbalpha.dem
│ ├── hidden.dem
│ ├── rgba_lines.dem
│ ├── simple.dem
│ ├── matrix_every.dem
│ ├── mouselab_2.dem
│ ├── boxclusters.dem
│ ├── approximate.dem
│ ├── immigration.dat
│ ├── candlesticks.dem
│ ├── linkedaxes.dem
│ ├── steps.dem
│ ├── transparent.dem
│ ├── polar.dem
│ ├── running_avg.dem
│ ├── nonlinear1.dem
│ ├── scatter.dem
│ ├── animate2.dem
│ ├── stats.dem
│ ├── gnuplot.rot
│ ├── callargs.dem
│ ├── arrowstyle.dem
│ ├── pm3d_lighting.dem
│ ├── transparent_solids.dem
│ ├── dashtypes.dem
│ ├── gantt.dem
│ ├── fillstyle.dem
│ ├── smooth_splines.dem
│ ├── margins.dem
│ ├── smooth.dem
│ ├── param.dem
│ ├── enhancedtext.dem
│ ├── enhanced_utf8.dem
│ ├── fenceplot.dem
│ ├── silver.dat
│ ├── pointsize.dem
│ ├── rectangle.dem
│ ├── mousevariables.dem
│ ├── nonlinear2.dem
│ ├── charset.dem
│ ├── ellipses_style.dem
│ ├── dgrid3d.dem
│ ├── piecewise.dem
│ ├── parallel.dem
│ ├── lcdemo.dat
│ ├── surface2.dem
│ ├── custom_key.dem
│ ├── world.dem
│ ├── armillary.dem
│ ├── errorbars.dem
│ ├── histograms2.dem
│ ├── cerf.dem
│ ├── electron.dem
│ ├── iterate.dem
│ ├── textcolor.dem
│ ├── orbits.dem
│ ├── scatter2.dat
│ ├── fillcrvs.dem
│ ├── autoscale.dem
│ ├── clipobject.dem
│ ├── hidden2.dem
│ ├── imageNaN.dem
│ ├── solar_params.dem
│ ├── vector.dem
│ ├── array.dem
│ └── rgb_variable.dat
├── docs
│ ├── gnuplot.pdf
│ └── psdoc
│ │ └── ps_guide.ps
└── share
│ ├── colors_mono.gp
│ ├── colors_podo.gp
│ ├── colors_default.gp
│ └── gnuplotrc
├── ovf1.pdf
├── ovf2.pdf
├── img
├── sin1.png
├── step.png
├── demo1.jpg
├── salute.png
├── salute2.png
├── sin1_noise.png
├── sin1_sin10.png
├── step_noise.png
├── adaptive_filter.png
├── sin1_shiftPhase.png
├── sin1_sin10_noise.png
├── sin_phase_shift.png
├── half_sin1_half_sin3.png
├── fft vs my stransform.png
├── sins_near_frequencies.png
├── sin_phase_shift_trScale.png
├── sins_two_requenses_half.png
├── sins_two_requenses_half_trScale.png
└── comparison_of_two_different_implementation_of_DFT.png
├── settings.h
├── README.md
├── AnyRandomGraph.cpp
├── machine_epsilon.cpp
├── besselsFunction.cpp
├── schrodinger_equation.cpp
├── interpolationPolinom.cpp
├── Matrix.hpp
├── gnuplot.h
└── sweepMethod.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | # Project exclude paths
2 | /cmake-build-debug/
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/gnuplot/demo/histopt.dat:
--------------------------------------------------------------------------------
1 | ClassA ClassB
2 | 1 7
3 | 3 4
4 | 4 2
5 | 3.5 3
6 |
--------------------------------------------------------------------------------
/gnuplot/demo/line.fnc:
--------------------------------------------------------------------------------
1 | #
2 | # a straight line
3 | #
4 |
5 | l(x) = y0 + m*x
6 |
--------------------------------------------------------------------------------
/ovf1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/ovf1.pdf
--------------------------------------------------------------------------------
/ovf2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/ovf2.pdf
--------------------------------------------------------------------------------
/img/sin1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin1.png
--------------------------------------------------------------------------------
/img/step.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/step.png
--------------------------------------------------------------------------------
/gnuplot/demo/steps.dat:
--------------------------------------------------------------------------------
1 | 1 2
2 | 3 5
3 | 5 6.1
4 | 6.5 7.4
5 | 10.0 11.0
6 |
--------------------------------------------------------------------------------
/img/demo1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/demo1.jpg
--------------------------------------------------------------------------------
/img/salute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/salute.png
--------------------------------------------------------------------------------
/img/salute2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/salute2.png
--------------------------------------------------------------------------------
/img/sin1_noise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin1_noise.png
--------------------------------------------------------------------------------
/img/sin1_sin10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin1_sin10.png
--------------------------------------------------------------------------------
/img/step_noise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/step_noise.png
--------------------------------------------------------------------------------
/gnuplot/demo/bldg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/bldg.png
--------------------------------------------------------------------------------
/gnuplot/demo/demo.edf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/demo.edf
--------------------------------------------------------------------------------
/gnuplot/demo/lena.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/lena.rgb
--------------------------------------------------------------------------------
/gnuplot/demo/sine.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/sine.bin
--------------------------------------------------------------------------------
/gnuplot/demo/using.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/using.bin
--------------------------------------------------------------------------------
/gnuplot/demo/blutux.rgb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/blutux.rgb
--------------------------------------------------------------------------------
/gnuplot/docs/gnuplot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/docs/gnuplot.pdf
--------------------------------------------------------------------------------
/img/adaptive_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/adaptive_filter.png
--------------------------------------------------------------------------------
/img/sin1_shiftPhase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin1_shiftPhase.png
--------------------------------------------------------------------------------
/img/sin1_sin10_noise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin1_sin10_noise.png
--------------------------------------------------------------------------------
/img/sin_phase_shift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin_phase_shift.png
--------------------------------------------------------------------------------
/.idea/turtles.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/gnuplot/demo/epslatex.dem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/epslatex.dem
--------------------------------------------------------------------------------
/gnuplot/demo/fontfile.dem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/fontfile.dem
--------------------------------------------------------------------------------
/gnuplot/demo/scatter2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/scatter2.bin
--------------------------------------------------------------------------------
/img/half_sin1_half_sin3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/half_sin1_half_sin3.png
--------------------------------------------------------------------------------
/img/fft vs my stransform.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/fft vs my stransform.png
--------------------------------------------------------------------------------
/img/sins_near_frequencies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sins_near_frequencies.png
--------------------------------------------------------------------------------
/gnuplot/demo/fontfile_latex.dem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/fontfile_latex.dem
--------------------------------------------------------------------------------
/gnuplot/demo/lena-keypoints.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/demo/lena-keypoints.bin
--------------------------------------------------------------------------------
/gnuplot/docs/psdoc/ps_guide.ps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/gnuplot/docs/psdoc/ps_guide.ps
--------------------------------------------------------------------------------
/img/sin_phase_shift_trScale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sin_phase_shift_trScale.png
--------------------------------------------------------------------------------
/img/sins_two_requenses_half.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sins_two_requenses_half.png
--------------------------------------------------------------------------------
/gnuplot/demo/ellipses.dat:
--------------------------------------------------------------------------------
1 | 0 0 5 4 0 1 0xbcde43
2 | 5 5 6 10 30 2 0x785678
3 | 0 10 10 6 60 3 0x235698
4 | 10 0 3 7 84 4 0x12fdad
5 |
--------------------------------------------------------------------------------
/img/sins_two_requenses_half_trScale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/sins_two_requenses_half_trScale.png
--------------------------------------------------------------------------------
/gnuplot/demo/clip14in.dat:
--------------------------------------------------------------------------------
1 | # demo for set pm3d [clip1in | clip4in]
2 |
3 | 0 1 1
4 | 1 1 2
5 | 2 1 3
6 |
7 | 0 2 1
8 | 1 2 2
9 | 2 2 3
10 |
--------------------------------------------------------------------------------
/gnuplot/demo/histerror.dat:
--------------------------------------------------------------------------------
1 | # histogram errorbars
2 | dummy set A err A set B err B
3 | 0 1 0.3 7 0.5
4 | 1 3 0.6 4 0.72
5 | 2 4 0.35 2 0.18
6 | 3 3.5 0.5 3 0.42
7 |
8 |
--------------------------------------------------------------------------------
/img/comparison_of_two_different_implementation_of_DFT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vectozavr/PhysicsSimulations/HEAD/img/comparison_of_two_different_implementation_of_DFT.png
--------------------------------------------------------------------------------
/gnuplot/demo/gnu-valley:
--------------------------------------------------------------------------------
1 | 0 0 10
2 | 0 1 10
3 | 0 2 10
4 |
5 | 1 0 10
6 | 1 1 5
7 | 1 2 10
8 |
9 | 2 0 10
10 | 2 1 1
11 | 2 2 10
12 |
13 | 3 0 10
14 | 3 1 0
15 | 3 2 10
16 |
--------------------------------------------------------------------------------
/gnuplot/demo/empty-circles.dat:
--------------------------------------------------------------------------------
1 | 15.8826 -15.9154 25.8660
2 | 13.9696 -34.7109 28.2968
3 | 49.8538 -4.7555 18.8980
4 | -8.5100 -40.5400 21.2788
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gnuplot/demo/gnuplot.cfg:
--------------------------------------------------------------------------------
1 | % LaTeX configuration file for usage with gnuplot-generated LaTeX files
2 | % (epslatex terminal with standalone option).
3 | % Here, used by epslatex.dem.
4 | \usepackage{exscale}
5 | \endinput
6 |
--------------------------------------------------------------------------------
/gnuplot/demo/sound.par:
--------------------------------------------------------------------------------
1 | #
2 | # Start parameters for the sound velocity fit
3 | #
4 | # HBB 970522: factored out 1e9 from c??, see hexa.fnc for details
5 |
6 | c33 = 9
7 | c11 = 6
8 | c44 = 1
9 | c13 = 4
10 | phi0 = 20.0
11 |
12 |
--------------------------------------------------------------------------------
/gnuplot/demo/sound2.par:
--------------------------------------------------------------------------------
1 | #
2 | # Start parameters for the sound velocity fit
3 | #
4 | # HBB 970522: factored out 1e9 from c??, see hexa.fnc for details
5 |
6 | c33 = 9
7 | c11 = 6
8 | c44 = 1 # FIXED
9 | c13 = 4 # FIXED
10 | phi0 = 0.0001
11 |
12 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gnuplot/demo/candlesticks.dat:
--------------------------------------------------------------------------------
1 | 1 1.5 2 2.4 4 6.
2 | 2 1.5 3 3.5 4 5.5
3 | 3 4.5 5 5.5 6 6.5
4 | 4 3.7 4.5 5.0 5.5 6.1
5 | 5 3.1 3.5 4.2 5 6.1
6 | 6 1 4 5.0 6 9
7 | 7 4 4 4.8 6 6.1
8 | 8 4 5 5.1 6 6.1
9 | 9 1.5 2 2.4 3 3.5
10 | 10 2.7 3 3.5 4 4.3
11 |
--------------------------------------------------------------------------------
/gnuplot/demo/big_peak.dat:
--------------------------------------------------------------------------------
1 | 26.500000 0.753252 0.012953
2 | 27.000000 0.877710 0.019712
3 | 27.500000 0.996531 0.021018
4 | 27.500000 0.940807 0.014499
5 | 28.000000 1.015178 0.021216
6 | 28.000000 0.984822 0.014840
7 | 28.500000 0.960538 0.020631
8 | 28.500000 0.930182 0.014416
9 | 29.000000 0.750650 0.018215
10 |
--------------------------------------------------------------------------------
/gnuplot/demo/start.par:
--------------------------------------------------------------------------------
1 | #
2 | # Start parameters for the fit of lcdemo.dat using density(x)
3 | #
4 |
5 | ml = -0.0005
6 | mh = -0.0005
7 | dens_Tc = 1.02
8 | Tc = 45.0
9 | g = 1.0
10 | b = 0.01002
11 |
12 |
--------------------------------------------------------------------------------
/settings.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ivan- on 10.02.2020.
3 | //
4 |
5 | #ifndef TURTLES_SETTINGS_H
6 | #define TURTLES_SETTINGS_H
7 |
8 | #define SCALE 2.7/100
9 | #define SCREEN_WIDTH 1920
10 | #define SCREEN_HEIGHT 1920
11 | #define PI 3.141592653589793238462
12 |
13 | #endif //TURTLES_SETTINGS_H
14 | //Привет, если ты это найдешь, напиши мне ;)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PhysicsSimulations
2 | Random physics simylations made with SFML library.
3 |
4 | 1. Simulation of turtles' motion: simple school problem.
5 | 
6 | 
7 |
--------------------------------------------------------------------------------
/gnuplot/demo/borders.dem:
--------------------------------------------------------------------------------
1 | unset grid
2 | set xrange [0:10]
3 | set yrange [0:10]
4 | set format ""
5 | #
6 | set multiplot layout 4, 4 title "Demonstration of different border settings"
7 | do for [bb = 0:15] {
8 | set border bb
9 | set label 1 sprintf("Border = %.0f",bb) at 5,5 center
10 | plot 1/0 notitle
11 | }
12 | unset multiplot
13 |
14 | pause -1 "Hit return to continue"
15 | reset
16 |
--------------------------------------------------------------------------------
/gnuplot/demo/volatile.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Unit test for "volatile" "skip" "refresh"
3 | # If the refreshed plot exactly overlies the original, it's good.
4 | #
5 | set title "Nothing interesting here, just a unit test for volatile, skip, and refresh"
6 | set style data lines
7 | set multiplot
8 | set tics tc "red"
9 | splot "whale.dat" skip 5 volatile lw 0.5
10 | set tics tc "black"
11 | refresh
12 | unset multiplot
13 | reset
14 |
--------------------------------------------------------------------------------
/gnuplot/demo/bolditalic.dem:
--------------------------------------------------------------------------------
1 | set polar
2 | unset xtics
3 | unset ytics
4 | unset key
5 | set border 0
6 |
7 | set title "{/:Bold Enhanced text style markup}"
8 | set x2label "Default {/Times:Bold=15 Bold ^{/:Italic Italic}} Default" offset 0,-2
9 | set xlabel 'Default {/Times=18:Italic Italic _{/:Bold Bold} ^{/:Normal Normal}} Default'
10 |
11 | plot [t=0:4*pi] t with lines
12 | pause -1 "Hit return to continue"
13 | reset
14 |
--------------------------------------------------------------------------------
/gnuplot/share/colors_mono.gp:
--------------------------------------------------------------------------------
1 | #
2 | # Provide a consistent set of four distinguishable
3 | # black line types.
4 | # NB: This does not work with "set term post mono"
5 | #
6 | unset for [i=1:8] linetype i
7 | set linetype 4 dt 1 lw 2 lc rgb "black"
8 | set linetype 3 dt 3 lw 1.5 lc rgb "black"
9 | set linetype 2 dt 2 lw 1.5 lc rgb "black"
10 | set linetype 1 dt solid lw 1 lc rgb "black"
11 | set linetype cycle 4
12 | #
13 | set palette gray
14 |
--------------------------------------------------------------------------------
/gnuplot/demo/gen-random.inc:
--------------------------------------------------------------------------------
1 | #
2 | # create random data, used e.g. by
3 | # random.dem, ellipse.dem, rugplot.dem, and kdensity2d.dem
4 | #
5 | if (!exist("$random")) {
6 | load "stat.inc"
7 | nsamp = 3000
8 | # Generate N random data points.
9 | set print $random
10 | do for [i=1:nsamp] {
11 | print sprintf("%8.5g %8.5g %8.5g", invnorm(rand(0)), invnorm(rand(0)), invnorm(rand(0)))
12 | }
13 | unset print
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/AnyRandomGraph.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Иван Ильин on 10.08.2020.
3 | //
4 |
5 | #include
6 | #include
7 | #include "gnuplot.h"
8 | #include "vemath.h"
9 |
10 | using namespace std;
11 | using namespace vemath;
12 |
13 | int main() {
14 | ComplexPlot p_R;
15 |
16 | GnuplotPipe gp;
17 |
18 | //gp.sendLine(R"(set xrange [-15:15])");
19 | //gp.sendLine(R"(set yrange [-15:15])");
20 | gp.sendLine(R"(plot "log.txt" with lines)");
21 | }
--------------------------------------------------------------------------------
/gnuplot/demo/named_var.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Plot a function of a named variable
3 | # i.e. f(gamma) rather than f(x)
4 | #
5 | set title "Plot a function of a named variable"
6 | set xlabel "gamma"
7 |
8 | plot [gamma=0.6:1.2] \
9 | [0:20] \
10 | fdivm=1.2, \
11 | omega = 0.8, \
12 | lambda=0.051, \
13 | f(gamma)=fdivm/sqrt((omega**2 - gamma**2)**2 + 4 * lambda**2 * gamma**2), \
14 | f(gamma) title "f(gamma)" with lines linewidth 6
15 |
16 | pause -1 "Hit return to continue"
17 |
18 | reset
19 |
--------------------------------------------------------------------------------
/gnuplot/demo/nokey.dem:
--------------------------------------------------------------------------------
1 | set title "Position plot titles at the end of the corresponding curve\nrather than in a separate key"
2 | set auto fix
3 | unset key
4 | set rmargin at screen 0.8
5 | set datafile sep '\t'
6 | set xtics nomirror scale 0
7 | set ytics nomirror
8 | set border 2 lw 2
9 | set style data lines
10 | plot for [place in "Germany Greece Denmark France"] 'immigration.dat' \
11 | using 1:(column(place)) lw 2 title columnhead at end
12 |
13 | pause -1 "Hit return to continue"
14 |
15 | reset
16 |
--------------------------------------------------------------------------------
/gnuplot/share/colors_podo.gp:
--------------------------------------------------------------------------------
1 | # Palette of colors selected to be easily distinguishable by
2 | # color-blind individuals with either protanopia or deuteranopia
3 | # Bang Wong [2011] Nature Methods 8, 441.
4 | set linetype 1 lc rgb "black"
5 | set linetype 2 lc rgb "#e69f00"
6 | set linetype 3 lc rgb "#56b4e9"
7 | set linetype 4 lc rgb "#009e73"
8 | set linetype 5 lc rgb "#f0e442"
9 | set linetype 6 lc rgb "#0072b2"
10 | set linetype 7 lc rgb "#d55e00"
11 | set linetype 8 lc rgb "#cc79a7"
12 | set linetype cycle 8
13 |
--------------------------------------------------------------------------------
/gnuplot/demo/multipalette.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Test case of multiplot containing more than one palette
3 | # (for debugging)
4 | #
5 | set view map
6 | set multiplot layout 2,1 \
7 | title "Test ability to display multiple palettes within a single multiplot"
8 | set title '10 gray levels'
9 | set palette gray
10 | set palette maxcolors 10
11 | splot x*x with pm3d
12 | set title '2 colors'
13 | set palette color
14 | set palette maxcolors 2
15 | splot x with pm3d
16 | unset multiplot
17 | pause -1 "Hit return to continue"
18 |
19 | reset
20 |
--------------------------------------------------------------------------------
/gnuplot/demo/colorwheel.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Set palette to HSV color wheel and define common colors as macros
3 | # This allows commands like
4 | # plot sin(x) with lines @orange
5 | #
6 | set palette mode HSV
7 | set palette defined ( 0 0 1 1, 1 1 1 1 )
8 | set cbrange [0:1]
9 | red = "lt pal frac 0"
10 | orange = "lt pal frac 0.10"
11 | yellow = "lt pal frac 0.16"
12 | green = "lt pal frac 0.33"
13 | cyan = "lt pal frac 0.5"
14 | blue = "lt pal frac 0.66"
15 | violet = "lt pal frac 0.79"
16 | magenta = "lt pal frac 0.83"
17 | black = "lt -1"
18 | set macros
19 |
--------------------------------------------------------------------------------
/gnuplot/share/colors_default.gp:
--------------------------------------------------------------------------------
1 | # Ethan A Merritt - my preference for gnuplot colors
2 | # 2 3 4 5 6 8 are borrowed from the colors_podo set
3 | #
4 | set linetype 1 lc rgb "dark-violet" lw 1
5 | set linetype 2 lc rgb "#009e73" lw 1
6 | set linetype 3 lc rgb "#56b4e9" lw 1
7 | set linetype 4 lc rgb "#e69f00" lw 1
8 | set linetype 5 lc rgb "#f0e442" lw 1
9 | set linetype 6 lc rgb "#0072b2" lw 1
10 | set linetype 7 lc rgb "#e51e10" lw 1
11 | set linetype 8 lc rgb "black" lw 1
12 | set linetype 9 lc rgb "gray50" lw 1
13 | set linetype cycle 9
14 |
15 |
--------------------------------------------------------------------------------
/gnuplot/demo/rugplot.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo of a Rug Plot
3 | # The X and Y coordinates of each point are marked by a mark
4 | # on the corresponding axis.
5 | #
6 | load "gen-random.inc"
7 |
8 | unset key
9 | set bmargin at screen .2;
10 | set rmargin at screen .8; set lmargin at screen .2;
11 | set offset .08, .08, .08, .08
12 | set border lw 0.5
13 |
14 | set title "Rug Plot" font ",24" offset 0,.5
15 |
16 | set xtics out scale 3
17 | set ytics out scale 3
18 | plot $random every 15 using 1:2:xtic(""):ytic("") with points ps .5
19 |
20 | pause -1 "Hit to continue"
21 | reset
22 |
--------------------------------------------------------------------------------
/gnuplot/demo/nonlinear6.dem:
--------------------------------------------------------------------------------
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 " to continue"
21 | reset
22 |
--------------------------------------------------------------------------------
/gnuplot/demo/molecule.dem:
--------------------------------------------------------------------------------
1 | set title "GM1 pentasaccharide ball-and-stick representation"
2 |
3 | set hidden3d
4 | set border 0
5 | unset tics
6 | unset key
7 | set view equal xyz
8 | set view 348, 163, 1.64872, 1.14
9 |
10 | set style fill transparent solid 0.9 border -1
11 | atomcolor(name) = name[1:1] eq "O" ? 0xdd2222 : name [1:1] eq "N" ? 0x4444ff : 0x888888
12 |
13 | splot 'GM1_sugar.pdb' using 6:7:8:(0.6):(atomcolor(strcol(3))) with circles fc rgb var, \
14 | 'GM1_bonds.r3d' using 1:2:3:($5-$1):($6-$2):($7-$3) with vectors nohead lw 3 lc "black"
15 |
16 | pause -1 "Hit return to continue"
17 |
18 |
--------------------------------------------------------------------------------
/gnuplot/demo/monotonic_spline.dem:
--------------------------------------------------------------------------------
1 | set title "Monotonic cubic splines"
2 |
3 | set style data lines
4 | set xrange [ 233. : 388. ]
5 | set yrange [ 1.75 : 32.0 ]
6 |
7 | plot 'silver.dat' using 1:2 with points pt 7 ps 2 lc "grey" title 'raw data', \
8 | '' using 1:2 smooth csplines lt 1 title 'smooth cspline', \
9 | '' using 1:2 smooth mcs lt 3 title 'smooth mcs'
10 |
11 | pause -1 "Hit to continue"
12 |
13 | set title "Monotonic cubic splines (log-scale data)"
14 | set log y
15 | set ytics (1,2,3,4,5,10,20)
16 | refresh
17 |
18 | pause -1 "Hit to continue"
19 | reset
20 |
--------------------------------------------------------------------------------
/gnuplot/demo/special_chars.dem:
--------------------------------------------------------------------------------
1 | set title "set minussign; set micro"
2 | unset minus
3 | unset micro
4 | set label 1 gprintf("no special characters: %.2s %cUnits", -1.23e-6)
5 | set minus
6 | set micro
7 | set label 2 gprintf(" special characters: %.2s %cUnits", -1.23e-6)
8 | set label 3 sprintf("current encoding %s", GPVAL_ENCODING)
9 |
10 | set label 1 at 1,4 font ",20"
11 | set label 2 at 1,3 font ",20"
12 | set label 3 at 1,1 font ",15" noenhanced
13 |
14 | unset border
15 | unset xtics
16 | unset ytics
17 | unset key
18 |
19 | plot [0:10][0:10] -10
20 |
21 | pause -1 "Hit return to continue"
22 | reset
23 |
--------------------------------------------------------------------------------
/gnuplot/demo/binary.dem:
--------------------------------------------------------------------------------
1 | set style data lines
2 | set hidden3d
3 | set title "Hidden line removal of explicit binary surfaces"
4 | set ticslevel 0
5 | set key box
6 |
7 | set xrange [-3:3]
8 | set yrange [-2:2]
9 | splot "binary1" binary
10 | pause -1 "Hit return to continue (1)"
11 |
12 | set view 70,45
13 | set xrange [-3:3]
14 | set yrange [-3:3]
15 | splot "binary2" binary
16 | pause -1 "Hit return to continue (2)"
17 |
18 | set title "Notice that sampling rate can change"
19 | set vi 70,10
20 | set xrange [-3:6]
21 | set yrange [-3:6]
22 | splot "binary3" binary
23 | pause -1 "Hit return to continue (3)"
24 |
25 | reset
26 |
--------------------------------------------------------------------------------
/gnuplot/demo/discrete.dem:
--------------------------------------------------------------------------------
1 | set contour
2 | set title "Demo of specifying discrete contour levels - default contours"
3 | splot x*y
4 | pause -1 "Hit return to continue"
5 |
6 | #set discrete levels
7 | set cntrparam levels discrete 0, 15, 75
8 | set title "3 discrete contours at 0 15 & 75"
9 | replot
10 | pause -1 "Hit return to continue"
11 |
12 | #set incremental levels
13 | set cntrp level incr -20, 5, 9
14 | set title "9 incremental contours starting at -20, stepping by 5"
15 | replot
16 | pause -1 "Hit return to continue"
17 |
18 | #restore defaults
19 | set title ""
20 | unset contour
21 | set cntrparam levels auto 5
22 |
23 |
--------------------------------------------------------------------------------
/gnuplot/demo/timedat.dat:
--------------------------------------------------------------------------------
1 | Date Time Val1 Val2 Val3 Val4
2 | 01/06/93 0000 0.20 0.175 3.07 2.62 0 25 0.24 7.5 70.8 16.9 0.328 9.94 23.74 6.74 8.34 5.96 4.69 0 0.164 0.021 0 0 8.62 22.8
3 | 17/08/93 0900 0.20 0.175 3.07 2.62 0 25 0.24 7.5 70.8 16.9 0.328 9.94 23.74 6.74 8.34 5.96 4.69 0 0.164 0.021 0 0 8.62 22.8
4 | 04/10/93 1300 0.28 0.18 6.05 4.92 0 0 106 0.24 7.2 53.7 20.8 0.12 6.45 27.55 6.37 8.94 7.46 0.499 0 0 0 0.035 0 0.772 6.39
5 | 11/10/93 1300 0.53 0.38 11.0 8.86 0 0 535 0.24 6.8 29.9 25 0.152 7.90 29.16 7.00 6.50 5.56 1.86 0 0.015 0 0.041 0 3.11 10.5
6 | 28/10/93 1000 0.17 0.05 6.65 5.55 52 0.22 7.3 41.5 18.7 0 5.57 24.81 6.93 9.33 6.70 2.31 0 0.019 0 0.033 0 3.86 12.3
7 |
--------------------------------------------------------------------------------
/gnuplot/demo/kdensity2d.dem:
--------------------------------------------------------------------------------
1 | reset
2 | load "gen-random.inc"
3 |
4 | set title "How to plot a kernel density estimate for this 2D dataset?"
5 | plot $random using 1:2
6 |
7 | pause -1 "Press Return to continue - the plot may take some time to appear"
8 |
9 | set view map
10 | set palette defined (0 'white', 1 'red')
11 | set dgrid3d 50,50 gauss kdensity
12 | set title "set dgrid3d 50,50 gauss kdensity"
13 |
14 | splot $random using 1:2:(1) with pm3d
15 |
16 | pause -1 "Press Return to continue - the plot may take some time to appear"
17 |
18 | set dgrid3d 50,50 gauss kdensity 0.1
19 | set title "set dgrid3d 50,50 gauss kdensity 0.1"
20 |
21 | replot
22 |
23 | pause -1 "Hit return to continue"
24 | reset
25 |
--------------------------------------------------------------------------------
/gnuplot/demo/table.dat:
--------------------------------------------------------------------------------
1 | Month ppt(1992-2000) ppt(2000-2001) runoff(1992-2000) runoff(2000-2001)
2 | ##### ########### ########### ############ ############
3 | mai 61 42.2 15.8 5.7
4 | jun 57.7 69.2 10.4 1.2
5 | jul 61.7 68.4 3.2 5.7
6 | aug 74.9 68.4 3 1.6
7 | sep 103.1 26.1 6.6 1.1
8 | okt 66.1 144.7 21.3 93.6
9 | nov 47.3 166.5 17.7 145.9
10 | des 48.8 52.9 17.3 51.6
11 | jan 55.7 43.4 8.3 0.9
12 | feb 36.1 22.9 1.8 0
13 | mar 39.1 37.5 10.8 5.4
14 | apr 41 42.1 56.1 61.7
15 |
16 |
--------------------------------------------------------------------------------
/gnuplot/demo/break_continue.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Unit test for `break` and `continue` commands
3 | # Two different entry actions:
4 | # "load break_continue.dem" executes the main loop
5 | # "call break_continue.dem foo" executes the inner clause
6 | #
7 | if (ARGC == 0) {
8 |
9 | do for [i=1:6] {
10 | print "start ", i;
11 | call 'break_continue.dem' sub1
12 | if (i > 4) { print ">>> ERROR <<<" }
13 | print "end ", i
14 | }
15 | print "done with for loop"
16 |
17 | } else {
18 |
19 | print " continue if i == 3, break if i > 4"
20 | if (i > 4) { break; }
21 | if (i == 3) { continue; print ">>> ERROR <<<" }
22 | print " still in load file"
23 | exit # exits only from this level of the call stack
24 | print ">>> failed to exit <<<"
25 | }
26 |
--------------------------------------------------------------------------------
/gnuplot/demo/cities.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demonstrates how to derive variable font size from a data file column.
3 | #
4 | # If you are viewing this via the HTML canvas terminal, be sure to toggle
5 | # the font scaling icon so that the fonts change size as you zoom in.
6 | #
7 | Scale(size) = 0.25*sqrt(sqrt(column(size)))
8 | CityName(String,Size) = sprintf("{/=%d %s}", Scale(Size), stringcolumn(String))
9 |
10 | set termoption enhanced
11 | save_encoding = GPVAL_ENCODING
12 | set encoding utf8
13 | unset xtics
14 | unset ytics
15 | unset key
16 | set border 0
17 | set size square
18 | set datafile separator "\t"
19 | plot 'cities.dat' using 5:4:($3 < 5000 ? "-" : CityName(1,3)) with labels
20 | pause -1 "hit return to continue"
21 | set encoding save_encoding
22 | reset
23 |
--------------------------------------------------------------------------------
/gnuplot/demo/controls.dem:
--------------------------------------------------------------------------------
1 | #
2 | # warning: this demo is SLOW on PCs without math coprocessors!
3 | #
4 | # From _Automatic_Control_Systems_, fourth ed., figure 6-14
5 | # transient response of a second-order system to a unit step input function
6 | #
7 | damp(t) = exp(-s*wn*t)/sqrt(1.0-s*s)
8 | per(t) = sin(wn*sqrt(1.0-s**2)*t - atan(-sqrt(1.0-s**2)/s))
9 | c(t) = 1-damp(t)*per(t)
10 | #
11 | # wn is natural undamped frequency
12 | # s is damping factor
13 | #
14 | wn = 1.0
15 | set xrange [0:13]
16 | set samples 50
17 | set dummy t
18 | set key box
19 | #
20 | # plot c(t) for several different damping factors s
21 | #
22 | plot s=.1,c(t),s=.3,c(t),s=.5,c(t),s=.7,c(t),s=.9,c(t),s=1.0,c(t),s=1.5,c(t),s=2.0,c(t)
23 | pause -1 "Hit return to continue"
24 | reset
25 |
26 |
--------------------------------------------------------------------------------
/gnuplot/demo/rotate_labels.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Additional data columns can be used to hold text rotation or color
3 | # for plot style "with labels"
4 | #
5 | $Data < to continue"
33 | reset
34 |
--------------------------------------------------------------------------------
/gnuplot/demo/battery.dat:
--------------------------------------------------------------------------------
1 | 50.000000 0.036990 2.500000 0.007039
2 | 47.000000 0.036990 2.500000 0.007039
3 | 44.000000 0.038360 2.500000 0.007053
4 | 41.000000 0.042160 2.500000 0.007050
5 | 38.000000 0.043200 2.500000 0.007018
6 | 35.000000 0.046900 2.500000 0.007021
7 | 32.000000 0.048840 2.500000 0.006963
8 | 29.000000 0.052000 2.500000 0.006929
9 | 26.000000 0.055470 2.500000 0.006947
10 | 23.000000 0.060000 2.500000 0.006882
11 | 20.000000 0.064660 2.500000 0.006879
12 | 17.000000 0.069600 2.500000 0.006936
13 | 14.000000 0.079800 2.500000 0.007080
14 | 11.000000 0.086920 2.500000 0.007232
15 | 8.000000 0.085500 2.500000 0.007262
16 | 5.000000 0.101260 2.500000 0.008415
17 | 2.000000 0.091000 2.500000 0.011203
18 | 0.000000 0.081480 2.500000 0.011828
19 |
--------------------------------------------------------------------------------
/gnuplot/demo/colorscheme.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo of color usage for principle plot elements
3 | #
4 |
5 | # Set canvas to a parchment color
6 | set obj 1 rectangle from screen 0,0 to screen 1,1 behind fc rgb "#e7dfcf"
7 |
8 | # Set plot area to light gray
9 | set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb "#dfdfdf"
10 |
11 | # border and tics in blue
12 | set border linetype 3 linewidth 3
13 |
14 | # key box and title in magenta,
15 | set key box lt 4 title "Key Box"
16 |
17 | # Apply the plot linetype color to the corresponding key entry title
18 | set key textcolor rgb variable
19 | set key left
20 |
21 | set title "Set new colors for principle plot elements"
22 | plot sin(x)/x lw 2, sin(x/2)/(x/2) lw 2 lt 4
23 |
24 | pause -1 "Hit return to continue"
25 | reset
26 |
--------------------------------------------------------------------------------
/gnuplot/demo/optimize.dat:
--------------------------------------------------------------------------------
1 | #
2 | # unconstrained optimization path with trust region size
3 | # read by circles.dem
4 | #
5 | -1.2000 1.0000 1.0000
6 | -1.1753 1.3807 1.0000
7 | -0.9764 0.9219 1.0000
8 | -0.7045 0.4225 1.0000
9 | -0.5965 0.3442 0.5000
10 | -0.4271 0.1603 0.5000
11 | -0.1645 -0.0419 0.5000
12 | -0.0858 0.0012 0.2500
13 | 0.1625 -0.0276 0.2500
14 | 0.2335 0.0495 0.2500
15 | 0.4553 0.1648 0.2500
16 | 0.5126 0.2595 0.2500
17 | 0.6847 0.4409 0.2500
18 | 0.7327 0.5345 0.2500
19 | 0.8726 0.7417 0.2500
20 | 0.8984 0.8064 0.2500
21 | 0.9881 0.9682 0.2500
22 | 0.9926 0.9853 0.2500
23 | 1.0000 0.9999 0.2500
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/gnuplot/demo/textbox.dem:
--------------------------------------------------------------------------------
1 | set grid
2 | unset xtics
3 | set xrange [ -0.50 : 12.00 ]
4 | set yrange [ 30.00 : 110.0 ]
5 | unset ylabel
6 | set bmargin 3
7 | unset key
8 |
9 |
10 | set style textbox 1 opaque border lc "blue"
11 | set style textbox 2 opaque margins 6,1.5 fc "grey75" border lc black
12 |
13 | set multiplot layout 1,2
14 | set title "textboxes with blue border"
15 | plot 'table.dat' using 0:2 title column with lines lw 3, \
16 | '' using 0:2:2 with labels center boxed bs 1 notitle column
17 |
18 | set title "larger textboxes with grey fill"
19 | plot 'table.dat' using 0:2 title column with lines lw 3, \
20 | '' using 0:2:2 with labels center boxed bs 2 notitle column
21 |
22 | unset multiplot
23 |
24 | pause -1 " to continue"
25 | reset
26 |
--------------------------------------------------------------------------------
/gnuplot/demo/triangle.dat:
--------------------------------------------------------------------------------
1 | # pm3d demo - datafile with different nb of points in scans and options
2 | # set pm3d flush [begin | center | end]
3 |
4 | 0 0 1
5 | 1 0 2
6 |
7 | 0 1 1
8 | 1 1 2
9 | 2 1 3
10 | 3 1 4
11 |
12 | 0 2 1
13 | 1 2 2
14 | 2 2 3
15 | 3 2 4
16 | 4 2 5
17 | 5 2 6
18 |
19 | 0 3 1
20 | 1 3 2
21 | 2 3 3
22 | 3 3 4
23 | 4 3 5
24 | 5 3 6
25 | 6 3 7
26 | 7 3 8
27 |
28 | 0 4 1
29 | 1 4 2
30 | 2 4 3
31 | 3 4 4
32 | 4 4 5
33 | 5 4 6
34 | 6 4 7
35 | 7 4 8
36 | 8 4 9
37 | 9 4 10
38 |
39 | 0 5 1
40 | 1 5 2
41 | 2 5 3
42 | 3 5 4
43 | 4 5 5
44 | 5 5 6
45 | 6 5 7
46 | 7 5 8
47 | 8 5 9
48 | 9 5 10
49 | 10 5 11
50 | 11 5 12
51 |
52 | 0 6 1
53 | 1 6 2
54 | 2 6 3
55 | 3 6 4
56 | 4 6 5
57 | 5 6 6
58 | 6 6 7
59 | 7 6 8
60 | 8 6 9
61 | 9 6 10
62 | 10 6 11
63 | 11 6 12
64 | 12 6 13
65 | 13 6 14
66 |
--------------------------------------------------------------------------------
/gnuplot/demo/arrowstyle.dat:
--------------------------------------------------------------------------------
1 | -1000 37 -41
2 | -959 11 -49
3 | -918 -16 -48
4 | -877 -42 -39
5 | -836 -60 -24
6 | -795 -69 -5
7 | -755 -66 14
8 | -714 -52 32
9 | -673 -30 44
10 | -632 -2 49
11 | -591 24 46
12 | -551 48 35
13 | -510 64 18
14 | -469 69 0
15 | -428 63 -20
16 | -387 46 -37
17 | -346 22 -47
18 | -306 -5 -49
19 | -265 -32 -44
20 | -224 -54 -31
21 | -183 -67 -13
22 | -142 -68 7
23 | -102 -59 26
24 | -61 -39 40
25 | -20 -14 48
26 | 20 14 48
27 | 61 39 40
28 | 102 59 26
29 | 142 68 7
30 | 183 67 -13
31 | 224 54 -31
32 | 265 32 -44
33 | 306 5 -49
34 | 346 -22 -47
35 | 387 -46 -37
36 | 428 -63 -20
37 | 469 -69 -0
38 | 510 -64 18
39 | 551 -48 35
40 | 591 -24 46
41 | 632 2 49
42 | 673 30 44
43 | 714 52 32
44 | 755 66 14
45 | 795 69 -5
46 | 836 60 -24
47 | 877 42 -39
48 | 918 16 -48
49 | 959 -11 -49
50 | 1000 -37 -41
51 |
--------------------------------------------------------------------------------
/gnuplot/demo/density.fnc:
--------------------------------------------------------------------------------
1 | #
2 | # This is a rough approach to fit a model function to the density
3 | # data of a liquid crystal. The function consists of a linear
4 | # branch for the high temperature region and of a curved branch with
5 | # linear asymptote for the low temperatuer branch
6 | #
7 |
8 | # free parameters:
9 | # m1, m2 slopes of the linear function in the low and high T region
10 | # Tc transition temperature
11 | # dens_Tc density at the transition temperature
12 | # g factor to scale tanh function
13 |
14 | ml = -0.0001
15 | mh = -0.0001
16 | dens_Tc = 1.020
17 | Tc = 45
18 | g = 1
19 | b = 0.1
20 |
21 |
22 | high(x) = mh*(x-Tc) + dens_Tc
23 | lowlin(x) = ml*(x-Tc) + dens_Tc
24 | curve(x) = b*tanh(g*(Tc-x))
25 |
26 | density(x) = x < Tc ? curve(x)+lowlin(x) : high(x)
27 |
--------------------------------------------------------------------------------
/gnuplot/demo/using.dem:
--------------------------------------------------------------------------------
1 | # Requires data file "using.dat" from this directory,
2 | # so change current working directory to this directory before running.
3 | #
4 |
5 | set title "Convex November 1-7 1989 Circadian"
6 | set key left box
7 | set xrange[-1:24]
8 | plot 'using.dat' using 2:4 title "Logged in" with impulses,\
9 | 'using.dat' using 2:4 title "Logged in" with points
10 | pause -1 "Hit return to continue"
11 |
12 | set xrange [1:8]
13 | #set xdtic
14 | set title "Convex November 1-7 1989"
15 | set key below
16 | set label "(Weekend)" at 5,25 center
17 | plot 'using.dat' using 3:4 title "Logged in" with impulses,\
18 | 'using.dat' using 3:5 t "Load average" with points,\
19 | 'using.dat' using 3:6 t "%CPU used" with lines
20 | unset label
21 | pause -1 "Hit return to continue"
22 | reset
23 |
--------------------------------------------------------------------------------
/gnuplot/demo/multiaxis.dem:
--------------------------------------------------------------------------------
1 | # Use the 3rd plot of the electronics demo to show off
2 | # the use of multiple x and y axes in the same plot.
3 | #
4 | A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
5 | p1 = 10
6 | p2 = 10000
7 | set dummy jw
8 | set grid x y2
9 | set key center top title " "
10 | set logscale xy
11 | set log x2
12 | unset log y2
13 | set title "Transistor Amplitude and Phase Frequency Response"
14 | set xlabel "jw (radians)"
15 | set xrange [1.1 : 90000.0]
16 | set x2range [1.1 : 90000.0]
17 | set ylabel "magnitude of A(jw)"
18 | set y2label "Phase of A(jw) (degrees)"
19 | set ytics nomirror
20 | set y2tics
21 | set tics out
22 | set autoscale y
23 | set autoscale y2
24 | plot abs(A(jw)) axes x1y1, 180./pi*arg(A(jw)) axes x2y2
25 |
26 | pause -1 "Hit return to continue"
27 |
28 | # undo what we've done
29 | reset
30 |
--------------------------------------------------------------------------------
/gnuplot/demo/ctg-y2.dat:
--------------------------------------------------------------------------------
1 | MONTH "precipitation 1992-2000"
2 | mai 61
3 | jun 57.7
4 | jul 61.7
5 | aug 74.9
6 | sep 103.1
7 | okt 66.1
8 | nov 47.3
9 | des 48.8
10 | jan 55.7
11 | feb 36.1
12 | mar 39.1
13 | apr 41
14 |
15 |
16 | MONTH "precipitation 2001-2002"
17 | mai 42.2
18 | jun 69.2
19 | jul 68.4
20 | aug 68.4
21 | sep 26.1
22 | okt 144.7
23 | nov 166.5
24 | des 52.9
25 | jan 43.4
26 | feb 22.9
27 | mar 37.5
28 | apr 42.1
29 |
30 |
31 | MONTH "runoff 1992-2000"
32 | mai 15.8
33 | jun 10.4
34 | jul 3.2
35 | aug 3
36 | sep 6.6
37 | okt 21.3
38 | nov 17.7
39 | des 17.3
40 | jan 8.3
41 | feb 1.8
42 | mar 10.8
43 | apr 56.1
44 |
45 |
46 | MONTH "runoff 2001-2002"
47 | mai 5.7
48 | jun 1.2
49 | jul 5.7
50 | aug 1.6
51 | sep 1.1
52 | okt 93.6
53 | nov 145.9
54 | des 51.6
55 | jan 0.9
56 | feb 0
57 | mar 5.4
58 | apr 61.7
59 |
--------------------------------------------------------------------------------
/gnuplot/demo/macros.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Exercise use of macro substitution
3 | #
4 | set macros
5 |
6 | title = "Test of command line macro substitution"
7 | style1 = "points"
8 | style2 = "lines lw 2"
9 | plot1 = "'1.dat' using 1:2 with @style1"
10 | plot2 = "'1.dat' using 1:($2+1) with @style2"
11 | plot3 = '@plot2'
12 | plot4 = '@plot3'
13 | plot5 = '@plot4'
14 | plot6 = '@plot5'
15 | #
16 | set title title
17 | plot @plot1 title 'plot1', \
18 | @plot2 title 'plot2'
19 | show var
20 | #
21 | pause -1 " to test limit on recursion depth"
22 | #
23 | print "testing depth 3"
24 | plot @plot1 title 'plot1', @plot3 lt 3 title 'Recursion depth 3'
25 | pause 1
26 | print "testing depth 4"
27 | plot @plot1 title 'plot1', @plot4 lt 4 title 'Recursion depth 4'
28 | pause 1
29 | print "testing depth 5"
30 | plot @plot1 title 'plot1', @plot5 lt 5 title 'Recursion depth 5'
31 | pause 1
32 | #
33 | pause -1
34 |
35 |
--------------------------------------------------------------------------------
/gnuplot/demo/azimuth.dem:
--------------------------------------------------------------------------------
1 | set view equal xy
2 | set zzeroaxis; set xzeroaxis; set yzeroaxis
3 | set xyplane at 0
4 | unset border
5 | unset key
6 | unset xtics
7 | unset ytics
8 | set ztics axis
9 |
10 | set arrow 1 from 0,0,0 to 1,0,0 head filled lw 1.5
11 | set label 1 at 1.2,0,0 "X" center
12 | set arrow 2 from 0,0,0 to 0,1,0 head filled lw 1.5
13 | set label 2 at 0,1.2,0 "Y" center
14 | set arrow 3 from 0,0,0 to 0,0,21 head filled lw 1.5
15 | set label 3 at 0,0,23 "Z" center
16 |
17 | set view 60, 30, 1., 1.75
18 |
19 | set multiplot layout 1,3
20 |
21 | set view azimuth 0.
22 | set title 'azimuth 0' offset 0,2
23 | splot sample [t=0:20] '+' using (cos($1)):(sin($1)):($1) with lines lw 2
24 |
25 | set title 'azimuth 10' offset 0,2
26 | set view azimuth 10.
27 | replot
28 |
29 | set title 'azimuth 60' offset 0,2
30 | set view azimuth 60.
31 | replot
32 |
33 | unset multiplot
34 | pause -1 "Hit return to continue"
35 | reset
36 |
--------------------------------------------------------------------------------
/gnuplot/demo/hypertext.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demonstrates how to attach hypertext to points so that
3 | # the text is displayed on mouse-over.
4 | # Not much to see here unless you are using the wxt, svg, qt,
5 | # or HTML5 canvas terminal.
6 | #
7 | set title 'Hypertext is shown when the mouse is over a point'
8 |
9 | Scale(size) = 0.08*sqrt(sqrt(column(size)))
10 | City(String,Size) = sprintf("%s\npop: %d", stringcolumn(String), column(Size))
11 |
12 | set termoption enhanced
13 | save_encoding = GPVAL_ENCODING
14 | set encoding utf8
15 | unset xtics
16 | unset ytics
17 | unset key
18 | set border 0
19 | set size square
20 | set datafile separator "\t"
21 |
22 | plot 'cities.dat' using 5:4:(City(1,3)):(Scale(3)) \
23 | with labels hypertext point pt 7 ps var lc rgb "#ffee99", \
24 | 'cities.dat' using 5:4:(Scale(3)) \
25 | with points pt 6 ps var lc rgb "black" lw 0.1
26 |
27 | pause -1 "hit return to continue"
28 | set encoding save_encoding
29 | reset
30 |
--------------------------------------------------------------------------------
/gnuplot/demo/nonlinear5.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Use of "set nonlinear" to produce a log-scale z axis and contours.
3 | #
4 | set border 15 front lt black
5 | set key at screen 1, 0.9 right top vertical Right
6 | set style textbox opaque margins 0.5, 0.5 noborder
7 | set view 22, 341, 1, 1.1
8 | set isosamples 60, 60
9 | unset surface
10 | set contour base
11 | set cntrlabel format '%8.3g' font ',7' start 2 interval 20
12 | set hidden3d back offset 1 trianglepattern 3 undefined 1 altdiagonal bentover
13 | set cntrparam order 8
14 | set style data lines
15 | set xyplane relative 0
16 | set nomztics
17 | unset ztics
18 | set title "Rosenbrock Function"
19 | set xlabel "x"
20 | set ylabel "y"
21 | Rosenbrock(x,y) = (1-x)**2 + 100*(y - x**2)**2
22 | u = 0.0
23 | x = 0.0
24 |
25 | # Achieves same effect as
26 | # set log z
27 | set nonlinear z via log10(z) inverse 10**z
28 |
29 | splot [-1.5:1.5] [-0.5:1.5] Rosenbrock(x,y)
30 |
31 | pause -1 " to continue"
32 | reset
33 |
--------------------------------------------------------------------------------
/gnuplot/demo/1.dat:
--------------------------------------------------------------------------------
1 | -20.000000 -3.041676
2 | -19.000000 -3.036427
3 | -18.000000 -3.030596
4 | -17.000000 -3.024081
5 | -16.000000 -3.016755
6 | -15.000000 -3.008456
7 | -14.000000 -2.998978
8 | -13.000000 -2.988049
9 | -12.000000 -2.975310
10 | -11.000000 -2.960273
11 | -10.000000 -2.942255
12 | -9.000000 -2.920278
13 | -8.000000 -2.892883
14 | -7.000000 -2.857799
15 | -6.000000 -2.811295
16 | -5.000000 -2.746802
17 | -4.000000 -2.651635
18 | -3.000000 -2.498092
19 | -2.000000 -2.214297
20 | -1.000000 -1.570796
21 | 0.000000 0.000000
22 | 1.000000 1.570796
23 | 2.000000 2.214297
24 | 3.000000 2.498092
25 | 4.000000 2.651635
26 | 5.000000 2.746802
27 | 6.000000 2.811295
28 | 7.000000 2.857799
29 | 8.000000 2.892883
30 | 9.000000 2.920278
31 | 10.000000 2.942255
32 | 11.000000 2.960273
33 | 12.000000 2.975310
34 | 13.000000 2.988049
35 | 14.000000 2.998978
36 | 15.000000 3.008456
37 | 16.000000 3.016755
38 | 17.000000 3.024081
39 | 18.000000 3.030596
40 | 19.000000 3.036427
41 |
--------------------------------------------------------------------------------
/gnuplot/demo/2.dat:
--------------------------------------------------------------------------------
1 | -20.000000 -6.083352
2 | -19.000000 -6.072853
3 | -18.000000 -6.061191
4 | -17.000000 -6.048162
5 | -16.000000 -6.033510
6 | -15.000000 -6.016913
7 | -14.000000 -5.997955
8 | -13.000000 -5.976098
9 | -12.000000 -5.950620
10 | -11.000000 -5.920546
11 | -10.000000 -5.884511
12 | -9.000000 -5.840556
13 | -8.000000 -5.785765
14 | -7.000000 -5.715597
15 | -6.000000 -5.622591
16 | -5.000000 -5.493603
17 | -4.000000 -5.303271
18 | -3.000000 -4.996183
19 | -2.000000 -4.428595
20 | -1.000000 -3.141593
21 | 0.000000 0.000000
22 | 1.000000 3.141593
23 | 2.000000 4.428595
24 | 3.000000 4.996183
25 | 4.000000 5.303271
26 | 5.000000 5.493603
27 | 6.000000 5.622591
28 | 7.000000 5.715597
29 | 8.000000 5.785765
30 | 9.000000 5.840556
31 | 10.000000 5.884511
32 | 11.000000 5.920546
33 | 12.000000 5.950620
34 | 13.000000 5.976098
35 | 14.000000 5.997955
36 | 15.000000 6.016913
37 | 16.000000 6.033510
38 | 17.000000 6.048162
39 | 18.000000 6.061191
40 | 19.000000 6.072853
41 |
--------------------------------------------------------------------------------
/gnuplot/demo/3.dat:
--------------------------------------------------------------------------------
1 | -20.000000 -9.125028
2 | -19.000000 -9.109280
3 | -18.000000 -9.091787
4 | -17.000000 -9.072243
5 | -16.000000 -9.050265
6 | -15.000000 -9.025369
7 | -14.000000 -8.996933
8 | -13.000000 -8.964147
9 | -12.000000 -8.925931
10 | -11.000000 -8.880819
11 | -10.000000 -8.826766
12 | -9.000000 -8.760835
13 | -8.000000 -8.678648
14 | -7.000000 -8.573396
15 | -6.000000 -8.433886
16 | -5.000000 -8.240405
17 | -4.000000 -7.954906
18 | -3.000000 -7.494275
19 | -2.000000 -6.642892
20 | -1.000000 -4.712389
21 | 0.000000 0.000000
22 | 1.000000 4.712389
23 | 2.000000 6.642892
24 | 3.000000 7.494275
25 | 4.000000 7.954906
26 | 5.000000 8.240405
27 | 6.000000 8.433886
28 | 7.000000 8.573396
29 | 8.000000 8.678648
30 | 9.000000 8.760835
31 | 10.000000 8.826766
32 | 11.000000 8.880819
33 | 12.000000 8.925931
34 | 13.000000 8.964147
35 | 14.000000 8.996933
36 | 15.000000 9.025369
37 | 16.000000 9.050265
38 | 17.000000 9.072243
39 | 18.000000 9.091787
40 | 19.000000 9.109280
41 |
--------------------------------------------------------------------------------
/gnuplot/demo/bins.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo illustrating the relationship between
3 | # a binned histogram and a kernel density model of the same data.
4 | #
5 | $DATA << EOD
6 | 1 1
7 | 2 1
8 | 8 1
9 | 9 1
10 | 17 1
11 | 17 1
12 | 9 1
13 | 9 1
14 | 5 1
15 | 7 1
16 | 7 1
17 | 8 1
18 | 8 1
19 | 8 1
20 | 10 1
21 | 11 1
22 | 11 1
23 | 12 1
24 | 14 1
25 | 3 1
26 | 3 1
27 | 3 1
28 | 8 7
29 | 15 1
30 | 17 1
31 | 17 1
32 | 18 1
33 | 19 1
34 | 20 1
35 | EOD
36 |
37 | set title "Comparison of a binned histogram and\na kernel density model of the same data"
38 |
39 | set style data lines
40 | set xtics 1 norangelimit nomirror
41 | set grid y
42 | set yrange [0:5.5]
43 | set style fill solid 0.5 noborder
44 | set jitter spread 0.5
45 |
46 | plot $DATA using 1 bins=20 with boxes title '20 bins', \
47 | '' using 1:(1) smooth kdensity bandwidth .5 lw 2 title 'smooth kdensity', \
48 | '' using 1:(.9) with impulse lc "black" title 'jittered data'
49 |
50 | pause -1 "Hit return to continue"
51 | reset
52 |
--------------------------------------------------------------------------------
/gnuplot/demo/mouselabels.dem:
--------------------------------------------------------------------------------
1 | # Demonstrate screen interaction using mouse variables
2 | #
3 | # MOUSE_X MOUSE_Y MOUSE_KEY MOUSE_CHAR
4 | #
5 |
6 | set termoption enhanced
7 |
8 | set title "Demo interactive placement of labels using mouse feedback"
9 | set label 1 at graph 0.02, graph 0.9
10 | set label 1 "Position mouse at desired start of label and start typing\nEnhanced text syntax may be used\nArrow keys will reposition label as you go\n or allows editing\n to terminate this label\n to terminate demo"
11 |
12 | set border 0
13 | unset xtics
14 | unset ytics
15 | set key box
16 |
17 | plot sin(13*besj0(x))/x
18 |
19 | #
20 | # Initialize label identifier
21 | #
22 | LID = 100
23 |
24 | #
25 | # Loop over interactive placement of new labels
26 | #
27 | load "mouselab_1.dem"
28 | print "Back from mouselab_1"
29 | show label
30 |
31 | #
32 | # All done with demo
33 | #
34 | unset label 1
35 | set label 2 "DONE"
36 | replot
37 | pause -1 "Hit to continue"
38 | reset
39 |
--------------------------------------------------------------------------------
/gnuplot/demo/ttics.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Use of "set ttics" to place angular labels around polar grid
3 | #
4 | set title "Angle labels (ttics) for polar plots" offset 0,1
5 | set polar
6 | set ttics 0,30 format "%g".GPVAL_DEGREE_SIGN font ":Italic"
7 | set mttics 3
8 | set grid r polar 60
9 | unset xtics
10 | unset ytics
11 | set border 0
12 | set size square
13 | unset key
14 |
15 | set rrange [0:6.1]
16 | if (GPVAL_ENCODING eq "utf8") {
17 | set ttics add ("π" 180, "π/2" 90, "3π/2" 270)
18 | } else {
19 | set ttics add ("pi" 180, "pi/2" 90, "3pi/2" 270)
20 | }
21 |
22 | plot t lt 3 lw 2, -t lt 4 lw 2
23 | #
24 | pause -1 " to continue"
25 |
26 | set title "Polar plot with border and rotated labels for ttics"
27 | set ttics rotate
28 | set rrange [0:6.5]
29 | set border polar
30 | replot
31 |
32 | pause -1 " to continue"
33 |
34 | set title "Theta origin at top, increasing clockwise"
35 | set ttics norotate offset 1
36 | set theta clockwise top
37 | replot
38 |
39 | pause -1 " to continue"
40 |
41 | reset
42 |
--------------------------------------------------------------------------------
/gnuplot/demo/ellipse.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Ethan A Merritt - Feb 2007
3 | # This demo requires support for 'set object ellipse'
4 | #
5 | load "gen-random.inc"
6 |
7 | unset key
8 | set xrange [-8:8]
9 | set yrange [-8:8]
10 | set size ratio 1.0
11 | set zeroaxis
12 | set border 0
13 | set xtics axis
14 | set ytics axis
15 | set tics scale 0.5
16 | set format xy ""
17 |
18 | set title 'Example of `set object ellipse`'
19 |
20 | set object 1 ellipse center 1.5,1.0 size 2.,4. angle 20. front fillstyle empty border -1
21 | set obj 2 ellipse center 1.5, 1 size 6, 12 angle 20 front fs empty bo 3
22 |
23 | A = pi/9.
24 | plot $random using (1.5 + $1*cos(A)-2.*$2*sin(A)):(1.0 + $1*sin(A)+2.*$2*cos(A)) with dots
25 |
26 | pause -1 "Hit return to continue"
27 |
28 | set title 'Example of range-limited axes and tics'
29 |
30 | set tics out scale 0.5
31 | set xtics 1.0 border rangelimited nomirror
32 | set ytics 1.0 border rangelimited nomirror
33 | set format xy "%.0f"
34 | set border 3
35 |
36 | replot
37 |
38 | pause -1 "Hit return to continue"
39 | reset
40 |
--------------------------------------------------------------------------------
/gnuplot/demo/asciimat.dat:
--------------------------------------------------------------------------------
1 | 0 1 2 3 4 5 6 7 8 9
2 | 0 1 2 3 4 5 6 7 8 9
3 | 0 1 2 3 4 5 6 7 8 9
4 | 0 1 2 3 4 5 6 7 8 9
5 | 0 1 2 3 4 5 6 7 8 9
6 | 0 1 2 3 4 5 6 7 8 9
7 | 0 1 2 3 4 5 6 7 8 9
8 | 0 1 2 3 4 5 6 7 8 9
9 | 0 1 2 3 4 5 6 7 8 9
10 | 0 1 2 3 4 5 6 7 8 9
11 |
12 | 0 0 0 0 0 0 0 0 0 0
13 | 1 1 1 1 1 1 1 1 1 1
14 | 2 2 2 2 2 2 2 2 2 2
15 | 3 3 3 3 3 3 3 3 3 3
16 | 4 4 4 4 4 4 4 4 4 4
17 | 5 5 5 5 5 5 5 5 5 5
18 | 6 6 6 6 6 6 6 6 6 6
19 | 7 7 7 7 7 7 7 7 7 7
20 | 8 8 8 8 8 8 8 8 8 8
21 | 9 9 9 9 9 9 9 9 9 9
22 |
23 | 0 1 2 3 4 5 6 7 8 9
24 | 1 2 3 4 5 6 7 8 9 10
25 | 2 3 4 5 6 7 8 9 10 11
26 | 3 4 5 6 7 8 9 10 11 12
27 | 4 5 6 7 8 9 10 11 12 13
28 | 5 6 7 8 9 10 11 12 13 14
29 | 6 7 8 9 10 11 12 13 14 15
30 | 7 8 9 10 11 12 13 14 15 16
31 | 8 9 10 11 12 13 14 15 16 17
32 | 9 10 11 12 13 14 15 16 17 18
33 |
--------------------------------------------------------------------------------
/gnuplot/demo/pm3dgamma.dem:
--------------------------------------------------------------------------------
1 | # Test of gamma correction for gray palettes
2 |
3 | set pm3d; set palette
4 | set palette gray
5 | set view map
6 | set style function pm3d
7 | set cbrange [-10:10]
8 | set xrange [-10:10]
9 | set yrange [*:*]
10 | unset ztics
11 | unset ytics
12 | set samples 101
13 | set isosamples 2
14 | set xtics 2
15 |
16 | set palette gamma 0.75
17 | set title "gamma = 0.75"
18 | splot x
19 | pause -1 "Hit return to continue"
20 |
21 |
22 | set palette gamma 1.0
23 | set title "gamma = 1.0"
24 | splot x
25 | pause -1 "Hit return to continue"
26 |
27 |
28 | set palette gamma 1.25
29 | set title "gamma = 1.25"
30 | splot x
31 | pause -1 "Hit return to continue"
32 |
33 |
34 | set palette gamma 1.5
35 | set title "gamma = 1.5"
36 | splot x
37 | pause -1 "Hit return to continue"
38 |
39 |
40 | set palette gamma 1.75
41 | set title "gamma = 1.75"
42 | splot x
43 | pause -1 "Hit return to continue"
44 |
45 |
46 | set palette gamma 2.0
47 | set title "gamma = 2.0"
48 | splot x
49 | pause -1 "Hit return to continue"
50 |
51 | reset
52 |
53 |
--------------------------------------------------------------------------------
/gnuplot/demo/barchart_art.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo of using rescaled images to construct a bar chart
3 | #
4 | if (!strstrt(GPVAL_COMPILE_OPTIONS,"+GD_PNG")) \
5 | print ">>> Skipping demo <<<\n" ; \
6 | print "This copy of gnuplot was built without support for loading png images" ;\
7 | exit ;
8 |
9 | reset
10 | set title "Building Code Height Limits"
11 | unset key
12 |
13 | set xrange [ -10 : 160 ]
14 | set yrange [ 0 : 200 ]
15 | set y2range[ 0 : 200 ]
16 |
17 | set y2tics
18 | set grid y
19 |
20 | set xtics ("NE" 12.0, "S" 42.0, "Downtown" 72.0, "Suburbs" 127.0) scale 0.0
21 |
22 | plot 'bldg.png' binary filetype=png origin=(60,0) dx=0.5 dy=1.5 with rgbimage, \
23 | 'bldg.png' binary filetype=png origin=(0,0) dx=0.5 dy=1 with rgbimage, \
24 | 'bldg.png' binary filetype=png origin=(30,0) dx=0.5 dy=0.7 with rgbimage, \
25 | 'bldg.png' binary filetype=png origin=(100,0) dx=0.5 dy=0.35 with rgbimage, \
26 | 'bldg.png' binary filetype=png origin=(125,0) dx=0.5 dy=0.35 with rgbimage
27 |
28 | pause -1 "Hit return to continue"
29 | reset
30 |
--------------------------------------------------------------------------------
/gnuplot/demo/fillbetween.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demonstrate filling the area between two curves
3 | # and also the application of fillstyle to filled curves.
4 | # Ethan Merritt
5 | # June 2004
6 | #
7 | set title "Fill area between two curves"
8 | set style data lines
9 | set xrange [10:*]
10 | set yrange [0:175]
11 | plot 'silver.dat' u 1:2:3 "%lf %lf %lf" w filledcu, \
12 | '' u 1:2 lt -1 notitle, '' u 1:3 lt -1 notitle
13 | pause -1 "Hit return to continue"
14 | set style fill pattern 2
15 | set title "Fill area between two curves (pattern fill)"
16 | replot
17 | pause -1 "Hit return to continue"
18 | set title "Fill area between two curves (above/below)"
19 | set style fill solid 1.0 noborder
20 | set xrange [250:500]
21 | set auto y
22 | plot 'silver.dat' u 1:2:($3+$1/50.) w filledcurves above title 'Above', \
23 | '' u 1:2:($3+$1/50.) w filledcurves below title 'Below', \
24 | '' u 1:2 lt -1 lw 2 title 'curve 1', \
25 | '' u 1:($3+$1/50.) lt 3 lw 2 title 'curve 2'
26 | pause -1 "Hit return to continue"
27 | reset
28 |
--------------------------------------------------------------------------------
/gnuplot/demo/textrotate.dem:
--------------------------------------------------------------------------------
1 | # Demonstrate rotation of label text
2 | #
3 | reset
4 | #
5 | set title "Rotation of label text"
6 | #
7 | set xrange [-5:5]
8 | set yrange [-5:5]
9 | set xlabel "xlabel"
10 | set ylabel "ylabel"
11 | #
12 | set label 1 "Default" at -4,4
13 | #
14 | set label 2 "rotate left" at 0,0 rotate left
15 | set label 3 "rotate right" at 0.5,0 rotate right
16 | set label 4 "rotate center" at 1.0,0 rotate center
17 | #
18 | set label 12 "rotate by -90 left" at 2.0,0 rotate by -90 left
19 | set label 13 "rotate by -90 right" at 2.5,0 rotate by -90 right
20 | set label 14 "rotate by -90 center" at 3.0,0 rotate by -90 center
21 | #
22 | set label 21 " rotate by 45" at -3.0,0.0 rotate by 45 point ps 2
23 | set label 22 " rotate by 90" at -3.0,0.0 rotate by 90 point ps 2
24 | set label 23 " rotate by -30" at -3.0,0.0 rotate by -30 point ps 2
25 | set label 24 " rotate by -60" at -3.0,0.0 rotate by -60 point ps 2
26 | set label 25 " rotate by -90" at -3.0,0.0 rotate by -90 point ps 2
27 | #
28 | plot 0
29 | #
30 | pause -1 "Hit return to continue"
31 |
32 | reset
33 |
34 |
--------------------------------------------------------------------------------
/gnuplot/demo/matrix_index.dem:
--------------------------------------------------------------------------------
1 | $MATRICES << EOM
2 | # A garbage line at the beginning that is not an index
3 |
4 | # set1
5 | 0 0.314 0.628
6 | 2 3.06 1.51
7 | 8 1.974 1.03
8 |
9 |
10 | # set2
11 | 0 0.314 0.628
12 | 20 3.06 2.01
13 | 80 1.974 1.03
14 |
15 |
16 | # set3
17 | 0 0.314 0.628
18 | 2 1.06 3.01
19 | 8 2.974 4.03
20 | EOM
21 |
22 | set palette cubehelix
23 | unset colorbox
24 | set cbrange [1:3.6]
25 | set key box opaque samplen 0
26 | set xrange [] noextend
27 | set yrange [] noextend
28 |
29 | set multiplot layout 2,2 margins char 3,3,2,4 title "{/:Bold Data file contains labeled ascii matrices}
30 |
31 | set title "Y range should be the same"
32 | plot '$MATRICES' nonuniform matrix i "set3" w image title "index 'set3'"
33 | set title "colors should be the same"
34 | plot '$MATRICES' nonuniform matrix i "set2" w image title "index 'set2'"
35 | unset title
36 | plot '$MATRICES' nonuniform matrix i 0 w image title "index 0"
37 | plot '$MATRICES' nonuniform matrix i 1 w image title "index 1"
38 |
39 | unset multiplot
40 |
41 | pause -1 "Hit return to continue"
42 |
43 | reset
44 |
--------------------------------------------------------------------------------
/gnuplot/demo/mouselab_1.dem:
--------------------------------------------------------------------------------
1 | # Demonstrate screen interaction using mouse variables
2 | #
3 | # MOUSE_X MOUSE_Y MOUSE_KEY MOUSE_CHAR
4 | #
5 | # On entry, LID is the identifier for the previous label
6 | #
7 | #
8 | # Loop until we see an
9 | #
10 | while (1) {
11 |
12 | if (exists("MOUSE_KEY") && MOUSE_KEY == 27) {
13 | break
14 | }
15 |
16 | LID = LID + 1
17 | set label 2 sprintf(">>> READY FOR LABEL %d <<<",LID-100)
18 | set label 2 at graph .02, graph .65 tc lt (LID-100)
19 | replot
20 |
21 | #
22 | # Get mouse position and first character of label
23 | #
24 | pause mouse key
25 |
26 | if (MOUSE_KEY == 27) {
27 | break
28 | }
29 |
30 | LABEL = ""
31 | LABEL_X = MOUSE_X
32 | LABEL_Y = MOUSE_Y
33 | set label LID LABEL at LABEL_X, LABEL_Y
34 | replot
35 | #
36 | # Call routine that catches keystrokes one by one and
37 | # updates the label
38 | #
39 | load "mouselab_2.dem"
40 | #
41 | # Print out final label details
42 | #
43 | show label LID
44 |
45 | } # end of loop waiting for
46 |
--------------------------------------------------------------------------------
/gnuplot/demo/tics.dem:
--------------------------------------------------------------------------------
1 | # demo for tics settings
2 |
3 | set xlabel "x"
4 | set ylabel "y"
5 | set mxtics
6 |
7 | set title "Default tics settings"
8 | set xrange [-15:15]
9 | set yrange [-0.25:1]
10 | plot sin(sqrt(x**2))/sqrt(x**2) notitle
11 | pause -1 "Hit return to continue"
12 |
13 | set title "Different modification of tics settings"
14 | set tics scale 3,2 rotate by 45
15 | set xtics out offset 0,-1.0
16 | replot
17 | pause -1 "Hit return to continue"
18 |
19 | set xtics textcolor rgb "red" norotate
20 | set ytics rotate by 90 offset 2,0
21 | replot
22 | pause -1 "Hit return to continue"
23 |
24 | set title "Modified tics settings (pm3d palette with colorbar)"
25 | set view map
26 | set border 4095
27 | set samples 25
28 | set isosamples 20
29 | set palette color positive
30 | set samples 50; set isosamples 50
31 | set tics norotate nooffset
32 | set cbtics in scale 4
33 | set xrange [-15:15]
34 | set yrange [-15:15]
35 | set zrange [-0.25:1]
36 | splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2) with pm3d notitle
37 | pause -1 "Hit return to continue"
38 |
39 | reset
40 |
41 | print "End of tics demo."
42 |
--------------------------------------------------------------------------------
/gnuplot/demo/world2.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Plot of location on globe,
3 | # this time with labels color-coded by explicit 4th input column
4 | # Requires EAM_DATASTRINGS
5 | #
6 | set dummy u,v
7 | set angles degrees
8 | set parametric
9 | set view 60, 136, 1.22, 1.26
10 | set samples 64,64
11 | set isosamples 13,13
12 | set mapping spherical
13 | unset xtics
14 | unset ytics
15 | unset ztics
16 | set border 0
17 | set title "Labels colored by GeV plotted in spherical coordinate system"
18 | set urange [ -90.0000 : 90.0000 ] noreverse nowriteback
19 | set vrange [ 0.00000 : 360.000 ] noreverse nowriteback
20 | set cblabel "GeV"
21 | set cbrange [0:8]
22 | set colorb vert user size 0.02, 0.75
23 | unset hidden
24 | splot cos(u)*cos(v),cos(u)*sin(v),sin(u) notitle with lines lt 5, \
25 | 'world.dat' notitle with lines lt 2, \
26 | 'srl.dat' using 3:2:(1):1:4 with labels notitle point pt 6 lw .1 left offset 1,0 font "Helvetica,7" tc pal
27 | pause -1 "Same plot with hidden line removal"
28 | set title "Labels with hidden line removal"
29 | set hidden nooffset
30 | replot
31 | pause -1 "Hit return to continue"
32 | reset
--------------------------------------------------------------------------------
/gnuplot/demo/animate.dem:
--------------------------------------------------------------------------------
1 | # Demo animation, tumbling around 'glass.dat'.
2 | #
3 | # History:
4 | # - 1. 1. 2006 Dan Sebald: Defined variables for more generic rotate
5 | # - ?. ?. ? Hans-Bernhard Broeker: Changed from rotating whale to
6 | # rotating glass
7 | # - ?. ?. ? ?: Initial tumbling whale demo
8 |
9 | set parametric
10 | set hidden3d
11 | unset key
12 | set style data line
13 | xrot=60
14 | xrot_delta = 17
15 | zrot=0
16 | zrot_delta = 10
17 | xview(xrot)=(50.+30.*sin((xrot%180)/180.*pi))
18 | zview(zrot)=(60.+45.*sin(zrot/180.*pi))
19 | set view xview(xrot),zview(zrot)
20 | splot "glass.dat"
21 |
22 | limit_iterations=40 # limits number of iterations if nonzero
23 |
24 | if (!limit_iterations) print "The following animation will never stop on its own. You have"
25 | if (!limit_iterations) print "to stop it manually by interrupting gnuplot (e.g., press ^C)"
26 | print "On some screen terminal drivers for PC screens, you'll have"
27 | print "to hit a key to get to the next frame"
28 |
29 | pause -1 "Press a key to start the rotation..."
30 |
31 | iteration_count=0
32 | load "gnuplot.rot"
33 | reset
34 |
--------------------------------------------------------------------------------
/gnuplot/demo/nonlinear3.dem:
--------------------------------------------------------------------------------
1 | # This example shows how a nonlinear axis definition can be used to
2 | # set up "probability axis" scaling on both the x and y axes.
3 | # This is also known as "probit" scaling.
4 | # We compare 3 treatments of an image file (Tux).
5 | # They differ in the sigma value defining the normal distribution curve
6 | # used for scaling.
7 | # The 4th plot shows the original, unscaled image using linear axes.
8 | #
9 | unset border
10 | set title offset 0,-1
11 |
12 | set multiplot layout 2,2 title "Probability axes: Scale image pixels by distance from center treated as a Z-score"
13 |
14 | set title "Sigma = 22 pixels"
15 | sigma = 22.
16 | ticinterval = 2
17 | load 'probably_tux.dem'
18 |
19 | set title "Sigma = 30 pixels"
20 | sigma = 30.
21 | ticinterval = 1
22 | load 'probably_tux.dem'
23 |
24 | set title "Sigma = 60 pixels"
25 | sigma = 60.
26 | load 'probably_tux.dem'
27 |
28 | set title "Linear Scale"
29 | set label 1 "Tux"
30 | set xlabel " "
31 | set ylabel " "
32 | unset nonlinear x
33 | unset nonlinear y
34 | unset xtics
35 | unset ytics
36 | replot
37 |
38 | unset multiplot
39 |
40 | pause -1 " to continue"
41 | reset
42 |
--------------------------------------------------------------------------------
/gnuplot/demo/hexa.fnc:
--------------------------------------------------------------------------------
1 | #
2 | # Use this function to fit sound velocity data as function of
3 | # sound propagation direction, indicated by its angle against the
4 | # z-axis of an hexagonal symmetry coordinate system
5 | #
6 | # Adjustable parameters:
7 | #
8 | # c33, c11, c13, c44 elastic moduli - materials constants
9 | # phi0 angle offset
10 | #
11 | # HBB 970522: factored out common factor 1e9 from c?? into the
12 | # function, to improve the fit convergence. Fit parameters were
13 | # just too grossly different before.
14 |
15 | rho = 1000.0 # density in kg/m3
16 |
17 | phi(x) = (x - phi0)/360.0*2.0*pi
18 |
19 | main(x) = c11*sin(phi(x))**2 + c33*cos(phi(x))**2 + c44
20 | mixed(x) = sqrt( ((c11-c44)*sin(phi(x))**2 \
21 | +(c44-c33)*cos(phi(x))**2)**2 \
22 | +(2.0*(c13+c44)*sin(phi(x))*cos(phi(x)))**2 )
23 |
24 | vlong(x) = sqrt(1.0/2.0/rho*1e9*(main(x) + mixed(x)))
25 | vtrans(x) = sqrt(1.0/2.0/rho*1e9*(main(x) - mixed(x)))
26 |
27 | # When we read the file in, we set y=index, and we use
28 | # y in this (pseudo) 3d fit to choose an x function
29 |
30 | f(x,y) = y==1 ? vlong(x) : vtrans(x)
31 |
--------------------------------------------------------------------------------
/gnuplot/demo/nonlinear4.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Nonlinear color axis
3 | # Confirm equivalence of "set log cb" and
4 | # "set nonlinear cb via log10(z) inv 10**z"
5 | #
6 |
7 | set style function pm3d
8 | set palette cubehelix negative
9 | unset key
10 | set title offset 0, -3
11 | set view 65, 34, 1.00627, 1.41667
12 | unset border
13 | unset xtics; unset ytics
14 | set cbtics add (450) offset -0.5,0
15 | unset mcbtics
16 |
17 | set isosamples 20, 20
18 | set xyplane at 0
19 | set xrange [ -2.00 : 6.00 ]
20 | set yrange [ -5.00 : 5.00 ]
21 | set zrange [ -50.0 : 450. ]
22 | set cbrange [ 0.100 : 450. ]
23 |
24 | set multiplot layout 1,3
25 |
26 | # Linear colors
27 | #
28 | set title "Linear cb axis"
29 | set ztics
30 | set border 16
31 | splot 5 + 100.*sin(sqrt(x**2+y**2))/(x**2+y**2)
32 |
33 | # Log-scale colors
34 | #
35 | set title "set log cb"
36 | set logscale cb 10
37 | unset ztics
38 | unset border
39 | replot
40 |
41 | # Nonlinear color axis (log scale)
42 | #
43 | set title "set nonlinear cb\nvia log10(z) inv 10**z"
44 | unset log cb
45 | set nonlinear cb via log10(z) inverse 10**z
46 | set cbtics log
47 | replot
48 |
49 | unset multiplot
50 |
51 | pause -1 " to continue"
52 | reset
53 |
--------------------------------------------------------------------------------
/gnuplot/demo/srl.dat:
--------------------------------------------------------------------------------
1 | # Data file for world2.dem
2 | # Note: The N/S and E/W latitude and longitude flags are ignored,
3 | # so S and W require a minus sign instead
4 | #
5 | #Site Latitude Longitude GeV
6 | #---------------------------------------------------
7 | Paris 48:50N 2:20E 2.75
8 | Grenoble 45:21N 5:19E 6
9 | Ithaca 42:26N -76:30W 5.5
10 | Argonne 41:50N -87:41W 7
11 | Stanford 37:25N -122:09W 3
12 | "Baton Rouge" 30:26N -91:07W 1.3
13 | Hamburg 53:34N 10:02E 4.5
14 | Barcelona 41:18N 2:05E 2.5
15 | Upton 40:52N -72:53W 2.8
16 | Yerevan 40:11N 44:30E 3.2
17 | Campinas -23:00S -47:08W 1.35
18 | Trieste 45:39N 13:48E 2.4
19 | Grenoble 45:11N 5:43E 6
20 | Lund 55:06N 9:48E 1.5
21 | "Nishi Harima" 35N 135E 8
22 | Tsukuba 36:04N 140:08E 2.5
23 | Allaan 31:57N 35:57E 2.5
24 | Novosibirsk 55:02N 82:56E 0.8
25 | Pohang 36:01N 129:09E 2
26 | Villigen 47:32N 8:13E 2.4
27 | Daresbury 53:20N -2:40W 2
28 | Melbourne -37:42S 145E 3
29 | Saskatoon 52:07N -106:38W 2.9
30 | Shanghai 31:06N 121:22E 3.5
31 | Moscow 55:45N 37:36E 2.5
32 | #
33 |
--------------------------------------------------------------------------------
/gnuplot/demo/zerror.dem:
--------------------------------------------------------------------------------
1 | #
2 | # zerrorfill
3 | #
4 | set yrange [0.5:5.5]
5 | set zrange [1:*]
6 | set xyplane at 1
7 | set log z
8 | set key opaque box height 1 at screen .9, .8
9 | set border 127
10 | set grid x y z vertical
11 | set grid lt 1 lw 0.75 lc "grey"
12 | set xtics offset 0, -0.5
13 | set ytics offset -0.5, -0.5
14 |
15 | set title "splot with zerrorfill\n(note that plot ordering must be back-to-front)"
16 | splot for [k=5:1:-1] 'silver.dat' using 1:(k):2:3 with zerror lt black fc lt k title "k = ".k
17 |
18 | pause -1 "Hit return to continue"
19 | reset
20 | #
21 | # Reproduce surface1.dem plot #16
22 | # using zerrorfill instead of hidden3d parametric surfaces
23 | #
24 | set format z "%.1f"
25 | unset key
26 | set view 66, 200, 1, 1
27 | set xyplane 0
28 | unset xtics
29 | unset ytics
30 | set title "fence plot constructed with zerrorfill"
31 | set xlabel "X axis" rotate parallel
32 | set ylabel "Y axis" rotate parallel offset -4
33 | set pm3d depthorder base
34 | sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)
35 |
36 | set style fill solid noborder
37 | splot for [i=-5:4][y=-50:50:5] '+' using (i):($1/100.):(-1):(-1):(sinc($1/10., 1.+i)) with zerrorfill
38 |
39 | pause -1 "Hit return to continue"
40 | reset
41 |
--------------------------------------------------------------------------------
/gnuplot/demo/reflect.fnc:
--------------------------------------------------------------------------------
1 | #
2 | # Model function for Reflectivity evaluation
3 | #
4 |
5 | mu = 1.130469005513490E-001 # (cm-1) @ 17.479 keV
6 | t0 = 0.18 # cm
7 | tb = 11.417823202820120 * 0.01745329251994 # thetaB (radians)
8 | A = mu * t0 / cos(tb)
9 | P = (1 + (cos(2.*tb))**2) / 2
10 | Fhkl = sqrt(3.536346308456155**2 + (4.58815426260982e-4)**2) * 0.968
11 | r0 = 2.81794092e-13 # classical electron radius
12 | lambda = 7.09338062818239e-9 # Mo K in cm
13 | V = 1.62253546981499e-23
14 | P = (1. + (cos(2.*tb))**2) / 2.
15 | #
16 | # combine constants to avoid exponential overflow on systems with
17 | # D floating point format where exponential limits are ca. 10**(+/-38)
18 | # r0liV = r0 * lambda / V
19 | r0liV = 2.81794092*7.09338062818239/1.62253546981499e-1
20 | #
21 |
22 | W(x) = 1./(sqrt(2.*pi)*eta) * exp( -1. * x**2 / (2.*eta**2) )
23 | Y(tc) = tc/sin(tb) * Fhkl * r0liV
24 | f(tc)= (tanh(Y(tc)) + abs(cos(2.*tb)) * tanh(abs(Y(tc)*cos(2.*tb)))) / (Y(tc)*(1.+(cos(2.*tb))**2))
25 | Q(tc) = (r0*Fhkl/V)**2 * (lambda**3/sin(2.*tb)) * P * f(tc)
26 | a(x) = W(x) * Q(tc) / mu
27 |
28 | #
29 |
30 | R(x) = sinh(A*a(x)) * exp(-1.*A*(1.+a(x)))
31 |
--------------------------------------------------------------------------------
/gnuplot/demo/probably_tux.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Distortion of an image by plotting against probability scaled axes.
3 | # Each pixel is re-scaled based on distance from the center, where
4 | # the scale factor treats that distance as a Z score.
5 | #
6 | #set title "Probability axes: Scale image pixels by distance from center treated as a Z-score"
7 | set label 1 "Tux (probably)" font "Times:Bold"
8 | set label 1 at graph 0.5, 0.4 center front
9 |
10 | set xrange [-6:134]
11 | set yrange [-6:134]
12 | unset key
13 |
14 | if (!exists("sigma")) sigma = 20.
15 | center = 64. # because the image is 128x128
16 |
17 | if (!exists("ticinterval")) ticinterval = 1
18 |
19 | f(x) = norm((x-center)/sigma)
20 | g(x) = sigma*invnorm(x)+center
21 | tic(x) = center + sigma * x
22 |
23 | set xtics ("" 64)
24 | do for [i=-3:3:ticinterval] {
25 | set xtics add (sprintf("%dσ",i) tic(real(i)), "" tic(real(i)+.5) 1)
26 | }
27 | set ytics ("" 64)
28 | do for [i=-3:3:ticinterval] {
29 | set ytics add (sprintf("%dσ",i) tic(real(i)), "" tic(real(i)+.5) 1)
30 | }
31 | set tics out nomirror
32 |
33 | set nonlinear x via f(x) inverse g(x)
34 | set nonlinear y via f(y) inverse g(y)
35 |
36 | plot 'blutux.rgb' binary array=(128,128) flipy format='%uchar' with rgbimage pixels
37 |
38 |
--------------------------------------------------------------------------------
/gnuplot/demo/rgbalpha.dem:
--------------------------------------------------------------------------------
1 | set border linecolor rgb "gold"
2 | set key title "Plot style rgbalpha" textcolor rgb "gold"
3 | set key bottom left at screen .75, screen .75
4 | set key Left width -7 sample 1
5 |
6 | set object 1 rect from screen 0, 0 to screen 1, 1 behind \
7 | fc rgb "gray10" fillstyle solid 1.00 noborder
8 | set samples 128, 128
9 | set size ratio 0.95
10 | set bmargin at screen .1
11 | set tmargin at screen .9
12 | set lmargin at screen .1
13 |
14 |
15 | set xrange [ 0. : 128. ]
16 | set yrange [ 0. : 128. ]
17 |
18 | # Alpha = linear gradient on x
19 |
20 | plot 100.*(.4+sin(x/5.)/(x/5.)) lw 5 title 'solid line', \
21 | 'lena.rgb' binary array=(128,128) format="%uchar" flipy using 1:2:3:(2.*column(0)) \
22 | with rgbalpha title "Lena with linear\nalpha gradient"
23 |
24 | pause -1 "Hit return to continue"
25 |
26 | # Alpha = circular mask
27 |
28 | focus(x,y) = ((column(0)-x)**2 + (column(-1)-(127-y))**2) > 400 ? 0 : 255
29 |
30 | plot 100.*(.4+sin(x/5.)/(x/5.)) lw 5 title 'solid line', \
31 | 'lena.rgb' binary array=(128,128) format="%uchar" flipy using 1:2:3:(focus(70,50)) \
32 | with rgbalpha title "Lena with circular mask"
33 |
34 | pause -1 "Hit return to continue"
35 | reset
36 |
--------------------------------------------------------------------------------
/gnuplot/demo/hidden.dem:
--------------------------------------------------------------------------------
1 | #
2 | #
3 | set samples 20
4 | set isosamples 20
5 | set hidden3d
6 | set title "Hidden line removal of explicit surfaces"
7 |
8 |
9 | set xrange [-3:3]
10 | set yrange [-2:2]
11 | splot 1 / (x*x + y*y + 1)
12 | pause -1 "Hit return to continue (1)"
13 |
14 | set xrange [-1:1]
15 | set yrange [-1:1]
16 | splot x*y / (x**2 + y**2 + 0.1)
17 | pause -1 "Hit return to continue (2)"
18 |
19 | set view 70,45
20 | unset contour
21 | set xrange [-3:3]
22 | set yrange [-3:3]
23 | splot sin(x*x + y*y) / (x*x + y*y)
24 | pause -1 "Hit return to continue (3)"
25 |
26 | set view 60,30
27 | set xrange [-3:3]
28 | set yrange [-3:3]
29 | set zrange [-1:1]
30 | set ztics -1,0.5,1
31 | set grid z
32 | set border 4095
33 | splot sin(x) * cos(y)
34 | pause -1 "Hit return to continue (4)"
35 |
36 | unset grid
37 | set ztics autofreq
38 | set border 31
39 | set view 75,230
40 | set contour
41 | replot
42 | pause -1 "Hit return to continue (5)"
43 |
44 | set view 80,30,1,1
45 | set style data lines
46 | # autoranging loses the verticals
47 | set xrange [0:15]
48 | set yrange [0:15]
49 | splot "glass.dat" using 1
50 | pause -1 "Hit return to continue (6)"
51 |
52 | set view 50
53 | set grid
54 | replot
55 | pause -1 "Hit return to continue (7)"
56 |
57 | reset
58 |
59 |
--------------------------------------------------------------------------------
/gnuplot/demo/rgba_lines.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demonstrate use of RGBA (Alpha channel + RGB) colors for lines and filled areas.
3 | # Color is represented by 32 bits AARRGGBB (i.e. Alpha is in the high bits)
4 | # Alpha = 0 is opaque; Alpha = 255 is transparent
5 | # This is BACKWARDS from the convention used by 'set style fill TRANSPARENT SOLID'
6 | # It is also BACKWARDS from the convention used by 'with rgbalpha'
7 | #
8 | set angle degrees
9 | set style arrow 1 size screen 0.03,15,90 noborder
10 | set style arrow 1 lc rgb variable lw 3
11 |
12 | fade(i) = (int(255.*i/360.) << 24) + 0xEF8000
13 |
14 | set obj 1 rect from -.5,-.5 to -.3,0 fs solid fc rgb "#00bbbbbb" front
15 | set obj 2 rect from -.3,-.3 to -.1,0.2 fs solid fc rgb "#55bbbbbb" front
16 | set obj 3 rect from -.1,-.1 to .3,0.3 fs solid fc rgb "#aabbbbbb" front
17 | set obj 4 rect from .3,-.4 to .4,0.4 fs solid fc rgb "#22bbbbbb" back
18 | set obj 10 circle at 0.15, -0.15 radius 0.5 fs solid fc rgb "cyan" behind
19 |
20 |
21 | unset border
22 | unset xtics
23 | unset ytics
24 | unset key
25 | set xrange [-1:1]
26 | set yrange [-1:1]
27 | set size square
28 |
29 | plot sample [i=5:360:5] '+' using (0):(0):(cos(i)):(sin(i)):(fade(i)) \
30 | with vector as 1
31 |
32 | pause -1 "Hit return to continue"
33 | reset
34 |
--------------------------------------------------------------------------------
/gnuplot/demo/simple.dem:
--------------------------------------------------------------------------------
1 | # Requires data files "[123].dat" from this directory,
2 | # so change current working directory to this directory before running.
3 | # gnuplot> set term
4 | # gnuplot> load 'simple.dem'
5 | #
6 | set title "Simple Plots" font ",20"
7 | set key left box
8 | set samples 50
9 | set style data points
10 |
11 | plot [-10:10] sin(x),atan(x),cos(atan(x))
12 | pause -1 "Hit return to continue"
13 |
14 | set key right nobox
15 | set samples 100
16 | plot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))
17 | pause -1 "Hit return to continue"
18 |
19 | set key left box
20 | set samples 200
21 | plot [-3:5] asin(x),acos(x)
22 | pause -1 "Hit return to continue"
23 |
24 | plot [-30:20] besj0(x)*0.12e1 with impulses, (x**besj0(x))-2.5 with points
25 | pause -1 "Hit return to continue"
26 |
27 | set samples 400
28 | plot [-10:10] real(sin(x)**besj0(x))
29 | pause -1 "Hit return to continue"
30 |
31 | set key bmargin center horizontal
32 | plot [-5*pi:5*pi] [-5:5] real(tan(x)/atan(x)), 1/x
33 | pause -1 "Hit return to continue"
34 |
35 | set key left box
36 | set autoscale
37 | set samples 800
38 | plot [-30:20] sin(x*20)*atan(x)
39 | pause -1 "Hit return to continue"
40 |
41 | plot [-19:19] '1.dat'with impulses ,'2.dat' ,'3.dat' with lines
42 | pause -1 "Hit return to continue"
43 |
44 | reset
45 |
46 |
--------------------------------------------------------------------------------
/gnuplot/demo/matrix_every.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Exercise use of 'every' subsampling with image plots
3 | # This was a regression in 5.0.3
4 | #
5 |
6 | $Matrix << EOM
7 | 3 3 3 3 3 3 3
8 | 3 4 4 4 4 4 3
9 | 3 4 5 5 5 4 3
10 | 3 4 5 6 5 4 3
11 | 3 4 5 5 5 4 3
12 | 3 4 4 4 4 4 3
13 | 3 3 3 3 3 3 3
14 | EOM
15 |
16 | unset key
17 | set ticscale 0
18 | set border 0
19 | set xrange [-0.5:6.5]
20 | set yrange [-0.5:6.5]
21 | set grid lt -1
22 | set cbrange [3:6]
23 | unset colorbox
24 | set style textbox opaque
25 |
26 | set multiplot layout 2,2
27 |
28 | set title "Full 7x7 matrix"
29 | plot $Matrix matrix with image
30 |
31 | set title "Subsample columns by every ::2::4"
32 | stats $Matrix every ::2::4 matrix noout
33 | set xlabel sprintf("%d x %d submatrix", STATS_size_x, STATS_size_y)
34 | set xlabel offset 0,1.5 boxed
35 | plot $Matrix every ::2::4 matrix with image
36 |
37 | set title "Subsample rows by every :::2::4"
38 | stats $Matrix every :::2::4 matrix noout
39 | set xlabel sprintf("%d x %d submatrix", STATS_size_x, STATS_size_y)
40 | set xlabel offset 0,1.5 boxed
41 | plot $Matrix every :::2::4 matrix with image
42 | set title "Sample alternate columns by every 2"
43 |
44 | set xtics 2
45 | set xrange [-1:7]
46 | unset xlabel
47 | plot $Matrix every 2 matrix with image
48 |
49 | unset multiplot
50 |
51 | pause -1 " to continue"
52 |
53 | reset
54 |
--------------------------------------------------------------------------------
/gnuplot/demo/mouselab_2.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Wait for keystroke in plot window
3 | # Return to caller on or , otherwise loop
4 | #
5 | while (MOUSE_KEY != 27 && MOUSE_CHAR ne " ") {
6 |
7 | #
8 | # Add new printable character to label
9 | #
10 | if (31 < MOUSE_KEY && MOUSE_KEY < 127) {
11 | LABEL = LABEL.MOUSE_CHAR
12 | }
13 | #
14 | # Add newline to label if input character was
15 | #
16 | if (MOUSE_KEY == 13) {
17 | LABEL = LABEL."\n"
18 | }
19 | #
20 | # Delete previous character from label on or
21 | #
22 | if (MOUSE_KEY == 8 || MOUSE_KEY == 127) {
23 | LABEL = LABEL[1:strlen(LABEL)-1]
24 | }
25 | #
26 | # Allow arrow keys to tweak label position
27 | # The GP_Up GP_Right GP_Down GP_Left (1008-1011) are defined in mousecmn.h
28 | #
29 | if (MOUSE_KEY == 1009) { LABEL_Y = LABEL_Y + (GPVAL_Y_MAX-GPVAL_Y_MIN)/100. }
30 | if (MOUSE_KEY == 1010) { LABEL_X = LABEL_X + (GPVAL_X_MAX-GPVAL_X_MIN)/100. }
31 | if (MOUSE_KEY == 1011) { LABEL_Y = LABEL_Y - (GPVAL_Y_MAX-GPVAL_Y_MIN)/100. }
32 | if (MOUSE_KEY == 1008) { LABEL_X = LABEL_X - (GPVAL_X_MAX-GPVAL_X_MIN)/100. }
33 | #
34 | # Update label
35 | #
36 | set label LID LABEL at LABEL_X, LABEL_Y
37 | replot
38 | #
39 | pause mouse key
40 |
41 | } # end of loop waiting for or
42 |
--------------------------------------------------------------------------------
/gnuplot/demo/boxclusters.dem:
--------------------------------------------------------------------------------
1 | #
2 | # The "histograms" style automates the construction of barcharts with
3 | # various stacking and clustering options. But it doesn't offer much
4 | # choice for coloring.
5 | #
6 | # This demo show using the "with boxes" plot style to generate clustered
7 | # histograms with individual box coloring generated by a user-provided function.
8 | # This could, for example, depend on data from other columns in the input.
9 | #
10 |
11 | set title "Clustered bar graph with individual colors\nspecified via plotstyle 'boxes'"
12 | set title boxed offset 0,-3 font ",15"
13 | set style fill solid border lt -1
14 | set style textbox opaque noborder
15 | set boxwidth 1.0 abs
16 | ClusterSize = 15
17 | unset key
18 |
19 | set yrange [0:7]
20 | set xrange [-2:60]
21 | set border 0
22 | category = "Yan Tan Tethera Methera Pimp"
23 | set xtics scale 0 ()
24 | set ytics scale 0 nomirror
25 | set grid y
26 | set colorb horizontal user origin .05, .05 size .9, .05
27 | set palette cubehelix
28 | set bmargin at screen 0.2
29 | set tmargin at screen 0.9
30 |
31 | set for [i=1:4] xtics add (word(category,i) 5+(i-1)*ClusterSize)
32 |
33 | xcoord(i) = i*ClusterSize + column(1)
34 | color(i) = rand(0)
35 |
36 | plot for [i=0:3] 'candlesticks.dat' \
37 | using (xcoord(i)):(column(i+2)):(color(i)) with boxes lc palette z
38 |
39 | pause -1 " to continue"
40 | reset
41 |
--------------------------------------------------------------------------------
/gnuplot/demo/approximate.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Show use of pseudodata mechanism '+' to use plot styles with more than
3 | # one relevant value per x coordinate. In this example we use the style
4 | # "filledcurves" to show the difference between two analytic functions.
5 | # This corresponds to the specification of multiple columns in the
6 | # 'using' option for input from data files.
7 | #
8 | #
9 | approx_1(x) = x - x**3/6
10 | approx_2(x) = x - x**3/6 + x**5/120
11 | approx_3(x) = x - x**3/6 + x**5/120 - x**7/5040
12 |
13 | label1 = "x - {x^3}/3!"
14 | label2 = "x - {x^3}/3! + {x^5}/5!"
15 | label3 = "x - {x^3}/3! + {x^5}/5! - {x^7}/7!"
16 |
17 | #
18 | set termoption enhanced
19 | save_encoding = GPVAL_ENCODING
20 | set encoding utf8
21 | #
22 | set title "Polynomial approximation of sin(x)"
23 | set key Left center top reverse
24 | set xrange [ -3.2 : 3.2 ]
25 | set xtics ("-π" -pi, "-π/2" -pi/2, 0, "π/2" pi/2, "π" pi)
26 | set format y "%.1f"
27 | set samples 500
28 | set style fill solid 0.4 noborder
29 |
30 | plot '+' using 1:(sin($1)):(approx_1($1)) with filledcurve title label1 lt 3, \
31 | '+' using 1:(sin($1)):(approx_2($1)) with filledcurve title label2 lt 2, \
32 | '+' using 1:(sin($1)):(approx_3($1)) with filledcurve title label3 lt 1, \
33 | sin(x) with lines lw 1 lc rgb "black"
34 |
35 | pause -1 "Hit return to continue"
36 |
37 | set encoding save_encoding
38 | reset
39 |
--------------------------------------------------------------------------------
/machine_epsilon.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Иван Ильин on 17.09.2020.
3 | //
4 |
5 | #include
6 | #include
7 | #include "gnuplot.h"
8 | #include "vemath.h"
9 |
10 | using namespace std;
11 |
12 | int main() {
13 |
14 | float epsilon_float = 3.0f;
15 | double epsilon_double = 3.0f;
16 |
17 | while (1.0f + epsilon_float / 2.0f != 1.0f) {
18 | epsilon_float /= 2.0f;
19 | }
20 |
21 | while (1.0f + epsilon_double / 2.0f != 1.0f) {
22 | epsilon_double /= 2.0f;
23 | }
24 |
25 | cout << "--------------------------------------------" << endl;
26 |
27 | cout << "Epsilon float = " << epsilon_float << endl;
28 | cout << "Epsilon double = " << epsilon_double << endl;
29 |
30 | cout << "--------------------------------------------" << endl;
31 |
32 | cout << "1 : 1 + E/2 : 1 + E : 1 + E + E/2 (for float)" << endl;
33 | printf("%20.16f ", 1.0f);
34 | printf("%20.16f ", 1.0f + epsilon_float / 2.0f);
35 | printf("%20.16f ", 1.0f + epsilon_float);
36 | printf("%20.16f ", 1.0f + epsilon_float + epsilon_float / 2.0f);
37 |
38 | cout << endl << "1 : 1 + E/2 : 1 + E : 1 + E + E/2 (for double)" << endl;
39 | printf("%20.20f ", 1.0f);
40 | printf("%20.20f ", 1.0f + epsilon_double / 2.0f);
41 | printf("%20.20f ", 1.0f + epsilon_double);
42 | printf("%20.20f ", 1.0f + epsilon_double / 2.0f + epsilon_double);
43 | }
--------------------------------------------------------------------------------
/gnuplot/demo/immigration.dat:
--------------------------------------------------------------------------------
1 | # IMMIGRATION BY REGION AND SELECTED COUNTRY OF LAST RESIDENCE
2 | #
3 | Region Austria Hungary Belgium Czechoslovakia Denmark France Germany Greece Ireland Italy Netherlands Norway Sweden Poland Portugal Romania Soviet_Union Spain Switzerland United_Kingdom Yugoslavia Other_Europe TOTAL
4 | 1891-1900 234081 181288 18167 - 50231 30770 505152 15979 388416 651893 26758 95015 226266 96720 27508 12750 505290 8731 31179 271538 - 282 3378014
5 | 1901-1910 668209 808511 41635 - 65285 73379 341498 167519 339065 2045877 48262 190505 249534 - 69149 53008 1597306 27935 34922 525950 - 39945 7387494
6 | 1911-1920 453649 442693 33746 3426 41983 61897 143945 184201 146181 1109524 43718 66395 95074 4813 89732 13311 921201 68611 23091 341408 1888 31400 4321887
7 | 1921-1930 32868 30680 15846 102194 32430 49610 412202 51084 211234 455315 26948 68531 97249 227734 29994 67646 61742 28958 29676 339570 49064 42619 2463194
8 | 1931-1940 3563 7861 4817 14393 2559 12623 144058 9119 10973 68028 7150 4740 3960 17026 3329 3871 1370 3258 5512 31572 5835 11949 377566
9 | 1941-1950 24860 3469 12189 8347 5393 38809 226578 8973 19789 57661 14860 10100 10665 7571 7423 1076 571 2898 10547 139306 1576 8486 621147
10 | 1951-1960 67106 36637 18575 918 10984 51121 477765 47608 43362 185491 52277 22935 21697 9985 19588 1039 671 7894 17675 202824 8225 16350 1325727
11 | 1961-1970 20621 5401 9192 3273 9201 45237 190796 85969 32966 214111 30606 15484 17116 53539 76065 3531 2465 44659 18453 213822 20381 11604 1124492
12 |
--------------------------------------------------------------------------------
/gnuplot/demo/candlesticks.dem:
--------------------------------------------------------------------------------
1 | reset
2 | #
3 | set xrange [0:11]
4 | set yrange [0:10]
5 | #
6 | set title "candlesticks with open boxes (default)"
7 | plot 'candlesticks.dat' using 1:3:2:6:5 with candlesticks
8 | #
9 | pause -1 "Hit return to continue"
10 | #
11 | set title "candlesticks with specified boxwidth"
12 | set boxwidth 0.2
13 | replot
14 | #
15 | pause -1 "Hit return to continue"
16 | #
17 | set title "candlesticks with style fill solid"
18 | set style fill solid
19 | set boxwidth 0.2
20 | replot
21 | #
22 | pause -1 "Hit return to continue"
23 | #
24 | set title "candlesticks showing both states of open/close"
25 | set style fill empty
26 | set boxwidth 0.2
27 | plot 'candlesticks.dat' using 1:(int($0)%3?$3:$5):2:6:(int($0)%3?$5:$3) with candlesticks title "open < close", \
28 | NaN with boxes lt 1 fs solid 1 title "close < open"
29 | #
30 | pause -1 "Hit return to continue"
31 | #
32 | set title "box-and-whisker plot adding median value as bar"
33 | set style fill empty
34 | plot 'candlesticks.dat' using 1:3:2:6:5 with candlesticks lt 3 lw 2 title 'Quartiles', \
35 | '' using 1:4:4:4:4 with candlesticks lt -1 lw 2 notitle
36 | #
37 | pause -1 "Hit return to continue"
38 | #
39 | set title "box-and-whisker with median bar and whiskerbars"
40 | plot 'candlesticks.dat' using 1:3:2:6:5 with candlesticks lt 3 lw 2 title 'Quartiles' whiskerbars, \
41 | '' using 1:4:4:4:4 with candlesticks lt -1 lw 2 notitle
42 | pause -1 "Hit return to continue"
43 | #
44 |
45 | reset
46 |
47 |
--------------------------------------------------------------------------------
/gnuplot/demo/linkedaxes.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo for non-linear linked axes.
3 | # In this example x2 is proportional to 1/x.
4 | # X axis is X-ray energy in eV; x2 axis is wavelength in Angstroms.
5 | #
6 | # The scattering data are pulled from the web using the GET
7 | # command, which is provided by the perl-libwww module.
8 | # You could replace it with wget or some other download tool, or you
9 | # could manually download the data first and then plot from the local copy.
10 | #
11 | # For more information on the plot itself see
12 | # http://skuld.bmsc.washington.edu/scatter
13 | #
14 | # Ethan A Merritt - August 2012
15 | #
16 | set encoding utf8
17 | set key outside Left
18 | set bmargin 5
19 | set tmargin 6
20 | set style data lines
21 | set tics in
22 | set ticslevel 0.5
23 | set xlabel "X-ray energy in eV"
24 | set format y '%5.1fe'
25 | set title " Anomalous scattering factors "
26 | set xrange [9000:14400]
27 | set offset 0,0,1.0,0
28 | set xtics nomirror
29 | set link x via 12398./x inverse 12398./x
30 |
31 | set x2label "X-ray wavelength in Å"
32 | set x2tics 0.1 format "%.1f Å" nomirror
33 |
34 | Brdata = "< GET http://skuld.bmsc.washington.edu/scatter/data/Br.dat"
35 | Tadata = "< GET http://skuld.bmsc.washington.edu/scatter/data/Ta.dat"
36 |
37 | plot Brdata volatile using 1:3 title 'Br f"' lt 1 lw 3, \
38 | '' volatile using 1:2 title "Br f'" lt 1 lw 1, \
39 | Tadata volatile using 1:3 title 'Ta f"' lt 2 lw 3, \
40 | '' volatile using 1:2 title "Ta f'" lt 2 lw 1
41 |
42 | pause -1 "Hit return to continue"
43 | reset
44 |
--------------------------------------------------------------------------------
/gnuplot/demo/steps.dem:
--------------------------------------------------------------------------------
1 | # This file will serve as the datafile used in demonstrating the
2 | # "plot with steps" option. Here is a gnuplot input file
3 | # which uses "plot with steps", inverse error function, normal
4 | # distribution function, and the inverse normal distribution
5 | # function.
6 |
7 | set title "Compare steps, fsteps and histeps"
8 | plot [0:12][0:13] "steps.dat" notitle with points, \
9 | "steps.dat" title 'steps' with steps, \
10 | 'steps.dat' title 'fsteps' with fsteps, \
11 | 'steps.dat' title 'histeps' with histeps
12 |
13 | pause -1 "Hit return for demonstration of automatic histogram creation"
14 | set title "Histogram built from unsorted data by 'smooth frequency'"
15 | set ylabel 'counts per bin'
16 | set xlabel 'bins'
17 | plot 'hemisphr.dat' u (floor($1*20)):(1) smooth frequency with histeps
18 |
19 | pause -1 "Hit return to see the same plot with fillsteps"
20 | set style fill solid 1.0
21 | plot 'hemisphr.dat' u (floor($1*20)):(1) smooth freq with fillsteps title "with fillsteps"
22 |
23 | pause -1 "Hit return for normal distribution function."
24 |
25 | set title "Normal Distribution Function"
26 | unset xlabel
27 | unset ylabel
28 | plot [-3:3][0:1] norm(x)
29 |
30 | pause -1 "Hit return for inverse error function."
31 | set title "Inverse Error Function"
32 | plot [-1:1] inverf(x)
33 |
34 | pause -1 "Hit return for inverse normal distribution function."
35 | set title "Inverse Normal Distribution Function"
36 | plot [0:1] invnorm(x)
37 |
38 | pause -1 "Press return to continue"
39 | reset
40 |
--------------------------------------------------------------------------------
/gnuplot/share/gnuplotrc:
--------------------------------------------------------------------------------
1 | ###
2 | ### Gnuplot version 5.0 initialization file
3 | ### This file is loaded by gnuplot at the start of each run.
4 | ### It is provided as a template, with all commands commented out.
5 | ### Uncomment and customize lines for local use.
6 | ### Any commands placed here will affect all users.
7 | ### To customize gnuplot's initial state for an individual user,
8 | ### place commands in a private file ~/.gnuplot instead.
9 |
10 | ###
11 | ### Language initialization
12 | ###
13 | # set locale
14 | # set encoding locale
15 |
16 | ###
17 | ### Default line colors and repeat cycle
18 | ###
19 | # set linetype 1 lc rgb "dark-violet" lw 1
20 | # set linetype 2 lc rgb "#009e73" lw 1
21 | # set linetype 3 lc rgb "#56b4e9" lw 1
22 | # set linetype 4 lc rgb "#e69f00" lw 1
23 | # set linetype 5 lc rgb "#f0e442" lw 1
24 | # set linetype 6 lc rgb "#0072b2" lw 1
25 | # set linetype 7 lc rgb "#e51e10" lw 1
26 | # set linetype 8 lc rgb "black" lw 1
27 | # set linetype cycle 8
28 |
29 | ###
30 | ### Initialize the default loadpath for shared gnuplot scripts and data.
31 | ### Please confirm that this path is correct before uncommented the line below.
32 | ###
33 | # set loadpath "/usr/local/share/gnuplot/4.7/demo"
34 |
35 | ###
36 | ### Some commonly used functions that are not built in
37 | ###
38 | # sinc(x) = sin(x)/x
39 | # rgb(r,g,b) = sprintf("#%06x",256.*256.*255.*r+256.*255.*g+255.*b)
40 | # hsv(h,s,v) = sprintf("#%06x",hsv2rgb(h,s,v))
41 |
42 | ###
43 | ### Other preferences
44 | ###
45 | # set clip two
46 |
47 |
--------------------------------------------------------------------------------
/gnuplot/demo/transparent.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Example of transparent fill areas
3 | # Ethan A Merritt - Aug 2006
4 | # NB:
5 | # Not all terminal types support transparency
6 | # Assumes UTF-8 support for plot titles
7 | #
8 | save_encoding = GPVAL_ENCODING
9 | set encoding utf8
10 | set style fill solid 1.0 noborder
11 | set style function filledcurves y1=0
12 |
13 | Gauss(x,mu,sigma) = 1./(sigma*sqrt(2*pi)) * exp( -(x-mu)**2 / (2*sigma**2) )
14 | d1(x) = Gauss(x, 0.5, 0.5)
15 | d2(x) = Gauss(x, 2., 1.)
16 | d3(x) = Gauss(x, -1., 2.)
17 |
18 | set xrange [-5:5]
19 | set yrange [0:1]
20 |
21 | unset colorbox
22 |
23 | set key title "Gaussian Distribution"
24 | set key top left Left reverse samplen 1
25 |
26 | #set obj 1 rect from graph 0,0 to graph 1,1
27 | #set obj 1 rect back fs solid 0.25 fc lt 4
28 |
29 | set title "Solid filled curves"
30 | plot d1(x) fs solid 1.0 lc rgb "forest-green" title "μ = 0.5 σ = 0.5", \
31 | d2(x) lc rgb "gold" title "μ = 2.0 σ = 1.0", \
32 | d3(x) lc rgb "dark-violet" title "μ = -1.0 σ = 2.0"
33 |
34 | pause -1 "Hit return to continue"
35 |
36 | set style fill transparent solid 0.5 noborder
37 | set title "Transparent filled curves"
38 | replot
39 |
40 | pause -1 "Hit return to continue"
41 |
42 | set style fill pattern 4 bo
43 | set title "Pattern-filled curves"
44 | replot
45 |
46 | pause -1 "Hit return to continue"
47 |
48 | set style fill transparent pattern 4 bo
49 | set title "Transparent pattern-filled curves"
50 | replot
51 |
52 | pause -1 "Hit return to continue"
53 | set encoding save_encoding
54 | reset
55 |
--------------------------------------------------------------------------------
/gnuplot/demo/polar.dem:
--------------------------------------------------------------------------------
1 | # Various ways of plotting functions in polar coordinates
2 | #
3 | unset border
4 | set clip
5 | set polar
6 | set xtics axis nomirror
7 | set ytics axis nomirror
8 | unset rtics
9 | set samples 160
10 | set zeroaxis
11 | set trange [0:2*pi]
12 | set title "Three circles (with aspect ratio distortion)"
13 | plot .5,1,1.5
14 | pause -1 "Hit return to continue"
15 | set title ""
16 | set key box
17 |
18 | plot cos(2*t)
19 | pause -1 "Hit return to continue"
20 |
21 | plot 2*sqrt(cos(t)),-2*sqrt(cos(t))
22 | pause -1 "Hit return to continue"
23 |
24 | plot sin(4*t),cos(4*t)
25 | set offset 0,0,0,0
26 | pause -1 "Hit return to continue"
27 |
28 | set xrange [-5:5]
29 | set yrange [-5:5]
30 | plot t/cos(3*t)
31 | pause -1 "Hit return to continue"
32 | set autoscale
33 |
34 | plot 1-sin(t)
35 | pause -1 "Hit return to continue"
36 |
37 | set trange [0:12*pi]
38 | plot 2*t
39 | pause -1 "Hit return to continue"
40 |
41 | butterfly(x)=exp(cos(x))-2*cos(4*x)+sin(x/12)**5
42 | set samples 800
43 | set title "Butterfly"
44 | unset key
45 | plot butterfly(t)
46 | pause -1 "Hit return to continue"
47 | reset
48 |
49 | set polar
50 | set grid polar
51 | unset xtics
52 | unset ytics
53 | set border 0
54 | set style fill solid 0.5
55 | set rrange [0.1 : 4]
56 | set size square
57 | set key title "bounding radius 2.5"
58 | set key outside top right samplen 0.7
59 |
60 | plot 3.+sin(t)*cos(5*t) with filledcurve above r=2.5 notitle,\
61 | 3.+sin(t)*cos(5*t) with line
62 |
63 | pause -1 "Hit return to continue"
64 | # undo what we've done above
65 | reset
66 |
--------------------------------------------------------------------------------
/gnuplot/demo/running_avg.dem:
--------------------------------------------------------------------------------
1 | #
2 | # This script demonstrates the use of assignment operators and
3 | # sequential expression evaluation to track data points as they
4 | # are read in.
5 | #
6 | # We use the '=' and ',' operators to track the running total
7 | # and previous 5 values of a stream of input data points.
8 | #
9 | # Ethan A Merritt - August 2007
10 | #
11 | # Define a function to calculate average over previous 5 points
12 | #
13 | set title \
14 | "Demonstrate use of assignment and serial evaluation operators\n" \
15 | . "to accumulate statistics as successive data lines are read in\n"
16 | set key invert box center right reverse Left
17 | set xtics nomirror
18 | set ytics nomirror
19 | set border 3
20 |
21 | samples(x) = $0 > 4 ? 5 : ($0+1)
22 | avg5(x) = (shift5(x), (back1+back2+back3+back4+back5)/samples($0))
23 | shift5(x) = (back5 = back4, back4 = back3, back3 = back2, back2 = back1, back1 = x)
24 |
25 | #
26 | # Initialize a running sum
27 | #
28 | init(x) = (back1 = back2 = back3 = back4 = back5 = sum = 0)
29 |
30 | #
31 | # Plot data, running average and cumulative average
32 | #
33 |
34 | datafile = 'silver.dat'
35 | set xrange [0:57]
36 |
37 | set style data linespoints
38 |
39 | plot sum = init(0), \
40 | datafile using 0:2 title 'data' lw 2 lc rgb 'forest-green', \
41 | '' using 0:(avg5($2)) title "running mean over previous 5 points" pt 7 ps 0.5 lw 1 lc rgb "blue", \
42 | '' using 0:(sum = sum + $2, sum/($0+1)) title "cumulative mean" pt 1 lw 1 lc rgb "dark-red"
43 |
44 | pause -1 "Hit return to continue"
45 |
46 | reset
47 |
--------------------------------------------------------------------------------
/gnuplot/demo/nonlinear1.dem:
--------------------------------------------------------------------------------
1 | # This example shows how a nonlinear axis definition can be used to
2 | # create a "broken axis". X coordinates 0-100 are at the left,
3 | # X coordinates 500-1000 are at the right, there is a small gap between them.
4 | # So long as no data points with (100 < x < 500) are plotted, this works as expected.
5 | #
6 | # f(x) maps x axis (discontinuous) to shadow axis coords (continuous linear range [0:1000])
7 | # g(x) maps shadow axis coords to x axis readout
8 | #
9 | set title "A 'broken' x axis can be defined using 'set nonlinear x'"
10 |
11 | # Define the broken-axis mapping
12 | axis_gap = 25.
13 | f(x) = (x <= 100) ? x : (x < 500) ? NaN : (x - 400 + axis_gap)
14 | g(x) = (x <= 100) ? x : (x < 100 + axis_gap) ? NaN : (x + 400 - axis_gap)
15 | set xrange [15:600] noextend
16 | set nonlinear x via f(x) inverse g(x)
17 |
18 | set xtics 50.
19 | set xtics rotate by -90 nomirror
20 | set ytics nomirror
21 | set border 3
22 | unset key
23 |
24 | # Creation of the broken axis marks (this should be automated)
25 | set arrow 500 from 100, graph 0 to 500, graph 0 nohead lt 500 lw 2 lc bgnd front
26 | set arrow 501 from 100, graph 0 length graph .01 angle 75 nohead lw 2 front
27 | set arrow 502 from 100, graph 0 length graph -.01 angle 75 nohead lw 2 front
28 | set arrow 503 from 500, graph 0 length graph .01 angle 75 nohead lw 2 front
29 | set arrow 504 from 500, graph 0 length graph -.01 angle 75 nohead lw 2 front
30 |
31 | plot 'silver.dat' with yerrorbars lw 2, '' with lines
32 | #
33 | pause -1 " to continue"
34 | reset
35 |
--------------------------------------------------------------------------------
/gnuplot/demo/scatter.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Simple demo of scatter data conversion to grid data.
3 | #
4 |
5 | set title "Simple demo of scatter data conversion to grid data"
6 | unset hidden3d
7 | set ticslevel 0.5
8 | set view 60,30
9 | set autoscale
10 | set parametric
11 | set style data points
12 | set xlabel "data style point - no dgrid"
13 | set key box
14 | splot "hemisphr.dat"
15 | pause -1 "Hit return to continue (1)"
16 |
17 | set dgrid3d 10,10,1
18 | set xlabel " data style lines, dgrid3d 10,10,1"
19 | set style data lines
20 | splot "hemisphr.dat"
21 | pause -1 "Hit return to continue (2)"
22 |
23 | set dgrid3d ,,4
24 | set xlabel " data style lines, dgrid3d ,,4 "
25 | set style data lines
26 | splot "hemisphr.dat"
27 | pause -1 "Hit return to continue (3)"
28 |
29 | set dgrid3d ,,16
30 | set xlabel " data style lines, dgrid3d ,,16"
31 | set style data lines
32 | splot "hemisphr.dat"
33 | pause -1 "Hit return to continue (4)"
34 |
35 | set contour
36 | set xlabel "data style lines, dgrid3d ,,16, contour"
37 | splot "hemisphr.dat"
38 | pause -1 "Hit return to continue (5)"
39 |
40 | unset dgrid3d
41 | set style data points
42 | set xlabel "data style points, nodgrid3d"
43 | splot "scatter2.dat"
44 | pause -1 "Hit return to continue (6)"
45 |
46 | set key nobox
47 | set dgrid3d ,,1
48 | set xlabel "data style lines, dgrid3d ,,1"
49 | set style data lines
50 | splot "scatter2.dat"
51 | pause -1 "Hit return to continue (7)"
52 |
53 | set dgrid3d ,,4
54 | set xlabel "data style lines, dgrid3d ,,4"
55 | set style data lines
56 | splot "scatter2.dat"
57 | pause -1 "Hit return to continue (8)"
58 | reset
59 |
--------------------------------------------------------------------------------
/besselsFunction.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Иван Ильин on 25.09.2020.
3 | //
4 |
5 | #include
6 | #include
7 | #include "gnuplot.h"
8 | #include "vemath.h"
9 |
10 | using namespace std;
11 | using namespace vemath;
12 |
13 | double bessel(double x, int m, double h) {
14 | double t = 0.0f;
15 | double S = 0.0f;
16 |
17 | while (t < PI) {
18 | S += cos(m*t - x*sin(t)) + 4.0f*cos(m*(t + h/2.0f) - x*sin(t + h/2.0f)) + cos(m*(t + h) - x*sin(t + h));
19 | t += h;
20 | }
21 |
22 | return S * h / 6.0f / PI;
23 | }
24 |
25 | double bessel0(double x, double h) {
26 | return bessel(x, 0, h);
27 | }
28 |
29 | double bessel1(double x, double h) {
30 | return bessel(x, 1, h);
31 | }
32 |
33 | double dbessel0(double x, double h) {
34 | return (bessel0(x+h, h) - bessel0(x-h, h))/(2.0f*h);
35 | }
36 |
37 | int main() {
38 |
39 | ComplexPlot errors_with_diff_h;
40 |
41 | double h = 0.000001f;
42 | int N = 10;
43 |
44 |
45 | while (h <= 1) {
46 |
47 | ComplexPlot errors;
48 | for(int i = 0; i < N; i++) {
49 | double x = 2.0f * PI * i / N;
50 | errors.push(x, {abs(dbessel0(x, h) + bessel1(x, h)),0});
51 | }
52 |
53 | errors_with_diff_h.push(log(h), {log(errors.sumReal()), 0});
54 |
55 | h *= 10;
56 | }
57 |
58 | saveVectorPoint2DToFile(errors_with_diff_h.real(), "errors_with_diff_h.dat");
59 |
60 | // GRAPH PLOT
61 | GnuplotPipe gp;
62 | //gp.sendLine(R"(set multiplot layout 2, 2)");
63 |
64 | gp.sendLine(R"(plot "errors_with_diff_h.dat" with lines)");
65 | }
66 |
--------------------------------------------------------------------------------
/gnuplot/demo/animate2.dem:
--------------------------------------------------------------------------------
1 | #
2 | # demo for creating GIF animation and illustrating saving images to
3 | # file one pixel to one pixel
4 | #
5 | # A combination of what was animate.dem and world2.dem with the
6 | # addition of saving the rotated image to an animated GIF.
7 | # Requires GIF_ANIMATION
8 | #
9 | # History:
10 | # - 1. 3. 2006 Dan Sebald: 1st version
11 | # 07 Jan 2006 Ethan Merritt: Revise to assume terminal type is set by caller
12 | #
13 |
14 | # Caller must set terminal type.
15 | # Example of intended use:
16 | # set term gif animate transparent opt delay 10 size 200,200 background rgb 'black'
17 |
18 | unset title
19 | unset key
20 | unset xtics
21 | unset ytics
22 | unset ztics
23 | set border 0
24 | set hidden3d nooffset
25 | set parametric
26 | set angles degrees
27 | set samples 64,64
28 | set isosamples 13,13
29 | set mapping spherical
30 | set dummy u,v
31 | set urange [ -90.0000 : 90.0000 ] noreverse nowriteback
32 | set vrange [ 0.00000 : 360.000 ] noreverse nowriteback
33 | set style data line
34 |
35 | # Defines for gnuplot.rot script
36 | limit_iterations=72
37 | xrot=60
38 | xrot_delta = 0
39 | zrot=136
40 | zrot_delta = 355
41 | xview(xrot)=xrot
42 | zview(zrot)=zrot
43 | set view xview(xrot), zview(zrot), 1.5, 1
44 | set size square
45 |
46 | splot cos(u)*cos(v),cos(u)*sin(v),sin(u) notitle with lines lt 5, \
47 | 'world.dat' notitle with lines lt 2 lw 3
48 |
49 | iteration_count=0
50 | xrot =(xrot+xrot_delta)%360
51 | zrot =(zrot+zrot_delta)%360
52 |
53 | load "gnuplot.rot"
54 |
55 | pause -1 "Hit return to continue"
56 |
57 | reset
58 |
59 | print "End of animate2 demo..."
60 |
--------------------------------------------------------------------------------
/gnuplot/demo/stats.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Exercise the "stats" command.
3 | # Skip this demo cleanly if the stats option was not configured.
4 | #
5 | if (!strstrt(GPVAL_COMPILE_OPTIONS,"+STATS")) {
6 | print "No support for stats command"
7 | } else {
8 |
9 | set title "Use of stats command to find min/max/mean before plotting\nOne data column"
10 |
11 | set style data line
12 | set offset 0,0,.5,.5
13 | set autoscale fix
14 | set key left Left
15 |
16 | stats 'orbital_elements.dat' index 1 using 2 prefix "A"
17 |
18 | set arrow 1 from A_index_min, graph 0.1 to A_index_min, A_min fill
19 | set arrow 2 from A_index_max, graph 0.9 to A_index_max, A_max fill
20 | set label 1 at A_index_min, graph 0.1 "min" center offset 0,-1
21 | set label 2 at A_index_max, graph 0.9 "max" center offset 0,1
22 |
23 | plot 'orbital_elements.dat' index 1 using 0:2 title " Data" lw 2, \
24 | A_mean title " Mean"
25 |
26 | pause -1 "Hit return to continue"
27 |
28 | set title "Use of stats command to find min/max/mean before plotting\nTwo data columns"
29 |
30 | f(x) = log(1+x)
31 |
32 | stats 'orbital_elements.dat' index 1 using (f($0)):2 prefix "B"
33 |
34 | set arrow 1 from B_pos_min_y, graph 0.1 to B_pos_min_y, B_min_y fill
35 | set arrow 2 from B_pos_max_y, graph 0.9 to B_pos_max_y, B_max_y fill
36 | set label 1 at B_pos_min_y, graph 0.1 "min" center offset 0,-1
37 | set label 2 at B_pos_max_y, graph 0.9 "max" center offset 0,1
38 |
39 | plot 'orbital_elements.dat' index 1 using (f($0)):2 title " Data" lw 2, \
40 | B_mean_y title " Mean", \
41 | B_slope * x + B_intercept title "Linear fit"
42 |
43 | pause -1 "Hit return to continue"
44 |
45 | reset
46 | }
47 |
--------------------------------------------------------------------------------
/gnuplot/demo/gnuplot.rot:
--------------------------------------------------------------------------------
1 | # A generic rotation routine for the gnuplot demos. In the commands
2 | # that load this file, the following should be defined:
3 | #
4 | # iteration_count: set iteration_count=0
5 | #
6 | # iteration_delay: pause between frames of iteration (defaults to 0.1 sec)
7 | #
8 | # limit_iterations: if set to a nonzero value, it'll stop after that
9 | # many iterations; if zero value, continues indefinitely
10 | #
11 | # xrot: the initial x rotation of the view
12 | #
13 | # xrot_delta: the amount to increment the x rotation for each new plot
14 | #
15 | # xview: function for generating x view value; for example
16 | # xview(xrot)=(50.+30.*sin((xrot%180)/180.*pi))
17 | #
18 | # zrot: the initial z rotation of the view
19 | #
20 | # zrot_delta: the amount to increment the z rotation for each new plot
21 | #
22 | # zview: function for generating z view value; for example
23 | # zview(zrot)=(60.+45.*sin(zrot/180.*pi))
24 | #
25 | # History:
26 | # - 1. 1. 2006 Dan Sebald: Made more generic so other demos could use
27 | # - ?. ?. ? Hans-Bernhard Broeker: Used to just turn round and round
28 | # by somewhat large steps. Now, it tumbles back and forth
29 | # smoothly.
30 | # - ?. ?. ? ?: Initial recursive script
31 | # Nov 2017 Switch to version 5 iteration syntax rather than reread
32 | # Add timed pause
33 |
34 | if (!(exists("iteration_delay"))) iteration_delay = 0.1
35 |
36 | while ((!limit_iterations) || (iteration_count<=limit_iterations)) {
37 | set view xview(xrot), zview(zrot)
38 | replot
39 | zrot = (zrot+zrot_delta) % 360
40 | xrot = (xrot+xrot_delta) % 360
41 | iteration_count = iteration_count + 1
42 | pause iteration_delay
43 | }
44 |
--------------------------------------------------------------------------------
/gnuplot/demo/callargs.dem:
--------------------------------------------------------------------------------
1 | #
2 | # This script exercises the ARG* variable-passing mechanism
3 | # used by the "call" command. Note that the only difference between
4 | # "load" and "call" is that "load" has no parameters (ARGC = 0).
5 | #
6 | if (!exists("ARGC")) {
7 | print "This copy of gnuplot does not support the ARG call method"
8 | exit
9 | }
10 | print "\nEntering ", ARG0, " with ", ARGC, " parameters"
11 | if (ARGC == 0) {
12 | undefine FOO
13 | BAZ = 5.67
14 | NOTAFUNCTION = "a string"
15 | print "Now exercise the call mechanism at line ", GPVAL_LINENO
16 | call ARG0 1.23e4 "string constant" FOO BAZ "3 + log(BAZ)" NOTAFUNCTION (1+3+4) pi
17 | } else {
18 | FOO = 1
19 | print "\n\tTest whether this copy of gnuplot also supports deprecated"
20 | print "\tcall parameter syntax "."$"."0 "."$"."1 "."$"."2 "."etc: "
21 | print "\t\t", exists("$2") ? "yes" : "no"
22 | show variable ARG
23 | print "ARG1 (numerical constant) came through as ", ARG1
24 | print " @ARG1 = ", @ARG1
25 | print " (ARG1 == @ARG1) is ", (ARG1 == @ARG1) ? "TRUE" : "FALSE"
26 | print "ARG2 (string constant) came through as ", ARG2
27 | print " words(ARG2) = ", words(ARG2)
28 | print "ARG3 (undefined variable FOO) came through as ", ARG3
29 | print "ARG4 (numerical variable BAZ=5.67) came through as ", ARG4
30 | print " @ARG4 = ", @ARG4
31 | print "ARG5 (quoted expression) came through as ", ARG5
32 | print " @ARG5 = ", @ARG5
33 | print "ARG6 (string variable) came through as ", ARG6
34 | print " words(ARG6) = ", words(ARG6)
35 | print "ARG7 (expression) came through as ", ARG7
36 | print "ARG8 (pi) came through as ", ARG8
37 | if (exists("ARGV")) { print "ARGV = ", ARGV }
38 | }
39 |
--------------------------------------------------------------------------------
/gnuplot/demo/arrowstyle.dem:
--------------------------------------------------------------------------------
1 | set xrange [-1000:1000]
2 | set yrange [-178:86]
3 | set tics scale 0
4 |
5 | set style line 1 lt 1 lw 2
6 | set style line 2 lt 3 lw 2
7 |
8 | set style arrow 1 head filled size screen 0.025,30,45 ls 1
9 | set style arrow 2 head nofilled size screen 0.03,15 ls 2
10 | set style arrow 3 head filled size screen 0.03,15,45 ls 1
11 | set style arrow 4 head filled size screen 0.03,15 ls 2
12 | set style arrow 5 heads noborder size screen 0.03,15,135 ls 1
13 | set style arrow 6 head empty size screen 0.03,15,135 ls 2
14 | set style arrow 7 nohead ls 1
15 | set style arrow 8 heads size screen 0.008,90 ls 2
16 |
17 | print ' We have defined the following arrowstyles:'
18 | show style arrow
19 |
20 | set for [i=1:8] arrow from -500, (-90 - i * 10) to 500, (-90 - i * 10) as i
21 | set for [i=1:8] label sprintf('arrowstyle %i:', i) at -520, (-90 - i * 10) right
22 |
23 | set samples 50
24 | set angles rad
25 | pos(x) = 69 * sin(0.01 * x)
26 | len(x) = 49 * sin(0.01 * x + pi/2)
27 |
28 | do for [i=1:8] {
29 | set title sprintf('Top: plot with vectors arrowstyle %i, Bottom: explicit arrows', i)
30 | plot '+' using 1:(pos(x)):(0):(len(x)) notitle with vectors arrowstyle i
31 | pause -1 "Hit return to continue"
32 | }
33 | #reset
34 |
35 | #
36 | # Show plot with data style vectors
37 | #
38 | set title "Plot 'file' with vectors "
39 | set key box opaque
40 | set xrange [*:*]
41 | set yrange [*:10]
42 | set for [i=1:8] style arrow i lc i
43 | plot '1.dat' using 1:2:(+1):(+1) with vectors lt 4 filled title 'filled', \
44 | '2.dat' using 1:2:(+1):(+1) with vectors lt 1 heads title 'double-headed', \
45 | '2.dat' using ($1):(2-$2/3):(+1):(+2.5):(int($0)%8 + 1) with vectors as var ti 'arrowstyle variable'
46 | #
47 | pause -1 "Hi return to continue"
48 | #
49 | reset
50 |
--------------------------------------------------------------------------------
/gnuplot/demo/pm3d_lighting.dem:
--------------------------------------------------------------------------------
1 | #
2 | # pm3d lighting model with specular highlighting
3 | #
4 | unset key
5 | unset border
6 | unset colorbox
7 | set view 33, 291, 1.2, 1.3
8 | set bmargin 0
9 | set tmargin 0
10 | set samples 200, 200
11 | set isosamples 200, 200
12 | set xyplane -0.05
13 | set format ""
14 | set grid x y lt black
15 | unset ztics
16 | set urange [ -20. : 20. ]
17 | set vrange [ -20. : 20. ]
18 | set zrange [ -0.25 : 0.5 ]
19 |
20 | set style fill solid 1.00 noborder
21 | set pm3d implicit at s depth noborder
22 |
23 | slice(x,y) = (x**2+y**2 < 10.0) ? 1.0 : (x**2+y**2 > 300.0) ? NaN : sin(abs(atan2(x,y)))
24 | sinc2(x,y) = sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)
25 | flatten(x,y) = sqrt(x**2+y**2)/5.
26 | F(x,y) = sinc2(x,y) * slice(x,y) * flatten(x,y)
27 |
28 | set title "pm3d lighting model with specular highlighting"
29 | set pm3d lighting primary 0.5 specular 0.2
30 | splot '++' using 1:2:(F($1,$2)):(0xAAEEEE) nosurface lc rgb variable
31 |
32 | pause -1 "Hit to continue"
33 | reset
34 |
35 | set title "PM3D surfaces with specular highlighting"
36 |
37 | unset border
38 | unset key
39 | set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind
40 | set object 1 rect fc rgb "gray" fillstyle solid 1.0 border -1
41 | set view 236, 339, 1.245, 1.0
42 | set isosamples 75, 75
43 | unset xtics
44 | unset ytics
45 | unset ztics
46 | set parametric
47 | set dummy u,v
48 | set urange [ -pi : pi ]
49 | set vrange [ -pi : pi ]
50 |
51 | set palette rgbformulae 8, 9, 7
52 | set style fill solid 1.0 noborder
53 | set pm3d depthorder noborder
54 | set pm3d lighting specular 0.6
55 |
56 | splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, \
57 | 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d
58 |
59 | pause -1 "Hit return to continue"
60 | reset
61 |
--------------------------------------------------------------------------------
/schrodinger_equation.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Иван Ильин on 17.09.2020.
3 | //
4 |
5 | #include
6 | #include
7 | #include "gnuplot.h"
8 | #include "vemath.h"
9 |
10 | using namespace std;
11 |
12 | double U_0 = 1.0f;
13 | double H = 1.0f;
14 | double m = 1.0f;
15 | double A = 1.0f;
16 |
17 | double ctg(double x) {
18 | return cos(x) / sin(x);
19 | }
20 |
21 | double f(double ksi) {
22 | return ctg(sqrt(2*(1-ksi)*m*A*A*U_0/(H*H))) - sqrt(-1 + 1/ksi);
23 | }
24 |
25 | double df(double ksi, double h, double fun(double ksi)) {
26 | return (fun(ksi+h) - fun(ksi-h))/(2*h);
27 | }
28 |
29 | int main() {
30 | double eps = 0.0000001f; // 10^-8
31 |
32 | double a = 0.1f, b = 0.9f; //study area
33 |
34 | double a1 = 0.1f, b1 = 0.0f;
35 | int n = 0;
36 |
37 | // Дихотомия
38 | while (abs(b - a) > eps) {
39 | n++;
40 | a1 = (a + b) / 2.0f;
41 | b1 = (a + b) / 2.0f;
42 | if (f(a1) * f(b) <= 0)
43 | a = a1;
44 | else
45 | b = b1;
46 | }
47 |
48 | // Метод простых итераций
49 | double ksi = 0, ksi1 = 0.2, la = 0.1;
50 | int k = 0;
51 |
52 | while ( abs(ksi - ksi1) > eps ){
53 | ksi = ksi1;
54 | ksi1 = ksi - la * f(ksi);
55 | k++;
56 | }
57 |
58 | // Метод Ньютона
59 | double ksiN = 0.0f, ksi1N = 0.5064675f, h = 0.0001f;
60 | int s = 0;
61 |
62 | while(abs(ksiN - ksi1N) > eps) {
63 | ksiN = ksi1N;
64 | ksi1N = ksiN - f(ksiN) / df(ksiN, h, f);
65 | s++;
66 | }
67 |
68 | cout << "Dichotomy method (n = " << n << ") E = " << a << endl;
69 | cout << "Simple iteration (n = " << k << ") E = " << ksi << endl;
70 | cout << "Newton method (n = " << s << ") E = " << ksiN << endl;
71 | }
--------------------------------------------------------------------------------
/gnuplot/demo/transparent_solids.dem:
--------------------------------------------------------------------------------
1 | set title "Interlocking Tori - PM3D surface with depth sorting and transparency"
2 |
3 | unset border
4 | unset key
5 | set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind
6 | set object 1 rect fc rgb "gray" fillstyle solid 1.0 border -1
7 | set view 64, 345, 1.24375, 0.995902
8 | set isosamples 50, 20
9 | unset xtics
10 | unset ytics
11 | unset ztics
12 | set parametric
13 | set dummy u,v
14 | set urange [ -pi : pi ]
15 | set vrange [ -pi : pi ]
16 |
17 | set palette rgbformulae 8, 9, 7
18 | set style fill transparent solid 0.30 border
19 | set pm3d depthorder border linecolor rgb "#a0a0f0" linewidth 0.5
20 |
21 | splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, \
22 | 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d
23 |
24 | pause -1 "Hit return to continue"
25 |
26 | unset title
27 | set label 1 "Kuen's Surface" at screen 0.57, 0.9
28 | set label 1 font "frscript,20"
29 | set pm3d depthorder border linetype -1 linewidth 0.5
30 | set style fill transparent solid 0.65 border
31 | set palette
32 | set hidden3d
33 |
34 | set ticslevel 0
35 | unset xtics ; unset ytics ; unset ztics
36 | unset border ; unset colorbox ; unset key
37 | set lmargin at screen 0.1
38 | set bmargin at screen 0.1
39 | set rmargin at screen 0.9
40 | set tmargin at screen 0.9
41 |
42 | set parametric
43 | set dummy u,v
44 | set urange [-4.5:4.5]
45 | set vrange [0.05:pi-0.05]
46 | set isosamples 51,51
47 | set view 122, 357, 1.35, 1.08
48 |
49 | a = 1.0
50 |
51 | x(u,v) = 2.*a*(cos(u)+u*sin(u))*sin(v) / (1+u**2.*(sin(v))**2)
52 | y(u,v) = 2.*a*(sin(u)-u*cos(u))*sin(v) / (1+u**2.*(sin(v))**2)
53 | z(u,v) = a*log(tan(v/2.))+2.*cos(v)/(1+u**2.*(sin(v))**2)
54 |
55 | splot x(u,v), y(u,v), z(u,v) with pm3d
56 |
57 | pause -1 "Hit return to continue"
58 | reset
59 |
--------------------------------------------------------------------------------
/gnuplot/demo/dashtypes.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Exercise various dashtype options
3 | # (Version 5 only)
4 | #
5 | set border 0
6 | unset xtics
7 | unset ytics
8 | unset key
9 | set yrange [0:1]
10 |
11 | y = 0.9
12 | set label 101 at screen 0.1, screen y "Terminal's native dashtypes"
13 | do for [i=1:10] {
14 | y = y - 0.05
15 | set arrow i from screen 0.25, screen y to screen 0.8, screen y nohead lw 1.5 lt 2 dt i
16 | set label i "dt ".i at screen 0.15, screen y
17 | }
18 | y = y - 0.05
19 | set label 102 at screen 0.1, screen y "Custom dashtypes"
20 | y = y - 0.05
21 | new = "."
22 | set label at screen 0.15, screen y 'dt "'.new.'"'
23 | set arrow 11 from screen 0.25, screen y to screen 0.8, screen y nohead lw 1.5 lt 3 dt new
24 | y = y - 0.05
25 | new = "-"
26 | set label at screen 0.15, screen y 'dt "'.new.'"'
27 | set arrow 12 from screen 0.25, screen y to screen 0.8, screen y nohead lw 1.5 lt 3 dt new
28 | y = y - 0.05
29 | new = "._"
30 | set label at screen 0.15, screen y 'dt "'.new.'"' noenh
31 | set arrow 13 from screen 0.25, screen y to screen 0.8, screen y nohead lw 1.5 lt 3 dt new
32 | y = y - 0.05
33 | new = "..- "
34 | set label at screen 0.15, screen y 'dt "'.new.'"'
35 | set arrow 14 from screen 0.25, screen y to screen 0.8, screen y nohead lw 1.5 lt 3 dt new
36 | y = y - 0.05
37 | set arrow 15 from screen 0.25, screen y to screen 0.8, screen y nohead lw 1.5 lc "blue'
38 | set arrow 15 dt (50,6,2,6)
39 | set label at screen 0.10, screen y 'dt (50,6,2,6)'
40 |
41 |
42 | plot 0 with lines lt nodraw
43 |
44 | pause -1 "Hit return to continue"
45 |
46 | # Now test effect of linewidth
47 | unset arrow 15
48 | unset label 15
49 |
50 | set for [i=1:14] arrow i lw 1+(i-1)%5
51 |
52 | plot 0 with lines lt nodraw
53 |
54 | pause -1 "Hit return to continue"
55 |
56 | reset
57 |
--------------------------------------------------------------------------------
/gnuplot/demo/gantt.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Very simple Gantt Chart
3 | # Demonstrate using timecolumn(N,format) to plot time data from
4 | # multiple columns
5 | #
6 | $DATA << EOD
7 | #Task start end
8 | A 2012-11-01 2012-12-31
9 | B 2013-01-01 2013-03-14
10 | C 2013-03-15 2014-04-30
11 | D 2013-05-01 2013-06-30
12 | E 2013-07-01 2013-08-31
13 | F1 2013-09-01 2013-10-31
14 | F2 2013-09-01 2014-01-17
15 | F3 2013-09-01 2014-01-30
16 | F4 2013-09-01 2014-03-31
17 | G1 2013-11-01 2013-11-27
18 | G2 2013-11-01 2014-01-17
19 | L 2013-11-28 2013-12-19
20 | M 2013-11-28 2014-01-17
21 | N 2013-12-04 2014-03-02
22 | O 2013-12-20 2014-01-17
23 | P 2013-12-20 2014-02-16
24 | Q 2014-01-05 2014-01-13
25 | R 2014-01-18 2014-01-30
26 | S 2014-01-31 2014-03-31
27 | T 2014-03-01 2014-04-28
28 | EOD
29 |
30 | set xdata time
31 | timeformat = "%Y-%m-%d"
32 | set format x "%b\n'%y"
33 |
34 | set yrange [-1:]
35 | OneMonth = strptime("%m","2")
36 | set xtics OneMonth nomirror
37 | set xtics scale 2, 0.5
38 | set mxtics 4
39 | set ytics nomirror
40 | set grid x y
41 | unset key
42 | set title "{/=15 Simple Gantt Chart}\n\n{/:Bold Task start and end times in columns 2 and 3}"
43 | set border 3
44 |
45 | T(N) = timecolumn(N,timeformat)
46 |
47 | set style arrow 1 filled size screen 0.02, 15 fixed lt 3 lw 1.5
48 |
49 | plot $DATA using (T(2)) : ($0) : (T(3)-T(2)) : (0.0) : yticlabel(1) with vector as 1, \
50 | $DATA using (T(2)) : ($0) : 1 with labels right offset -2
51 |
52 | pause -1 "Hit return to check backwards compatibility with v4 syntax"
53 |
54 | set timefmt timeformat
55 | plot $DATA using (timecolumn(2)) : ($0) : (T(3)-T(2)) : (0.0) : yticlabel(1) with vector as 1, \
56 | $DATA using 2 : ($0) : 1 with labels right offset -2
57 |
58 | pause -1 "Hit return to continue"
59 | reset
60 |
--------------------------------------------------------------------------------
/gnuplot/demo/fillstyle.dem:
--------------------------------------------------------------------------------
1 | # E A Merritt 24-Sep-2002
2 | #
3 | # Demo for revised fillstyle code selected by
4 | # ./configure --enable-filledboxes --enable-relative-boxwidth
5 | #
6 | reset
7 |
8 | set samples 25
9 | unset xtics
10 | unset ytics
11 | set yrange [0:120]
12 |
13 | set title "A demonstration of boxes with default properties"
14 | plot [-10:10] 100/(1.0+x*x) title 'distribution' with boxes
15 |
16 | pause -1 "Now draw the boxes with solid fill"
17 |
18 | set title "A demonstration of boxes with style fill solid 1.0"
19 | set style fill solid 1.0
20 | replot
21 |
22 | pause -1 "Now draw the boxes with a black border"
23 |
24 | set title "A demonstration of boxes with style fill solid border -1"
25 | set style fill solid border -1
26 | replot
27 |
28 | pause -1 "Now make the boxes a little less wide"
29 |
30 | set title "Filled boxes of reduced width"
31 | set boxwidth 0.5
32 | replot
33 |
34 | pause -1 "And now let's try a different fill density"
35 |
36 | set title "Filled boxes at 50% fill density"
37 | set style fill solid 0.25 border
38 | replot
39 |
40 | pause -1 "Now draw the boxes with no border"
41 |
42 | set title "A demonstration of boxes with style fill solid 0.25 noborder"
43 | set style fill solid 0.25 noborder
44 | replot
45 |
46 | pause -1 "Or maybe a pattern fill, instead?"
47 |
48 | set title "A demonstration of boxes in mono with style fill pattern"
49 | set samples 11
50 | set boxwidth 0.5
51 | set style fill pattern border
52 | plot [-2.5:4.5] 100/(1.0+x*x) title 'pattern 0' with boxes lt -1, \
53 | 80/(1.0+x*x) title 'pattern 1' with boxes lt -1, \
54 | 40/(1.0+x*x) title 'pattern 2' with boxes lt -1, \
55 | 20/(1.0+x*x) title 'pattern 3' with boxes lt -1
56 |
57 | pause -1 "Finished this demo"
58 |
59 | reset
60 |
61 |
--------------------------------------------------------------------------------
/gnuplot/demo/smooth_splines.dem:
--------------------------------------------------------------------------------
1 | # First part of old mgr.dem
2 | # show same data with various spline smoothing choices
3 |
4 | print "various splines for smoothing"
5 |
6 | set title "cubic spline fit to data (no weights)"
7 | set samples 300
8 | set xlabel "Time (sec)"
9 | set ylabel "Rate"
10 | plot "silver.dat" t "experimental" w errorb, \
11 | "" smooth csplines t "cubic smooth" lw 2
12 |
13 | pause -1 "Now apply a smoothing spline, weighted by 1/rel error (-> return)"
14 | set title "acsplines weighted by relative error"
15 | # error is column 3; weight larger errors less
16 | # start with rel error = 1/($3/$2)
17 | S=1
18 | plot "silver.dat" t "experimental" w errorb,\
19 | "" u 1:2:(S*$2/$3) smooth acsplines t "acspline Y/Z" lw 2
20 |
21 | pause -1 "Make it smoother by changing the smoothing weights (-> return)"
22 | set title "acsplines with increasing weight from error estimate"
23 | plot "silver.dat" t "rate" w errorb,\
24 | "" u 1:2:($2/($3*1.e1)) sm acs t "acspline Y/(Z*1.e1)" lw 2,\
25 | "" u 1:2:($2/($3*1.e3)) sm acs t " Y/(Z*1.e3)" lw 2,\
26 | "" u 1:2:($2/($3*1.e5)) sm acs t " Y/(Z*1.e5)" lw 2
27 |
28 | pause -1 "Accentuate the relative changes with a log-scale (-> return)"
29 | set title "same plot (various weighting) in log scale"
30 | set logscale y
31 | set grid x y mx my
32 | replot
33 |
34 | pause -1 "Now approximate the data with a bezier curve between the endpoints (-> return)"
35 | set title "Bezier curve rather than cubic spline"
36 | unset logscale y
37 | plot "silver.dat" t "experimental" w errorb,\
38 | "" smooth sbezier t "bezier" lw 2
39 |
40 | pause -1 "You would rather use log-scales ? (-> return)"
41 | set title "Bezier curve with log scale"
42 | set logscale y
43 | replot
44 |
45 | pause -1 "Hit return to continue"
46 | reset
47 |
--------------------------------------------------------------------------------
/gnuplot/demo/margins.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demonstrate use of 'set {btlr}margin at screen '
3 | # to pin plot borders to a specific place on the canvas.
4 | # This allows positioning multiple plots on the page so that their
5 | # corners line up perfectly.
6 | #
7 | # Aug 2006 - Ethan A Merritt
8 | #
9 |
10 | set multiplot title "Demo of placing multiple plots (2D and 3D)\nwith explicit alignment of plot borders"
11 |
12 | #
13 | # First plot (large)
14 | #
15 | set lmargin at screen 0.20
16 | set rmargin at screen 0.85
17 | set bmargin at screen 0.25
18 | set tmargin at screen 0.85
19 |
20 | set pm3d
21 | set palette rgbformulae 7, 5, 15
22 | set view map
23 | set samples 50, 50
24 | set isosamples 50, 50
25 | unset surface
26 | set xrange [ -15.00 : 15.00 ]
27 | set yrange [ -15.00 : 15.00 ]
28 | set zrange [ -0.250 : 1.000 ]
29 |
30 | unset xtics
31 | unset ytics
32 |
33 | unset key
34 |
35 | splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)
36 |
37 | unset pm3d
38 | unset key
39 |
40 | #
41 | # second plot (tall and narrow; at left of main plot)
42 | #
43 | set lmargin at screen 0.10
44 | set rmargin at screen 0.20
45 |
46 | set ytics
47 |
48 | set parametric
49 | set dummy u,v
50 | set view map
51 |
52 | f(h) = sin(sqrt(h**2))/sqrt(h**2)
53 |
54 | set urange [ -15.00 : 15.00 ]
55 | set vrange [ -15.00 : 15.00 ]
56 | set xrange [*:*]
57 | set surface
58 |
59 | splot f(u), u, 0 with lines lc rgb "green"
60 |
61 | unset parametric
62 |
63 | #
64 | # third plot (short and wide; at bottom of main plot)
65 | #
66 | set lmargin at screen 0.20
67 | set rmargin at screen 0.85
68 | set bmargin at screen 0.10
69 | set tmargin at screen 0.25
70 |
71 | set xrange [ -15.00 : 15.00 ]
72 | set yrange [ * : * ]
73 | set xtics
74 | unset ytics
75 |
76 | y = 0
77 | plot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)
78 |
79 | unset multiplot
80 |
81 | pause -1 "Hit return to continue"
82 | reset
83 |
--------------------------------------------------------------------------------
/gnuplot/demo/smooth.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Find number of points
3 | #
4 | stats 'random-points' nooutput
5 | N = STATS_records
6 |
7 | bin(x, s) = s*int(x/s)
8 |
9 | set zeroaxis
10 | set style data points
11 | set key box top left
12 |
13 | # Uniform
14 | set title "Uniform Distribution"
15 | set boxwidth 0.05
16 | set xrange [-0.1 : 1.1] noextend
17 | set yrange [-0.4 : 1.6]
18 | plot "random-points" u 1:(0.25*rand(0)-.35) t '', \
19 | "" u (bin($1,0.05)):(20./N) smooth freq t 'smooth frequency' w boxes, \
20 | "" u 1:(1.) smooth cnorm t 'smooth cnorm'
21 | pause -1 "Hit enter to continue"
22 |
23 |
24 | # Normal
25 | set title "Normal Distribution"
26 | set boxwidth 0.05
27 | set xrange [* : *] noextend
28 | set yrange [-0.4 : 1.1]
29 | set ytics 0,.2
30 |
31 | plot "random-points" u 2:(0.25*rand(0)-.35) t '', \
32 | "" u (bin($2,0.05)):(20./N) smooth freq t 'smooth frequency' w boxes, \
33 | "" u 2:(1.) smooth cnorm t 'smooth cnorm'
34 | pause -1 "Hit enter to continue"
35 |
36 |
37 | # Lognormal
38 | set title "Lognormal Distribution"
39 | set boxwidth 0.1
40 | set xrange [0 : *] noextend
41 | plot "random-points" u 3:(0.25*rand(0)-.35) t '', \
42 | "" u (bin($3,0.1)):(10./N) smooth freq t 'smooth frequency' w boxes, \
43 | "" u 3:(1.) smooth cnorm t 'smooth cnorm'
44 | pause -1 "Hit enter to continue"
45 |
46 |
47 | # Mixed
48 | set title "Mixed Distribution (Lognormal with shifted Gaussian)"
49 | set boxwidth 0.1
50 | set xrange [* : *] noextend
51 | set link y2 via y*N inverse y/N
52 | set ytics nomirror 0,.2
53 | set y2tics nomirror tc "red" 0,50
54 |
55 | plot "random-points" u 4:(0.25*rand(0)-.35) t '', \
56 | "" u (bin($4,0.1)):(10./N) smooth freq t 'smooth frequency' w boxes, \
57 | "" u 4:(1.) smooth cnorm t 'smooth cnorm' lc "#88eeff" lw 5, \
58 | "" u 4:(1.) axes x1y2 smooth cumulative t 'smooth cumulative' lc "red"
59 | pause -1 "Hit enter to continue"
60 |
61 |
62 | reset
63 |
--------------------------------------------------------------------------------
/gnuplot/demo/param.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Show some of the new parametric capabilities.
3 | #
4 | set parametric
5 | set dummy t
6 | set autoscale
7 | set samples 160
8 | set title ""
9 | set key box
10 | set key below
11 | plot t,sin(t)/t title "t,sin(t)/t or sin(x)/x"
12 | pause -1 "Hit return to continue"
13 |
14 | plot sin(t)/t,t
15 | pause -1 "Hit return to continue"
16 |
17 | plot sin(t),cos(t)
18 | pause -1 "Hit return to continue"
19 |
20 | set xrange [-3:3]
21 | set yrange [-3:3]
22 | set title "Parametric Conic Sections"
23 | plot -t,t,cos(t),cos(2*t),2*cos(t),sin(t),-cosh(t),sinh(t)
24 | set title ""
25 | pause -1 "Hit return to continue"
26 |
27 | set xrange [-5:5]
28 | set yrange [-5:5]
29 | plot tan(t),t,t,tan(t)
30 | pause -1 "Hit return to continue"
31 |
32 | set trange [0.00001:3]
33 | plot t,log(t),-t,log(t),sin(t),t**2,-sin(t),t**2
34 | pause -1 "Hit return to continue"
35 |
36 | set autoscale x
37 | set yrange [-1.5:1.5]
38 | set trange [0.0001:10*pi]
39 | plot sin(t)/t,cos(t)/t
40 | pause -1 "Hit return to continue"
41 |
42 | #
43 | # Decouple range of parametric axes u/v from that of display axes x/y/z
44 | #
45 | reset
46 | set label 1 "Decouple range of parametric axes u/v\nfrom that of display axes x/y/z"
47 | set label 1 at screen 0.1, 0.9
48 | unset colorbox
49 | set palette cubehelix cycle 3
50 | set view equal xyz
51 | set view 120, 300
52 | set xyplane 0
53 | set pm3d depthorder
54 | set border 4095
55 | set tics scale 0
56 | set format ""
57 | set angles radians
58 | xx(u, v) = cos(v) * cos(u)
59 | yy(u, v) = cos(v) * sin(u)
60 | zz(u, v) = sin(v)
61 | color(u, v) = sin(2*u)+sin(2*v)
62 | #
63 | set parametric
64 | set isosamples 121, 61
65 | set samples 121, 61
66 | set urange [-pi:pi]
67 | set vrange [-pi/2:pi/2]
68 | set xrange [-1:1]
69 | set yrange [-1:1]
70 | set zrange [-1:1]
71 | splot "++" using (xx($1,$2)):(yy($1,$2)):(zz($1,$2)):(color($1,$2)) with pm3d notitle
72 | pause -1
73 |
74 | # undo what we've done above
75 | reset
76 |
77 |
--------------------------------------------------------------------------------
/gnuplot/demo/enhancedtext.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Test page for enhanced text mode
3 | #
4 | print " ----------------------------------------------------"
5 | print " This test page for enhanced text mode will only work"
6 | print " if enhanced text is selected and supported for the"
7 | print " current terminal type. E.g. 'set term post enh'"
8 | print " ----------------------------------------------------"
9 | #
10 | set termoption enhanced
11 | save_encoding = GPVAL_ENCODING
12 | set encoding iso_8859_1
13 | #
14 | set title "Test page for enhanced text mode"
15 | set xrange [-1:1]
16 | set yrange [-0.5:1.1]
17 | set format xy "%.1f"
18 | set arrow from 0.5, -0.5 to 0.5, 0.0 nohead
19 | #
20 | set label 1 at -0.65, 1.0
21 | set label 1 "These examples require no extra fonts:" tc lt 3
22 | set label 2 at -0.55, 0.9
23 | set label 2 "10^{-2} A_{j,k} e^x"
24 | set label 3 at -0.55, 0.8
25 | set label 3 'x@^2_k x@_0^{-3/2}y'
26 |
27 | set label 5 at -0.55, 0.7
28 | set label 5 "Space-holders:" tc lt 3
29 | set label 6 at -0.45, 0.6
30 | set label 6 "<&{{/=20 B}ig}> <&{x@_0^{-3/2}y}> holds space for"
31 | set label 7 at -0.45, 0.5
32 | set label 7 "<{/=20 B}ig> "
33 |
34 | set label 8 at -0.9, -0.2
35 | set label 8 "Overprint\n(v should be centred over d)" tc lt 3
36 | set label 9 at -0.85, -0.4
37 | set label 9 " ~{abcdefg}{0.8v}"
38 |
39 |
40 | set label 10 at -.40, 0.35
41 | set label 10 "Requires Symbol font:" tc lt 3
42 | set label 11 at -.30, 0.2
43 | set label 11 "{/Symbol=18 \362@_{/=9.6 0}^{/=12 ^\245}} {e^{-{/Symbol m}^2/2} d}{/Symbol m=(p/2)^{1/2}}"
44 |
45 | set label 21 at 0.5, -.1
46 | set label 21 "Left ^{centered} text" left
47 | set label 22 at 0.5, -.2
48 | set label 22 "Right ^{centered} text" right
49 | set label 23 at 0.5, -.3
50 | set label 23 "Center^{centered} text" center
51 | #
52 | set key title " "
53 | plot sin(x)**2 lt 2 lw 2 title "sin^2(x)"
54 | #
55 | pause -1 "Hit to continue"
56 | set encoding save_encoding
57 | reset
58 |
--------------------------------------------------------------------------------
/gnuplot/demo/enhanced_utf8.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Test page for enhanced text mode in UTF-8 encoding
3 | #
4 | # Suggested PostScript font test
5 | # set fontpath "/usr/local/share/fonts"
6 | # set term post color adobeglyphnames fontfile 'l_10646.ttf' font "LucidaSansUnicode,12"
7 | # set output 'enhanced_utf8.ps'
8 | #
9 | set termoption enhanced
10 | save_encoding = GPVAL_ENCODING
11 | set encoding utf8
12 | #
13 | set title "Demo of enhanced text mode using a single UTF-8 encoded font\nThere is another demo that shows how to use a separate Symbol font"
14 | set xrange [-1:1]
15 | set yrange [-0.5:1.1]
16 | set format xy "%.1f"
17 | set arrow from 0.5, -0.5 to 0.5, 0.0 nohead
18 | #
19 | set label 1 at -0.65, 0.95
20 | set label 1 "Superscripts and subscripts:" tc lt 3
21 |
22 | set label 3 at -0.55, 0.85
23 | set label 3 'A_{j,k} 10^{-2} x@^2_k x@_0^{-3/2}y'
24 |
25 | set label 5 at -0.55, 0.7
26 | set label 5 "Space-holders:" tc lt 3
27 | set label 6 at -0.45, 0.6
28 | set label 6 "<&{{/=20 B}ig}> <&{x@_0^{-3/2}y}> holds space for"
29 | set label 7 at -0.45, 0.5
30 | set label 7 "<{{/=20 B}ig}> <{x@_0^{-3/2}y}>"
31 |
32 | set label 8 at -0.9, -0.2
33 | set label 8 "Overprint\n(v should be centred over d)" tc lt 3
34 | set label 9 at -0.85, -0.4
35 | set label 9 " ~{abcdefg}{0.8v}"
36 |
37 |
38 | set label 10 at -.40, 0.35
39 | set label 10 "UTF-8 encoding does not require Symbol font:" tc lt 3
40 | set label 11 at -.30, 0.2
41 | set label 11 "{/*1.5 ∫@_{/=9.6 0}^{/=12 ∞}} {e^{-{μ}^2/2} d}{μ=(π/2)^{1/2}}"
42 |
43 | set label 21 at 0.5, -.1
44 | set label 21 "Left ^{centered} ƒ(αβγδεζ)" left
45 | set label 22 at 0.5, -.2
46 | set label 22 "Right ^{centered} ƒ(αβγδεζ)" right
47 | set label 23 at 0.5, -.3
48 | set label 23 "Center^{centered} ƒ(αβγδεζ)" center
49 |
50 | set label 30 at -.9, 0.0 "{/:Bold Bold} and {/:Italic Italic} markup"
51 | #
52 | set key title " "
53 | plot sin(x)**2 lt 2 lw 2 title "sin^2(x)"
54 | #
55 | pause -1 "Hit return to continue"
56 | set encoding save_encoding
57 | reset
58 |
59 |
--------------------------------------------------------------------------------
/gnuplot/demo/fenceplot.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Two different methods to construct a fence plot
3 | #
4 | # 1) Each fence is a separate parametric surface
5 | # surface appearance is controlled by "set hidden3d"
6 | #
7 | set title "fence plot constructed with separate parametric surfaces"
8 | sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)
9 | set xrange [-5:5]; set yrange [-5:5]
10 | set xtics offset 0,-1
11 | set ytics offset 0,-1
12 | set zrange [-1:1]
13 | set format z "%.1f"
14 | set arrow 1 from 5,-5,-1.2 to 5,5,-1.2 lt -1
15 | set label 1 "increasing v" at 6,0,-1
16 | set arrow 2 from 5,6,-1 to 5,5,-1 lt -1
17 | set label 2 "u=0" at 5,6.5,-1
18 | set arrow 3 from 5,6,sinc(5,5) to 5,5,sinc(5,5) lt -1
19 | set label 3 "u=1" at 5,6.5,sinc(5,5)
20 | set parametric
21 | set hidden3d offset 0 # front/back coloring makes no sense for fenceplot #
22 | set isosamples 2,33
23 | array U[10]
24 | u=-5; du=(4.99-(-4.99))/9
25 | do for [i=1:10] { U[i] = u + i * du }
26 |
27 | set view 70, 25
28 | set urange [0:1]
29 | set vrange [-4.99:4.99]
30 | splot for [i=1:10] U[i], v, (u<0.5) ? -1 : sinc(U[i],v) notitle
31 |
32 | pause -1 "Hit return to continue"
33 | unset hidden3d
34 |
35 | #
36 | # 2) Each fence is a curve drawn with zerrorfill
37 | # surface appearance is controlled by "set pm3d" and "set style fill"
38 | # If depth-cueing is needed, use "set pm3d depthorder"
39 | #
40 | set format z "%.1f"
41 | unset key
42 | unset arrow
43 | unset label
44 | set view 70,25
45 | unset xtics
46 | unset ytics
47 | set title "fence plot constructed with zerrorfill"
48 | set zrange [-1:1]
49 | set arrow 1 from 5,-.5,-1.2 to 5,.5,-1.2 lt -1
50 | set label 1 "sampling on Y" at 6,-0.1,-1
51 | set xlabel "X axis" rotate parallel
52 | set xrange [-5:4]
53 | set yrange [-0.5:0.5]
54 | sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)
55 |
56 | set style fill solid 0.75 noborder
57 | splot for [x=-4:4][y=-50:50:3] '+' using (x):($1/100.):(-1):(-1):(sinc($1/10., 1.+x)) with zerrorfill
58 |
59 | pause -1 "Hit return to continue"
60 | reset
61 |
--------------------------------------------------------------------------------
/gnuplot/demo/silver.dat:
--------------------------------------------------------------------------------
1 | 10.000000 280.000000 16.733201
2 | 20.000000 191.000000 13.820275
3 | 30.000000 152.000000 12.328828
4 | 40.000000 150.000000 12.247449
5 | 50.000000 104.000000 10.198039
6 | 60.000000 77.000000 8.774964
7 | 70.000000 69.000000 8.306624
8 | 80.000000 60.000000 7.745967
9 | 90.000000 60.000000 7.745967
10 | 100.000000 51.000000 7.141428
11 | 110.000000 41.000000 6.403124
12 | 120.000000 34.000000 5.830952
13 | 130.000000 35.000000 5.916080
14 | 140.000000 34.000000 5.830952
15 | 150.000000 24.000000 4.898979
16 | 160.000000 24.000000 4.898979
17 | 170.000000 19.000000 4.358899
18 | 180.000000 21.000000 4.582576
19 | 190.000000 20.000000 4.472136
20 | 200.000000 18.000000 4.242641
21 | 210.000000 21.000000 4.582576
22 | 220.000000 15.000000 3.872983
23 | 230.000000 19.000000 4.358899
24 | 240.000000 12.000000 3.464102
25 | 250.000000 20.000000 4.472136
26 | 260.000000 20.000000 4.472136
27 | 270.000000 18.000000 4.242641
28 | 280.000000 18.000000 4.242641
29 | 290.000000 20.000000 4.472136
30 | 300.000000 12.000000 3.464102
31 | 310.000000 26.000000 5.099020
32 | 320.000000 17.000000 4.123106
33 | 330.000000 8.000000 2.828427
34 | 340.000000 6.000000 2.449490
35 | 350.000000 8.000000 2.828427
36 | 360.000000 10.000000 3.162278
37 | 370.000000 20.000000 4.472136
38 | 380.000000 14.000000 3.741657
39 | 390.000000 8.000000 2.828427
40 | 400.000000 10.000000 3.162278
41 | 410.000000 9.000000 3.000000
42 | 420.000000 8.000000 2.828427
43 | 430.000000 10.000000 3.162278
44 | 440.000000 13.000000 3.605551
45 | 450.000000 9.000000 3.000000
46 | 460.000000 5.000000 2.236068
47 | 470.000000 7.000000 2.645751
48 | 480.000000 11.000000 3.316625
49 | 500.000000 7.000000 2.645751
50 | 510.000000 9.000000 3.000000
51 | 520.000000 12.000000 3.464102
52 | 530.000000 4.000000 2.000000
53 | 540.000000 7.000000 2.645751
54 | 550.000000 10.000000 3.162278
55 | 560.000000 9.000000 3.000000
56 | 580.000000 8.000000 2.828427
57 | 590.000000 9.000000 3.000000
58 | 600.000000 5.000000 2.236068
59 |
--------------------------------------------------------------------------------
/gnuplot/demo/pointsize.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Read individual point sizes from extra column of input file
3 | # Ethan A Merritt - October 2004
4 | #
5 | unset key
6 | unset border
7 | unset yzeroaxis
8 | unset xtics
9 | unset ytics
10 | unset ztics
11 |
12 | #
13 | # plot a 2D map with locations marked by variable sized points
14 | #
15 | set title "plot with variable size points"
16 | plot 'world.dat' with lines lt 3, \
17 | 'world.cor' using 1:2:(5.*rand(0)) with points lt 1 pt 6 ps variable
18 | pause -1 "Hit return to continue"
19 |
20 | #
21 | set title "splot with variable size points\nit is possible to specify size and color separately"
22 | set view map
23 | unset hidden3d
24 | splot 'world.dat' using 1:2:(0) with lines lt 3, \
25 | 'world.cor' using 1:2:(0.5-rand(0)):(5.*rand(0)) with points pt 5 ps var lt palette
26 | pause -1 "Hit return to continue"
27 |
28 | #
29 | # plot a '3D version using spherical coordinate system' of the world.
30 | set angles degrees
31 | set title "3D version using spherical coordinate system"
32 | set ticslevel 0
33 | set view 70,40,0.8,1.2
34 | set mapping spherical
35 | set parametric
36 | set samples 32
37 | set isosamples 9
38 | set urange [-90:90]
39 | set vrange [0:360]
40 | splot cos(u)*cos(v),cos(u)*sin(v),sin(u) with lines lt 5,\
41 | 'world.dat' with lines lt 3, \
42 | 'world.cor' using 1:2:(1):(5.*rand(0)) with points lt 1 pt 6 ps variable
43 | pause -1 "Hit return to continue"
44 |
45 | #
46 | # hidden3d still not working fully
47 | # pointsize is now handled, but axes are never obscured
48 | #
49 | set title "3D solid version through hiddenlining"
50 | set hidden3d
51 | set arrow from 0,0,-1.2 to 0,0,1.2 lt 5 lw 2
52 | set arrow from -1.2, 0, 0 to 1.2, 0, 0 nohead lt 5 lw 1
53 | set arrow from 0, -1.2, 0 to 0, 1.2, 0 nohead lt 5 lw 1
54 | splot cos(u)*cos(v),-cos(u)*sin(v),sin(u) with lines lt 5,\
55 | 'world.dat' u 1:2:(1.001) with lines lt 3, \
56 | 'world.cor' using 1:2:(1):(5.*rand(0)) with points lt 1 pt 6 ps var
57 | pause -1 "Hit return to continue"
58 |
59 | reset
60 |
61 |
--------------------------------------------------------------------------------
/gnuplot/demo/rectangle.dem:
--------------------------------------------------------------------------------
1 | # demo for the use of "set object rectangle"
2 | # Updated for version 5
3 | # show front/back/behind, opaque key box
4 |
5 | set object 1 rect from 0,0 to 1,4 fc lt 2 front
6 | set object 2 rect from -1,1 to 0,5 fc rgb "gold"
7 | set object 5 rect from 0, -3 to 2, -2 fc rgb "cyan" fs pattern 1 bo -1
8 |
9 | set style fill pattern 2 bo 1
10 |
11 | #
12 | # Test clipping and placement in the presence of an inverted axis range
13 | #
14 | set obj 4 rect at -4,0 size 3,1
15 | set label 4 at -2.6,0 "There should be a\nclipped rectangle here" left offset 0,.5
16 |
17 | #
18 | # The key box has its own option "opaque" to generate a filled rectangle
19 | #
20 | set key box opaque height 2
21 |
22 | #
23 | # Illustrate using character widths to put a box around a label
24 | #
25 | LABEL = "Label in a box"
26 | set obj 10 rect at -3,-4 size char strlen(LABEL), char 1
27 | set obj 10 fillstyle empty border -1 front
28 | set label 10 at -3,-4 LABEL front center
29 |
30 | set obj 9 rect from -4, -4 to -4, -3 fc lt -1
31 |
32 | set obj 20 rect from graph 0, graph 0 to graph 1, graph 1 fs solid 0.15 fc rgb "#FFD700" behind
33 |
34 | set xrange [5:-5]
35 |
36 | plot x, -3+sin(x*5)/x lt 3 lw 3
37 |
38 | pause -1 "Hit return to continue"
39 |
40 | reset
41 |
42 | #
43 | # Requires data file "using.dat" from this directory,
44 | # so change current working directory to this directory before running.
45 | #
46 |
47 | set xrange [1:8]
48 | set title "Convex November 1-7 1989"
49 | set key below
50 | set label "(Weekend)" at 5,25 center
51 |
52 | set style rect fc lt -1 fs solid 0.15 noborder
53 |
54 | set obj rect from 1, graph 0 to 2, graph 1
55 | set obj rect from 3, graph 0 to 4, graph 1
56 | set obj rect from 5, graph 0 to 6, graph 1
57 | set obj rect from 7, graph 0 to 8, graph 1
58 |
59 | plot 'using.dat' using 3:4 title "Logged in" with impulses,\
60 | 'using.dat' using 3:5 t "Load average" with points,\
61 | 'using.dat' using 3:6 t "%CPU used" with lines
62 |
63 | pause -1 "Hit return to continue"
64 |
65 | reset
66 |
--------------------------------------------------------------------------------
/gnuplot/demo/mousevariables.dem:
--------------------------------------------------------------------------------
1 | # Demonstrate use of user variables
2 | # MOUSE_BUTTON MOUSE_X MOUSE_Y MOUSE_X2 MOUSE_Y2
3 | # and built-in function exists("")
4 | #
5 | reset
6 | set title "Scripted zoom using exported MOUSE variables"
7 | set samples 200
8 | set label 3 at graph 0.1, graph 0.9 tc lt 3
9 | set label 3 "Click on one corner of desired zoom region"
10 | plot sin(13*besj0(x))/x
11 | #
12 | pause mouse "Click on one corner of desired zoom region"
13 | #
14 | if (exists("MOUSE_BUTTON")) \
15 | print "Mouse button ", MOUSE_BUTTON, " at ", MOUSE_X, " ", MOUSE_Y ;\
16 | set label 1 sprintf(" Mouse button %d\n clicked here!", MOUSE_BUTTON) ;\
17 | set label 1 at MOUSE_X, MOUSE_Y ;\
18 | set label 1 point pt 6 ps 6 ;\
19 | replot ;\
20 | else \
21 | print "No mouse click?" ;\
22 | exit ;
23 | #
24 | BOT_X = MOUSE_X
25 | BOT_Y = MOUSE_Y
26 | set label 3 "Click on diagonal corner of desired zoom region"
27 | replot
28 | #
29 | pause mouse "Click on diagonal corner of desired zoom region"
30 | #
31 | if (exists("MOUSE_BUTTON")) \
32 | print "Mouse button ", MOUSE_BUTTON, " at ", MOUSE_X, " ", MOUSE_Y ;\
33 | set label 2 sprintf(" Mouse button %d\n clicked here!", MOUSE_BUTTON) ;\
34 | set label 2 at MOUSE_X, MOUSE_Y ;\
35 | set label 2 point pt 6 ps 6 ;\
36 | replot ;\
37 | else \
38 | print "No mouse click?" ;\
39 | exit ;
40 | #
41 | #
42 | TOP_X = MOUSE_X
43 | TOP_Y = MOUSE_Y
44 | #
45 | set label 3 "Plot will zoom in 3 seconds"
46 | replot
47 | pause 3
48 | #
49 | set xrange [ BOT_X : TOP_X ]
50 | set yrange [ BOT_Y : TOP_Y ]
51 | set grid
52 | #
53 | unset label 1
54 | unset label 2
55 | unset label 3
56 | set label 4 sprintf("zoom x range %.3f to %.3f",BOT_X,TOP_X)
57 | set label 5 sprintf("zoom y range %.3f to %.3f",TOP_X,TOP_Y)
58 | set label 4 at graph 0.1, graph 0.95 tc lt 3
59 | set label 5 at graph 0.1, graph 0.90 tc lt 3
60 | replot
61 | #
62 | print "Zoomed to xrange ",BOT_X," ",TOP_X
63 | print "Zoomed to yrange ",BOT_Y," ",TOP_Y
64 | #
65 | pause -1 "Type to continue"
66 |
67 | reset
68 |
--------------------------------------------------------------------------------
/gnuplot/demo/nonlinear2.dem:
--------------------------------------------------------------------------------
1 | # This example shows how in gnuplot version 5 a nonlinear axis definition
2 | # can be used to set up log-scale axes. This mechanism replaces a special-case
3 | # logscale implementation provided by previous versions of gnuplot.
4 | # The pair of commands
5 | # set nonlinear x via log10(x) inverse 10**x
6 | # set xtics log
7 | # is equivalent to the pre-v5 command
8 | # set logscale x
9 | # The "set logscale" command is still accepted as a shortcut.
10 | #
11 | # This plot is the same as plot #2 in electrom.dem showing log-scaled axes.
12 | #
13 | set title "Log-scaled axes defined using 'set log'"
14 | set label 1 "This version of the plot uses\nset logscale x\nset logscale y" at graph 0.5, 0.85, 0 center norotate back nopoint
15 |
16 | set dummy jw, y
17 | set grid xtics ytics
18 | set key inside center bottom vertical Right noreverse enhanced autotitle box
19 | set samples 160, 160
20 | set style data lines
21 | set xtics border out scale 1,0.5 nomirror
22 | set ytics border out scale 1,0.5 nomirror
23 | set ytics norangelimit 0.1 textcolor rgb "dark-violet"
24 | set y2tics border out scale 1,0.5 nomirror
25 | set y2tics norangelimit autofreq textcolor rgb "#56b4e9"
26 | set xlabel "jw (radians)"
27 | set ylabel "magnitude of A(jw)"
28 | set y2label "Phase of A(jw) (degrees)"
29 | #
30 | set xrange [ 1.1 : 90000.0 ] noextend
31 | set yrange [ 0.1 : 1.0 ]
32 | #
33 | set log x
34 | set log y
35 | set ytics nolog
36 | #
37 | A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
38 | p1 = 10
39 | p2 = 10000
40 | #
41 | plot abs(A(jw)) lt 1, 180/pi*arg(A(jw)) axes x1y2 lt 3
42 |
43 | pause -1 " to continue"
44 |
45 | set title "Log-scaled axes defined using 'set nonlinear'"
46 | set label 1 "The same plot except that 'set logscale' is replaced by\nset nonlinear x via log10(x) inverse 10**x\nset nonlinear y via log10(y) inverse 10**y"
47 |
48 | set nonlinear x via log10(x) inverse 10**x
49 | set nonlinear y via log10(y) inverse 10**y
50 | set xtics log
51 | set ytics nolog
52 |
53 | replot
54 |
55 | pause -1 " to continue"
56 |
57 | reset
58 |
--------------------------------------------------------------------------------
/gnuplot/demo/charset.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Dump all (8-bit) characters by octal code value
3 | #
4 | set title "Complete dump of characters for this font and encoding"
5 | #
6 | set border 0
7 | unset xtics
8 | unset ytics
9 | #
10 | set label 11 "001-040:" at graph 0.02, 0.9
11 | set label 12 "041-100:" at graph 0.02, 0.8
12 | set label 13 "101-140:" at graph 0.02, 0.7
13 | set label 14 "141-200:" at graph 0.02, 0.6
14 | set label 15 "201-240:" at graph 0.02, 0.5
15 | set label 16 "241-300:" at graph 0.02, 0.4
16 | set label 17 "301-340:" at graph 0.02, 0.3
17 | set label 18 "341-376:" at graph 0.02, 0.2
18 | #
19 | set label 1 at graph 0.2, 0.9
20 | set label 2 at graph 0.2, 0.8
21 | set label 3 at graph 0.2, 0.7
22 | set label 4 at graph 0.2, 0.6
23 | set label 5 at graph 0.2, 0.5
24 | set label 6 at graph 0.2, 0.4
25 | set label 7 at graph 0.2, 0.3
26 | set label 8 at graph 0.2, 0.2
27 | #
28 | set label 1 "\001\002\003\004\005\006\007\010\011 \013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040"
29 | set label 2 "\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100"
30 | set label 3 "\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140"
31 | set label 4 "\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200"
32 | set label 5 "\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240"
33 | set label 6 "\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300"
34 | set label 7 "\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340"
35 | set label 8 "\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376"
36 | #
37 | set xrange [-1:1]
38 | set yrange [-1:1]
39 | plot -10 notitle
40 | reset
41 |
--------------------------------------------------------------------------------
/gnuplot/demo/ellipses_style.dem:
--------------------------------------------------------------------------------
1 | # Demo to illustrate the ellipses style
2 |
3 | set title "Demonstration of the 'ellipses' plotting style\nTwo-column form: x y (default size)"
4 |
5 | plot 'ellipses.dat' u 1:2 with ellipses
6 |
7 | pause -1 'Hit to continue'
8 |
9 | set title "Three-column form: x y major_diameter (minor diameter is the same)" noenh
10 |
11 | plot 'ellipses.dat' u 1:2:3 with ellipses
12 |
13 | pause -1 'Hit to continue'
14 |
15 | set title "Four-column form: x y major_diameter minor_diameter" noenh
16 |
17 | plot 'ellipses.dat' u 1:2:3:4 with ellipses
18 |
19 | pause -1 'Hit to continue'
20 |
21 | set title "Five-column form: x y major_diameter minor_diameter angle" noenh
22 |
23 | plot 'ellipses.dat' u 1:2:3:4:5 with ellipses
24 |
25 | pause -1 'Hit to continue'
26 |
27 | set title "Six-column form: 6th column variable color (lc variable)"
28 |
29 | plot 'ellipses.dat' u 1:2:3:4:5:6 with ellipses lc var
30 |
31 | pause -1 'Hit to continue'
32 |
33 | set title "Six-column form: 6th column variable color (lc palette)"
34 |
35 | plot 'ellipses.dat' u 1:2:3:4:5:6 with ellipses lc pal
36 |
37 | pause -1 'Hit to continue'
38 |
39 | set title "Six-column form: 6th column variable color (lc rgb variable)"
40 |
41 | plot 'ellipses.dat' u 1:2:3:4:5:7 with ellipses lc rgb var
42 |
43 | pause -1 'Hit to continue'
44 |
45 | set title "Scaling of axes: units xy"
46 | set yr [-15:30]
47 | set xr [-5:15]
48 |
49 | plot 'ellipses.dat' u 1:2:3:4:5 with ellipses units xy
50 |
51 | pause -1 'Hit to continue'
52 |
53 | set title "Scaling of axes: units xx"
54 |
55 | plot 'ellipses.dat' u 1:2:3:4:5 with ellipses units xx
56 |
57 | pause -1 'Hit to continue'
58 |
59 | set title "Scaling of axes: units yy"
60 |
61 | plot 'ellipses.dat' u 1:2:3:4:5 with ellipses units yy
62 |
63 | pause -1 'Hit to continue'
64 |
65 | set title "Now see all three together"
66 |
67 | plot 'ellipses.dat' u 1:2:3:4:5 with ellipses units xy title "units xy",\
68 | '' u 1:2:3:4:5 with ellipses units xx title "units xx",\
69 | '' u 1:2:3:4:5 with ellipses units yy title "units yy"
70 |
71 | pause -1 'Hit to continue'
72 | reset
73 |
--------------------------------------------------------------------------------
/gnuplot/demo/dgrid3d.dem:
--------------------------------------------------------------------------------
1 | set view 60,75
2 | unset key
3 | set hidden3d
4 |
5 | # Raw data
6 | set title "The Valley of the Gnu"
7 | splot "gnu-valley" u 1:2:3 w linesp
8 | pause -1 "Hit return to continue"
9 |
10 | # Splines
11 | set title "dgrid3d splines"
12 | set dgrid3d splines
13 | splot "gnu-valley" u 1:2:3 w lines
14 | pause -1 "Hit return to continue"
15 |
16 | # QNorm
17 | set title "dgrid3d 30,30 qnorm 1"
18 | set dgrid3d 30,30 qnorm 1
19 | splot "gnu-valley" u 1:2:3 w l
20 | pause -1 "Hit return to continue"
21 |
22 | set title "dgrid3d 30,30 qnorm 2"
23 | set dgrid3d 30,30 qnorm 2
24 | splot "gnu-valley" u 1:2:3 w l
25 | pause -1 "Hit return to continue"
26 |
27 | set title "dgrid3d 30,30 qnorm 3"
28 | set dgrid3d 30,30 qnorm 3
29 | splot "gnu-valley" u 1:2:3 w l
30 | pause -1 "Hit return to continue"
31 |
32 | set title "dgrid3d 30,30 qnorm 4"
33 | set dgrid3d 30,30 qnorm 4
34 | splot "gnu-valley" u 1:2:3 w l
35 | pause -1 "Hit return to continue"
36 |
37 | set title "dgrid3d 30,30 qnorm 5"
38 | set dgrid3d 30,30 qnorm 5
39 | splot "gnu-valley" u 1:2:3 w l
40 | pause -1 "Hit return to continue"
41 |
42 |
43 | # Gauss
44 | set title "dgrid3d 30,30 gauss 1"
45 | set dgrid3d 30,30 gauss 1
46 | splot "gnu-valley" u 1:2:3 w l
47 | pause -1 "Hit return to continue"
48 |
49 | set title "dgrid3d 30,30 gauss .75"
50 | set dgrid3d 30,30 gauss .75
51 | splot "gnu-valley" u 1:2:3 w l
52 | pause -1 "Hit return to continue"
53 |
54 | set title "dgrid3d 30,30 gauss .5"
55 | set dgrid3d 30,30 gauss .5
56 | splot "gnu-valley" u 1:2:3 w l
57 | pause -1 "Hit return to continue"
58 |
59 | set title "dgrid3d 30,30 gauss .35"
60 | set dgrid3d 30,30 gauss .35
61 | splot "gnu-valley" u 1:2:3 w l
62 | pause -1 "Hit return to continue"
63 |
64 | set title "dgrid3d 30,30 gauss .25"
65 | set dgrid3d 30,30 gauss .25
66 | splot "gnu-valley" u 1:2:3 w l
67 | pause -1 "Hit return to continue"
68 |
69 | set title "dgrid3d 30,30 gauss .5,.35"
70 | set dgrid3d 30,30 gauss 0.5,0.35
71 | splot "gnu-valley" u 1:2:3 w l
72 | pause -1 "Hit return to continue"
73 |
74 | set title "dgrid3d 30,30 gauss .35,.5"
75 | set dgrid3d 30,30 gauss 0.35,0.5
76 | splot "gnu-valley" u 1:2:3 w l
77 | pause -1 "Hit return to continue"
78 |
79 | reset
80 |
--------------------------------------------------------------------------------
/interpolationPolinom.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Иван Ильин on 25.09.2020.
3 | //
4 |
5 | #include
6 | #include
7 | #include "gnuplot.h"
8 | #include "vemath.h"
9 |
10 | using namespace std;
11 | using namespace vemath;
12 |
13 | double xk(unsigned k, unsigned n) {
14 | return 1.0f + (double)k / (double)n;
15 | }
16 |
17 | double li(double x, unsigned i, unsigned n) {
18 | double res = 1.0f;
19 |
20 | for(int k = 0; k <= n; k++)
21 | if(i != k)
22 | res *= (x - xk(k, n));
23 |
24 | return res;
25 | }
26 |
27 | double yk(unsigned k, unsigned n) {
28 | return log(xk(k, n));
29 | }
30 |
31 | double pn(double x, unsigned n) {
32 | double res = 0.0f;
33 |
34 | for(int k = 0; k <= n; k++)
35 | res += yk(k, n) * li(x, k, n) / li(xk(k, n), k, n);
36 |
37 | return res;
38 | }
39 |
40 | int main() {
41 |
42 | double x0 = 1.0f;
43 | double x1 = 2.0f;
44 | double h = 0.01f;
45 |
46 | //drawing log(x)
47 | ComplexPlot plot_log;
48 | double t = x0;
49 | while (t <= x1) {
50 | plot_log.push(t, {log(t), 0});
51 | t += h;
52 | }
53 | saveVectorPoint2DToFile(plot_log.real(), "plot_log.dat");
54 |
55 | ComplexPlot plot_errors;
56 |
57 | for(int n = 4; n <= 30; n++) {
58 | ComplexPlot plot;
59 |
60 | double x = x0;
61 | while (x <= x1) {
62 | plot.push(x, {pn(x, n) - log(x), 0});
63 | x += h;
64 | }
65 |
66 | plot_errors.push(n, {log(plot.maxReal()), 0});
67 |
68 | saveVectorPoint2DToFile(plot.real(), "plot" + to_string(n) + ".dat");
69 | }
70 |
71 | saveVectorPoint2DToFile(plot_errors.real(), "plot_errors.dat");
72 |
73 | // GRAPH PLOT
74 | GnuplotPipe gp;
75 | //gp.sendLine(R"(plot "plot4.dat" , "plot5.dat" , "plot6.dat" , "plot7.dat" , "plot8.dat" , "plot9.dat" , "plot10.dat" , "plot11.dat" , "plot12.dat" , "plot13.dat" , "plot14.dat" , "plot15.dat" )");
76 | gp.sendLine(R"(plot "plot15.dat" with lines)");
77 | //gp.sendLine(R"(plot "plot5.dat" with lines, "plot6.dat" with lines, "plot22.dat" with lines)");
78 |
79 | //gp.sendLine(R"(plot "plot_errors.dat")");
80 |
81 | return 0;
82 | }
--------------------------------------------------------------------------------
/gnuplot/demo/piecewise.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo of plotting piecewise functions
3 | #
4 | unset border
5 | set key center top reverse Left
6 | set xzeroaxis
7 | set yzeroaxis
8 | set xtics axis out scale 1,8
9 | set xtics add (1.00000 1, 6.28319 1)
10 | set ytics axis
11 | set title "Piecewise function sampling" font ",15"
12 | set xrange [ -2 : 10 ] noreverse nowriteback
13 |
14 | plot sample [*:1] x, [1:2.*pi] cos(x), [2.*pi:10] (x-8)**2
15 |
16 | pause -1 "Hit to continue"
17 | reset
18 | #
19 | # This example taken from
20 | # http://amca01.wordpress.com/2012/05/29/a-piecewise-polynomial-approximation-to-the-normal-cdf/
21 | # Original approximation from John Hoyt (1962), The American Statistician 22:25-26.
22 | #
23 | set termopt enhanced
24 | set termopt dash
25 | save_encoding = GPVAL_ENCODING; set encoding utf8
26 |
27 | set title "Piecewise approximation to the\nNormal Cumulative Distribution Function"
28 |
29 | set format "%.1f"
30 | set key left Left reverse invert
31 | set style data lines
32 | set xtics nomirror
33 | set xrange [ 0 : 4 ]
34 | set yrange [ 0.5 : 1.1 ]
35 | set style line 1 lt 0 lw 3
36 | set style line 2 lt 0 lw 3 lc rgb "red"
37 |
38 | part1(x) = 0.5 + (9.*x-x**3)/ 24.
39 | part2(x) = 1.0 + (x-3.0)**3 / 48.
40 |
41 | part1 = "part1: for x < 1 norm(x) ≈ ½ + (9x-x^3) / 24"
42 | part2 = "part2: for x > 1 norm(x) ≈ 1 + (x-3)^3 / 48"
43 |
44 | set label 1 at 1.0, 0.62
45 | set label 1 "plot norm(x), [0:1] part1(x), [1:4] part2(x)"
46 | set arrow 1 from 1.,.7 to 1.,.9 nohead
47 |
48 | plot norm(x) lt -1, \
49 | [1:4] part2(x) ls 2 title part2, \
50 | [0:1] part1(x) ls 1 title part1
51 |
52 | pause -1 "Hit to continue"
53 |
54 | set termopt solid
55 | reset
56 |
57 | set border 16
58 | unset xtics
59 | unset ytics
60 | set xyplane at 0
61 | set style data lines
62 | set key center at screen 0.5, screen 0.15
63 | set title font ",15"
64 | set title "Piecewise function of one parameter in 3D"
65 |
66 | splot [-2:2][-2:2] sample \
67 | [h=1:5] '+' using (cos(h)):(sin(h)):(h) lw 2, \
68 | [h=5:10] '+' using (cos(h)):(sin(h)):(h) lw 4, \
69 | [h=10:15] '+' using (cos(h)):(sin(h)):(h) lw 2
70 |
71 | pause -1 "Hit to continue"
72 |
73 | set encoding save_encoding
74 | reset
75 |
--------------------------------------------------------------------------------
/gnuplot/demo/parallel.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Parallel axis plot
3 | # shows plot layout but would better use some real data set
4 | # NB: March 2019 revised syntax for 5.3
5 | #
6 | set title "Parallel Axis Plot" font ",15"
7 |
8 | set border 0
9 | unset key
10 | set xrange [] noextend
11 | unset ytics
12 | set style data parallelaxes
13 |
14 | # Use x-axis tic positions to label the axes
15 | set xtics 1,1,5 format "axis %g" scale 0,0
16 |
17 | # Turn on axis tics for the parallel axes
18 | set for [i=1:5] paxis i tics
19 |
20 | # Use the range commands to create an "interesting" plot.
21 | # For suitable input data this is the sort of result you
22 | # might get without axis range manipulation.
23 |
24 | set paxis 2 range [0:30]
25 | set paxis 4 range [-10:50]
26 | set paxis 5 range [50:*] reverse
27 | set paxis 5 tics left offset 4
28 |
29 | plot 'silver.dat' using 2:(int($0/25)) lc variable, '' using 3, '' using 1, '' using ($3/2), '' using 2
30 |
31 | pause -1 "Hit return to continue"
32 |
33 | reset
34 |
35 | set title "Parallel Axis Plot" font ",15"
36 |
37 | save_encoding = GPVAL_ENCODING
38 | set encoding utf8
39 |
40 | set border 0
41 | unset ytics
42 | set xrange [] noextend
43 | unset key
44 |
45 | set style data parallelaxes
46 | set paxis 1 tics format '%.0f Å' offset -1
47 | set paxis 4 tics left offset 4 format '%.0f Å^2'
48 | set paxis 4 range [0:40]
49 |
50 | plot 'GM1_sugar.pdb' using 6:5 lc var lw 2 title "X", '' using 7 at 1.75 title "Y", '' using 8 at 2.5 title "Z", '' using 10 title "B"
51 |
52 | pause -1 "Hit return to continue"
53 | reset
54 |
55 | set style data parallel
56 | set palette defined (0 "dark-blue", 1 "dark-orange")
57 | set xrange [0.5:7.5]
58 | unset ytics
59 | set xtics font "/:Bold,13"
60 | unset border
61 | set bmargin 4
62 | unset colorbox
63 | a = 12.
64 | b = 34.
65 |
66 | set title "Parallel Axis Plot" font ",15"
67 |
68 | plot sample [x=1:20] '+' using (rand(0)):0 lc palette title "random", \
69 | '' u ($1) title "x", \
70 | '' u (-$1) title "-x", \
71 | '' u (a*$1) title "a*x", \
72 | '' u (a*$1+b) title "a*x+b", \
73 | '' u (exp($1)) title "e^x", \
74 | '' u (1/$1) title "1/x"
75 |
76 | pause -1 "Hit return to continue"
77 |
78 | set encoding save_encoding
79 | reset
80 |
--------------------------------------------------------------------------------
/gnuplot/demo/lcdemo.dat:
--------------------------------------------------------------------------------
1 | #
2 | # This file contains density values (2) against temperature (1) of a
3 | # common liquid crytsal (MBBA). At about 45.6 degr. there occurs a
4 | # phase transition indicated by the anomaly.
5 | #
6 | # Columns (3) and (4) contain weights for a straight line fit
7 | # preferredly in the low temperature range and in the high temperature
8 | # range, respectively. Of course not a very senseful approach but
9 | # a good demo to see the effect of weights in a fit.
10 | #
11 |
12 | # Column
13 | # 1 2 3 4 5
14 |
15 | 39.471 1.03307 1.0 0.98765 0.010
16 | 40.091 1.03246 1.0 0.98765 0.010
17 | 40.602 1.03197 1.0 0.98765 0.010
18 | 41.058 1.03153 1.0 0.98765 0.010
19 | 41.438 1.03117 1.0 0.98765 0.010
20 | 41.880 1.03074 1.0 0.98765 0.010
21 | 42.437 1.03021 1.0 0.98765 0.010
22 | 42.836 1.02982 1.0 0.98765 0.010
23 | 43.209 1.02946 1.0 0.98765 0.010
24 | 43.599 1.02907 1.0 0.98765 0.010
25 | 43.997 1.02867 1.0 0.98765 0.010
26 | 44.313 1.02833 1.0 0.98765 0.010
27 | 44.908 1.02765 1.0 0.98765 0.010
28 | 45.169 1.02735 1.0 0.98765 0.010
29 | 45.594 1.02683 1.0 0.98765 0.010
30 | 45.743 1.02661 999.0 0.98765 0.010
31 | 45.796 1.02650 999.0 0.98765 0.010
32 | 45.816 1.02644 999.0 0.98765 0.010
33 | 45.841 1.02634 999.0 0.98765 0.010
34 | 45.876 1.02623 999.0 0.98765 0.010
35 | 45.908 1.02611 999.0 0.98765 0.010
36 | 45.959 1.02592 999.0 0.98765 0.010
37 | 46.008 1.02561 999.0 0.12345 0.001
38 | 46.040 1.02526 999.0 0.12345 0.001
39 | 46.060 1.02506 999.0 0.12345 0.001
40 | 46.096 1.02500 999.0 0.12345 0.001
41 | 46.126 1.02496 999.0 0.12345 0.001
42 | 46.149 1.02494 999.0 0.12345 0.001
43 | 46.372 1.02474 999.0 0.12345 0.001
44 | 46.625 1.02452 999.0 0.12345 0.001
45 | 46.945 1.02425 999.0 0.12345 0.001
46 | 47.326 1.02393 999.0 0.12345 0.001
47 | 47.708 1.02361 999.0 0.12345 0.001
48 | 48.095 1.02329 999.0 0.12345 0.001
49 | 48.540 1.02293 999.0 0.12345 0.001
50 | 48.927 1.02262 999.0 0.12345 0.001
51 | 49.314 1.02231 999.0 0.12345 0.001
52 |
53 |
--------------------------------------------------------------------------------
/gnuplot/demo/surface2.dem:
--------------------------------------------------------------------------------
1 | set parametric
2 | set isosamples 50,10
3 | set hidden
4 | set key below
5 |
6 | set title "Parametric Sphere"
7 | set urange [-pi/2:pi/2]
8 | set vrange [0:2*pi]
9 | set ztics nomirror -1.0,0.25,1.0
10 | set view 45,50
11 | splot cos(u)*cos(v),cos(u)*sin(v),sin(u)
12 | pause -1 "Hit return to continue (1)"
13 |
14 | set view ,,,0.7
15 | set title "Parametric Sphere, crunched z axis"
16 | replot
17 | pause -1 "Hit return to continue (2)"
18 |
19 | set view ,,,1.4
20 | set title "Parametric Sphere, enlarged z axis"
21 | replot
22 | pause -1 "Hit return to continue (3)"
23 |
24 | set view ,,,1.0
25 |
26 | set title "Parametric Torus"
27 | set urange [0:2*pi]
28 | set vrange [0:2*pi]
29 | set zrange [-1:1] # imitate old 'set view' hack
30 | splot (1-0.2*cos(v))*cos(u),(1-0.2*cos(v))*sin(u),0.2*sin(v)
31 | pause -1 "Hit return to continue (4)"
32 |
33 |
34 | set title "Parametric Hexagon"
35 | set urange [-1.3:1.3]
36 | set vrange [0:2*pi]
37 | set autoscale z
38 | set ticslevel 0. # reserve more space z direction.
39 | set view ,,0.7,1.4 # crunch xyz, and re-extend z back to full size
40 | set ztics autofreq
41 | splot cos(v)**3*cos(u)**3,sin(v)**3*cos(u)**3,sin(u)**3
42 | pause -1 "Hit return to continue (5)"
43 |
44 | set view ,,1.,1.
45 |
46 | set title "Parametric Helix"
47 | set isosamples 100,20
48 | set urange [0:10*pi]
49 | set vrange [0:2*pi]
50 | set autoscale z
51 | splot (1-0.1*cos(v))*cos(u),(1-0.1*cos(v))*sin(u),0.1*(sin(v)+u/1.7-10)
52 | pause -1 "Hit return to continue (6)"
53 |
54 |
55 | set title "Parametric Shell (clipped to limited z range)"
56 | set isosamples 40,20
57 | set view 50,30,1.0
58 | set urange [0:2*pi]
59 | set vrange [0:2*pi]
60 | set zrange [-3:1.5]
61 | splot cos(u)*u*(1+cos(v)/2),sin(v)*u/2,sin(u)*u*(1+cos(v)/2)
62 | pause -1 "Hit return to continue (7)"
63 |
64 | set autoscale z
65 | set title "Parametric Shell (automatic z range)"
66 | replot
67 | pause -1 "Hit return to continue (8)"
68 |
69 | set title "Interlocking Tori"
70 |
71 | set urange [-pi:pi]
72 | set vrange [-pi:pi]
73 | set isosamples 50,20
74 | splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with lines, \
75 | 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with lines
76 | pause -1 "Hit return to continue (9)"
77 | reset
78 |
--------------------------------------------------------------------------------
/Matrix.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class Matrix final {
6 | private:
7 | std::vector> matrix;
8 | size_t r = 0;
9 | size_t c = 0;
10 | void init();
11 | void clean();
12 | bool valid = false;
13 | public:
14 | Matrix();
15 | Matrix(size_t cols);
16 | Matrix(size_t rows, size_t cols);
17 | ~Matrix();
18 |
19 | Matrix(const Matrix& mat);
20 |
21 | Matrix operator*(const Matrix& mat) const;
22 | Matrix operator-(const Matrix& mat) const;
23 | Matrix operator+(const Matrix& mat) const;
24 |
25 | Matrix operator*(double value) const;
26 | Matrix operator/(double value) const;
27 |
28 | Matrix& operator=(const Matrix& mat);
29 | Matrix& operator*=(const Matrix& mat);
30 | Matrix& operator+=(const Matrix& mat);
31 | Matrix& operator-=(const Matrix& mat);
32 |
33 | Matrix& operator*=(double value);
34 | Matrix& operator/=(double value);
35 |
36 | bool isValid();
37 |
38 | void resize(size_t rows, size_t cols);
39 |
40 | [[nodiscard]] const double& coeffRef(size_t rowIdx, size_t colIdx) const;
41 | double& coeffRef(size_t rowIdx, size_t colIdx);
42 |
43 | [[nodiscard]] const std::vector> & data() const;
44 | [[nodiscard]] std::vector> & data();
45 |
46 | size_t rows() const;
47 | size_t cols() const;
48 |
49 | Matrix& setIdentity();
50 | Matrix& setZero();
51 | Matrix& setConstants(double value);
52 |
53 | Matrix& setIdentity(size_t rows, size_t cols);
54 | Matrix& setZero(size_t rows, size_t cols);
55 | Matrix& setConstants(size_t rows, size_t cols, double value);
56 |
57 | Matrix diag();
58 | Matrix transpose();
59 | Matrix inverse();
60 | double det();
61 |
62 | //This is new useful functions:
63 | void print(); // Print matrix.
64 | void printSolution(); // Print solution for matrix (only for N*(N+1) sizes).
65 | double* solve(); // Solve matrix (only for N*(N+1) sizes).
66 | bool static linaryDep(double* r1, double* r2, size_t size_row); // Are r1 and r2 linery dependent.
67 | Matrix minor(int i, int j);
68 | //
69 |
70 | Matrix static identity(size_t rows, size_t cols);
71 | Matrix static zeros(size_t rows, size_t cols);
72 | Matrix static constants(size_t rows, size_t cols, double value);
73 |
74 | friend Matrix operator*(double value, const Matrix& mat);
75 | };
--------------------------------------------------------------------------------
/gnuplot/demo/custom_key.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Illustrate custom placement of individual plot titles outside the key box
3 | #
4 | set style data boxes
5 | set style fill solid border
6 | set boxwidth 0.5
7 | set datafile missing '-'
8 | set yrange [0:*]
9 | unset ytics
10 | unset xtics
11 | set xrange [-0.5:7.5]
12 | set offset 0,0,graph .1,0
13 |
14 | set label 1 at screen 0.75, screen 0.22 "{/:Bold Custom combined key area}" center
15 | set key autotitle columnhead nobox title " "
16 | set multiplot layout 3,2 columnsfirst \
17 | title "{/:Bold Illustrate use of a custom key area}" \
18 | margins 0.05, 0.95, 0.05, 0.90 spacing 0.0, 0.0
19 |
20 | plot 'immigration.dat' using 0:6 lt 1 title at 0.75, 0.18
21 | plot 'immigration.dat' using 0:12 lt 2 title at 0.75, 0.15
22 | plot 'immigration.dat' using 0:13 lt 3 title at 0.75, 0.12
23 | plot 'immigration.dat' using 0:14 lt 4 title at 0.75, 0.09
24 | set xtics scale 0 font ",8"
25 |
26 | plot 'immigration.dat' using 0:($6+$12+$13+$14):xtic(strcol(1)[6:]) with linespoints \
27 | lt black pt 7 title "total"
28 |
29 | unset multi
30 |
31 | if (exists("MANUAL_FIGURES")) exit
32 | pause -1 "Hit return to continue"
33 |
34 | reset
35 | #
36 | # Use of `keyentry` to construct a key
37 | # ====================================
38 | #
39 | reset
40 | set title "{/:Bold Construct key from custom entries}"
41 | set tics scale 0
42 | unset xtics
43 | set xrange [-0.5:4.5]
44 | set x2range [-0.5:4.5]
45 | set yrange [3.5:-0.5]
46 | set x2tics ("A" 0, "B" 1, "C" 2, "D" 3, "E" 4)
47 | set ytics 0,1
48 | set palette rgbform -7,2,-7
49 | unset colorbox
50 | set style fill solid border lc "black"
51 | set key outside right center reverse Left samplen 1
52 | set key title "{/:Bold Outcomes}" left
53 |
54 | $HEATMAP << EOD
55 | 5 4 3 1 0
56 | 2 2 0 0 1
57 | 0 0 0 1 0
58 | 0 1 4 1 3
59 | EOD
60 |
61 | plot $HEATMAP matrix with image pixels notitle, \
62 | keyentry with boxes fc palette cb 0 title "no effect", \
63 | keyentry with boxes fc palette cb 1 title "threshold", \
64 | keyentry with boxes fc palette cb 3 title "typical range", \
65 | keyentry with labels title "as reported in [12]", \
66 | keyentry with boxes fc palette cb 5 title "strong effect"
67 |
68 | pause -1 "Hit return to continue"
69 |
70 | reset
71 |
--------------------------------------------------------------------------------
/gnuplot/demo/world.dem:
--------------------------------------------------------------------------------
1 | set title "Gnuplot Correspondences\ngeographic coordinate system"
2 | unset key
3 | set xrange [-180:180]
4 | set yrange [-90:90]
5 | set yzeroaxis
6 | set xtics geographic
7 | set ytics geographic
8 | set format x "%D %E"
9 | set format y "%D %N"
10 | #
11 | # plot world map and correspondent locations as a +
12 | plot 'world.dat' with lines lc rgb "blue" , 'world.cor' with points lt 1 pt 2
13 | pause -1 "Hit return to continue"
14 | #
15 | # plot a '3D version using spherical coordinate system' of the world.
16 | reset
17 | unset key
18 | set border
19 | set xzeroaxis
20 | set yzeroaxis
21 | set xtics
22 | set ytics
23 | set angles degrees
24 | set title "3D version using spherical coordinate system"
25 | set ticslevel 0
26 | set view 70,40,0.8,1.2
27 | set view equal xyz
28 | set mapping spherical
29 | set parametric
30 | set samples 32
31 | set isosamples 9
32 | set urange [-90:90]
33 | set vrange [0:360]
34 | splot cos(u)*cos(v),cos(u)*sin(v),sin(u) with lines lc rgb "cyan" ,\
35 | 'world.dat' with lines lc rgb "blue" , 'world.cor' with points lt 1 pt 2
36 | pause -1 "Hit return to continue"
37 |
38 | # HBB 20000715: new demo:
39 | # same plot, but with hidden3d active, plus axes through the
40 | # poles:
41 | set title "3D solid version with hidden line removal"
42 | set hidden3d offset 0
43 | set arrow from 0,0,-1.2 to 0,0,1.2 lc rgb "cyan" lw 2
44 | set arrow from -1.2, 0, 0 to 1.2, 0, 0 nohead lc rgb "cyan" lw 1
45 | set arrow from 0, -1.2, 0 to 0, 1.2, 0 nohead lc rgb "cyan" lw 1
46 | splot cos(u)*cos(v),-cos(u)*sin(v),sin(u) with lines lc rgb "cyan" ,\
47 | 'world.dat' u 1:2:(1.001) with lines lc rgb "blue" , 'world.cor' with points lt 1 pt 2
48 | pause -1 "Hit return to continue"
49 |
50 | unset arrow
51 |
52 | #
53 | # plot a '3D version using cylindrical coordinate system' of the world.
54 | set title "3D version using cylindrical coordinate system"
55 | set view 70,40,0.8,1.2
56 | set view equal xy
57 | set mapping cylindrical
58 | set parametric
59 | set samples 32
60 | set isosamples 13
61 | set urange [-180:180]
62 | set vrange [-90:90]
63 | set zrange [-90:90]
64 | set xyplane at -110
65 | set ztics 30
66 |
67 | splot cos(u),sin(u),v with lines lc rgb "cyan" ,\
68 | 'world.dat' with lines lc rgb "blue" lw 2, 'world.cor' with points lt 1 pt 2
69 | pause -1 "Hit return to continue"
70 | reset
71 |
--------------------------------------------------------------------------------
/gnuplot/demo/armillary.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Show placement of circles in 3D using
3 | # - sampling
4 | # - circle objects in axis coordinates
5 | # - circle objects and labels in polar (cylindrical) coordinates
6 | #
7 | save_encoding = GPVAL_ENCODING
8 | set encoding utf8
9 |
10 | unset border
11 | unset key
12 | set angles degrees
13 | set view 64, 302, 1.62, 1.0
14 | set view azimuth 23.4
15 | set view equal xyz
16 | set style data lines
17 | set xzeroaxis
18 | set yzeroaxis
19 | set zzeroaxis
20 | set xyplane at 0
21 | unset tics
22 | set xrange [ -1.1 : 1.1 ]
23 | set yrange [ -1.1 : 1.1 ]
24 | set zrange [ -1.1 : 1.1 ]
25 | #
26 | set title "Circle and polygon objects in 3D" font ",20"
27 | set arrow from 0,0,-1.2 to 0,0,1.2 lw 2 filled
28 | #
29 | # Place circles as objects using Cartesian axis coordinates
30 | #
31 | set object 21 circle at 0,0,0 radius 1.0 fs empty border lc "black" lw 3 front
32 | set object 22 circle at 0,0,1 radius 0.1 fs transparent solid 0.5 fc "slategray"
33 | set object 23 circle at 0,0,-1 radius 0.1 fs transparent solid 0.5 fc "slategray"
34 |
35 | #
36 | # Pentagonal "base"
37 | #
38 | set obj 24 polygon from polar 0, 0.5, -1.2 to polar 72, 0.5, -1.2 to polar 144, 0.5, -1.2 to polar 216, 0.5, -1.2 to polar 288, 0.5, -1.2 to polar 0, 0.5, -1.2
39 | set obj 24 fillstyle solid border border lc "black" back fc "olive"
40 |
41 |
42 | #
43 | # Plot symbols for Zodiac constellations in polar (actually cylindrical) coordinates
44 | # Place a circle around the corresponding glyph
45 | # Note: Many fonts do not provide glyphs for these symbols
46 | #
47 | array Zodiac[13] = ["♐", "♑", "♒", "♓", "♈", "♉", "♊", "♋", "♌", "♍", "♎", "♏", "⛎"]
48 | array Longitude[13] = [267., 300., 328., 352., 29., 53., 90., 118., 138., 174., 218., 241., 248.]
49 | do for [i=1:13] {
50 | set label i Zodiac[i] at polar Longitude[i], 1.1, 0 center font ",15"
51 | set obj i circle at polar Longitude[i], 1.1, 0 radius char 1.5
52 | set obj i fs solid fc rgb hsv2rgb( Longitude[i]/360., 0.5, 1.0)
53 | }
54 |
55 | #
56 | # plot sampled parametric circles
57 | #
58 | splot sample [u=0:360] '+' using (cos(u)):(0):(sin(u)) lw 2, \
59 | [u=0:360] '+' using (cos(u)):(sin(u)):(0) lw 2, \
60 | [u=0:360] '+' using (0):(cos(u)):(sin(u)) lw 2
61 |
62 | pause -1 "Hit to continue"
63 |
64 | set encoding save_encoding
65 | reset
66 |
--------------------------------------------------------------------------------
/gnuplot/demo/errorbars.dem:
--------------------------------------------------------------------------------
1 | # Second part of old mgr.dem
2 | # Show the same plot with various errorbar styles
3 | #
4 | print "various styles of errorbar"
5 |
6 | set xlabel "Resistance [Ohm]"
7 | set ylabel "Power [W]"
8 |
9 | set title "error represented by xyerrorbars"
10 | n(x)=1.53**2*x/(5.67+x)**2
11 | plot [0:50] "battery.dat" t "Power" with xyerrorbars, n(x) t "Theory" w lines
12 |
13 | pause -1 "Would you like boxes? (-> return)"
14 | set title "error represented by boxxyerror"
15 | plot [0:50] "battery.dat" t "Power" with boxxyerr, n(x) t "Theory" w lines
16 |
17 | pause -1 "Only X-Bars? (-> return)"
18 | set title "error represented by xerrorbars"
19 | plot [0:50] "battery.dat" u 1:2:3 t "Power" w xerr, n(x) t "Theory" w lines
20 |
21 | pause -1 "Only Y-Bars? (-> return)"
22 | set title "error represented by yerrorbars"
23 | plot [0:50] "battery.dat" u 1:2:4 t "Power" w yerr, n(x) t "Theory" w lines
24 |
25 | pause -1 "Logscaled? (-> return)"
26 | set title "yerrorbars in log scale"
27 | set logscale y
28 | plot [0:50] "battery.dat" u 1:2:4 t "Power" w yerr, n(x) t "Theory" w lines
29 |
30 | pause -1 "X as well? (-> return)"
31 | set title "xyerrorbars in log scale"
32 | set logscale xy
33 | plot [1:50] "battery.dat" t "Power" w xyerr, n(x) t "Theory" w lines
34 |
35 | pause -1 "If you like bars without tics (-> return)"
36 | set title "xyerrorbars with no crossbar"
37 | unset logscale
38 | set bars small
39 | plot [0:50] "battery.dat" t "Power" with xyerrorbars, n(x) t "Theory" w lines
40 |
41 | pause -1 "X-Bars only (-> return)"
42 | set title "xerrorbars with no crossbar"
43 | plot [0:50] "battery.dat" u 1:2:3 t "Power" w xerr, n(x) t "Theory" w lines
44 |
45 | pause -1 "Y-Bars only (-> return)"
46 | set title "yerrorbars with no crossbar"
47 | plot [0:50] "battery.dat" u 1:2:4 t "Power" w yerr, n(x) t "Theory" w lines
48 |
49 | pause -1 "filledcurve shaded error region"
50 | set title "Error on y represented by filledcurve shaded region"
51 | set xlabel "Time (sec)"
52 | set ylabel "Rate"
53 | set grid xtics mxtics ytics mytics
54 | set log y
55 | Shadecolor = "#80E0A080"
56 | #
57 | plot 'silver.dat' using 1:($2+$3):($2-$3) \
58 | with filledcurve fc rgb Shadecolor title "Shaded error region",\
59 | '' using 1:2 smooth mcspline lw 2 title "Monotonic spline through data"
60 |
61 | pause -1 "Hit return to continue"
62 | reset
63 |
--------------------------------------------------------------------------------
/gnuplot/demo/histograms2.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Example of using histogram modes
3 | #
4 | reset
5 | set title "US immigration from Europe by decade"
6 | set datafile missing "-"
7 | set xtics nomirror rotate by -45
8 | set key noenhanced
9 | #
10 | # 'newhistogram' keyword to plot
11 | #
12 | set title "Default Histogram Colouring"
13 | set key under
14 | set key invert autotitle columnhead
15 | set style data histogram
16 | set style histogram clustered gap 1 title offset 2,-2 font ",11" boxed
17 | set style fill solid noborder
18 | set boxwidth 0.95
19 | unset xtics
20 | set xtics rotate by -45
21 | set xlabel "Immigration from different regions" offset 0, 0
22 | set ytics
23 | set grid y
24 | set auto y
25 | set bmargin 12
26 | #
27 | plot \
28 | newhistogram "Northern Europe", \
29 | 'immigration.dat' using 6:xtic(1), '' u 13, '' u 14, \
30 | newhistogram "Southern Europe", \
31 | '' u 9:xtic(1), '' u 17 , '' u 22 , \
32 | newhistogram "British Isles", \
33 | '' u 10:xtic(1) , '' u 21
34 | #
35 | pause -1 "Same plot using explicit histogram start colors"
36 | set title "Explicit start color in 'newhistogram' command"
37 | plot \
38 | newhistogram "Northern Europe" lt 4, \
39 | 'immigration.dat' using 6:xtic(1), '' u 13, '' u 14, \
40 | newhistogram "Southern Europe" lt 4, \
41 | '' u 9:xtic(1), '' u 17, '' u 22, \
42 | newhistogram "British Isles" lt 4, \
43 | '' u 10:xtic(1), '' u 21
44 | #
45 | #
46 | pause -1 "Same plot using explicit histogram start pattern"
47 | set title "Explicit start pattern in 'newhistogram' command"
48 | set style fill pattern 1 border -1
49 | plot \
50 | newhistogram "Northern Europe" fs pattern 1, \
51 | 'immigration.dat' using 6:xtic(1), '' u 13, '' u 14, \
52 | newhistogram "Southern Europe" fs pattern 1, \
53 | '' u 9:xtic(1), '' u 17, '' u 22, \
54 | newhistogram "British Isles" fs pattern 1, \
55 | '' u 10:xtic(1), '' u 21
56 | #
57 | #
58 | pause -1 "Same plot with both explicit color and pattern"
59 | set title "Explicit start pattern and linetype"
60 | set style fill pattern 1 border -1
61 | plot \
62 | newhistogram "Northern Europe" lt 2 fs pattern 1, \
63 | 'immigration.dat' using 6:xtic(1), '' u 13, '' u 14, \
64 | newhistogram "Southern Europe" lt 2 fs pattern 1, \
65 | '' u 9:xtic(1), '' u 17, '' u 22, \
66 | newhistogram "British Isles" lt 2 fs pattern 1, \
67 | '' u 10:xtic(1), '' u 21
68 | #
69 | #
70 | pause -1 "Hit return to continue"
71 | reset
72 |
--------------------------------------------------------------------------------
/gnuplot/demo/cerf.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Exercise the special functions in external library libcerf.
3 | # These are only present if libcerf was found during configuration/build
4 | # of the current gnuplot executable.
5 | #
6 | if (!strstrt(GPVAL_COMPILE_OPTIONS,"+LIBCERF")) {
7 | print "This copy of gnuplot was not linked against libcerf"
8 | exit;
9 | }
10 |
11 | save_encoding = GPVAL_ENCODING
12 | set encoding utf8
13 |
14 | set title "Voigt Profile VP(x,σ,γ)"
15 | set xrange [-10:10]
16 | set yrange [0.0:0.3]
17 | set xtics out nomirror
18 | set ytics in mirror format "%.2f"
19 | set mxtics
20 | set mytics
21 | set sample 200
22 |
23 | plot VP(x,1.53,0.0) title "σ=1.53 γ=0.00", \
24 | VP(x,1.30,0.5) title "σ=1.30 γ=0.50", \
25 | VP(x,1.00,1.0) title "σ=1.00 γ=1.00", \
26 | VP(x,0.00,1.8) title "σ=0.00 γ=1.80"
27 |
28 | pause -1 " to continue"
29 |
30 | set yrange [-1:1]
31 | set title "Faddeeva/Voigt Function"
32 | set key samplen 0.5
33 |
34 | plot real( faddeeva(x) ) lw 2, \
35 | imag( faddeeva(x) ) lw 2, \
36 | real(cdawson(x)) lt -1 lw 0.5 title "Dawson's Integral"
37 |
38 | pause -1 " to continue"
39 |
40 | reset
41 | unset key
42 | set view map
43 | set bmargin at screen 0.1
44 | set sample 200
45 | set isosamples 200, 200
46 | set size ratio 1 1,1
47 | set cbtics ("0" -pi, "2π" pi)
48 | set title "Complex error function cerf( x + iy )"
49 | set auto xy
50 | set urange [ -3 : 3 ]
51 | set vrange [ -3 : 3 ]
52 | set tics scale 0
53 | set cblabel "Phase Angle"
54 | set cblabel offset character -2, 0, 0 font "" textcolor lt -1 rotate by -270
55 | set cbrange [ -pi : pi ] noreverse nowriteback
56 |
57 | set contour
58 | set cntrparam levels discrete 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500
59 | set cntrlabel onecolor
60 |
61 | set palette positive nops_allcF maxcolors 0 gamma 1.5 color model HSV
62 | set palette defined ( 0 0 1 1, 1 1 1 1 )
63 |
64 | Hue(x,y) = (pi + atan2(-y,-x)) / (2*pi)
65 | phase(x,y) = hsv2rgb( Hue(x,y), sqrt(x**2+y**2), 1. )
66 | rp(x,y) = real(f(x,y))
67 | ip(x,y) = imag(f(x,y))
68 | color(x,y) = hsv2rgb( Hue( rp(x,y), ip(x,y) ), abs(f(x,y)), 1. )
69 | f(x,y) = cerf(x+y*{0,1})
70 |
71 | splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable nocontour, \
72 | '++' using 1:2:(abs(cerf($1+$2*{0,1}))) with lines nosurf lt -1
73 |
74 | pause -1 " to continue"
75 | reset
76 | set encoding save_encoding
77 |
--------------------------------------------------------------------------------
/gnuplot/demo/electron.dem:
--------------------------------------------------------------------------------
1 | # Electronics demo
2 | #
3 | # Bipolar Transistor (NPN) Mutual Characteristic
4 | Ie(Vbe)=Ies*exp(Vbe/kT_q)
5 | Ic(Vbe)=alpha*Ie(Vbe)+Ico
6 | alpha = 0.99
7 | Ies = 4e-14
8 | Ico = 1e-09
9 | kT_q = 0.025
10 | set dummy Vbe
11 | set grid
12 | set offsets
13 | unset log
14 | unset polar
15 | set samples 160
16 | set title "Mutual Characteristic of a Transistor"
17 | set xlabel "Vbe (base emmitter voltage)"
18 | set xrange [0 : 0.75]
19 | set ylabel "Ic (collector current)"
20 | set yrange [0 : 0.005]
21 | set key box
22 | set key at .2,.0045
23 | set format y "%.4f"
24 | plot Ic(Vbe)
25 | set format "%g"
26 |
27 | pause -1 "Hit return to continue"
28 |
29 | # Junction Field Effect Transistor (JFET) Mutual Characteristic
30 | # drain current above pinch off
31 | Ida(Vd)=Ido*(1-Vg/Vp)**2
32 | # drain current below pinch off
33 | Idb(Vd)=Ido*(2*Vd*(Vg-Vp)-Vd*Vd)/(Vp*Vp)
34 | # drain current
35 | Id(Vd)= (Vd>Vg-Vp) ? Ida(Vd) : Idb(Vd)
36 | # drain current at zero gate voltage
37 | Ido = 2.5
38 | # pinch off voltage
39 | Vp = -1.25
40 | # gate voltage
41 | Vg = 0
42 | set dummy Vd
43 | unset grid
44 | unset key
45 | #set offsets 0, 1, 0, 0
46 | set title "JFET Mutual Characteristic"
47 | set xlabel "Drain voltage Vd (V)"
48 | set xrange [0 : 4]
49 | set ylabel "Drain current Id (mA)"
50 | set yrange [0 : 5]
51 | set rmargin 12
52 | set label 1 "-0.5 Vp" at 4.1,0.625
53 | set label 2 "-0.25 Vp" at 4.1,1.4
54 | set label 3 "0" at 4.1,2.5
55 | set label 4 "Vg = 0.5 Vp" at 4.1,3.9
56 | plot Vg=0.5*Vp,Id(Vd),Vg=0.25*Vp,Id(Vd),Vg=0,Id(Vd),Vg=-0.25*Vp,Id(Vd)
57 |
58 | pause -1 "Hit return to continue"
59 | unset label
60 | unset rmargin
61 |
62 | # show off double axes
63 |
64 | # amplitude frequency response
65 | A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
66 | p1 = 10
67 | p2 = 10000
68 | set dummy jw
69 | set grid x y2
70 | set logscale xy
71 | set log x2
72 | unset log y2
73 | set key default
74 | set key bottom center box
75 | set title "Amplitude and Phase Frequency Response"
76 | set xlabel "jw (radians)"
77 | set xrange [1.1 : 90000.0]
78 | set ylabel "magnitude of A(jw)"
79 | set y2label "Phase of A(jw) (degrees)"
80 | set ytics nomirror tc lt 1
81 | set y2tics nomirror tc lt 3
82 | set xtics mirror
83 | set tics out
84 | set autoscale y
85 | set autoscale y2
86 | plot abs(A(jw)) lt 1, 180/pi*arg(A(jw)) axes x1y2 lt 3
87 |
88 | pause -1 "Hit return to continue"
89 |
90 | # undo what we've done
91 | reset
92 |
--------------------------------------------------------------------------------
/gnuplot/demo/iterate.dem:
--------------------------------------------------------------------------------
1 | set title "Iteration within plot command"
2 | set xrange [0:3]
3 | set label 1 "plot for [n=2:10] sin(x*n)/n" at graph .95, graph .92 right
4 | plot for [n=2:10] sin(x*n)/n notitle lw (13-n)/2
5 | pause -1 "Hit return to continue"
6 | reset
7 |
8 | set title "Iteration over all available data in a file"
9 | set view 38., 341.
10 | unset xtics
11 | unset ytics
12 | unset ztics
13 | set border 0
14 | set lmargin at screen 0.09
15 | set rmargin at screen 0.90
16 | set key outside below samplen 0.6
17 | set key title "splot for [scan=1:*] 'whale.dat' index scan"
18 | set key maxrows 6
19 | splot for [i=1:*] "whale.dat" index i title sprintf("scan %d",i) with lines
20 | pause -1 "Hit return to continue"
21 | reset
22 |
23 |
24 | # Dynamic reevaluation of iteration limits
25 | # inner loop refers to the control variable of an outer loop
26 | #
27 | set key opaque box height 1 title "Dynamic iteration limits"
28 | set title "plot for [i=1:4] for [k=i:i] for [j=1:k] 10*k + cos(j*x)"
29 | plot for [i=1:4] for [k=i:i] for [j=1:k] 10*k + cos(j*x) lw j \
30 | title sprintf("k=%d j=%d", i, j)
31 | pause -1 "Hit return to continue"
32 |
33 | # More iteration tests (no graph output)
34 | #
35 | print "\ndynamic reevaluation of numeric iteration limits"
36 | array J[3] = [ 1, 4, 3 ]
37 | print "\nJ =",J
38 | Output = ""
39 | print "do for [i=1:3] for [j=J[i]:3] { save(i,j) }"
40 | do for [i=1:3] for [j=J[i]:3] { Output = Output . sprintf("%d-%d ",i,j) }
41 | print Output
42 |
43 | array J[3] = [ 4, 1, 3 ]
44 | print "\nJ =",J
45 | Output = ""
46 | print "do for [i=1:3] for [j=J[i]:3] { save(i,j) }"
47 | do for [i=1:3] for [j=J[i]:3] { Output = Output . sprintf("%d-%d ",i,j) }
48 | print Output
49 |
50 | print ""
51 | Output = ""
52 | print "do for [i=1:4] for [k=i:i] for [j=1:k] { save(i,j) }"
53 | do for [i=1:4] for [k=i:i] for [j=1:k] { Output = Output . sprintf("%d-%d ",i,j) }
54 | print Output
55 |
56 | print "\ndynamic reevaluation of iteration string"
57 |
58 | array A[3] = [ "a b", "", "d" ]
59 | print "A = ", A
60 |
61 | print 'do for [ i = 1:|A| ] { do for [ j in A[i]] { print "".i.": ".j }}'
62 | Output = ""
63 | do for [ i = 1:|A| ] { do for [ j in A[i]] { Output = Output." ".i.": ".j }}
64 | print Output
65 |
66 | print 'do for [ i = 1:|A| ] for [ j in A[i]] { print "".i.": ".j }'
67 | Output = ""
68 | do for [ i = 1:|A| ] for [ j in A[i]] { Output = Output." ".i.": ".j }
69 | print Output
70 |
71 | reset
72 |
--------------------------------------------------------------------------------
/gnuplot/demo/textcolor.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Textcolor in 2D
3 | #
4 | reset
5 | #
6 | set title "Textcolor options in 2D plot (notice this title in color)" tc lt 1
7 | set xrange [-2:2]
8 | set yrange [-2:2]
9 | #
10 | set label 11 "label with textcolor lt 1" at -1.5, 1.8 front nopoint tc lt 1
11 | set label 10 "label with tc default" at -1.5, 1.6 front nopoint tc def
12 | set label 12 "label with tc lt 2" at -1.5, 1.4 front nopoint tc lt 2
13 | set label 13 "label with tc lt 3" at -1.5, 1.2 front nopoint tc lt 3
14 | #
15 | set xlabel 'color of xlabel should be lt 4' tc lt 4
16 | set ylabel 'color of ylabel should still be black'
17 | #
18 | plot sin(x)
19 | #
20 | pause -1 "Hit return to continue"
21 | #
22 | # Textcolor in 3D (req. pm3d)
23 | #
24 | set title "Textcolor options in splot (notice this title in color)" tc lt 1
25 | set samples 20; set isosamples 20
26 | set autoscale
27 | set key box
28 | set pm3d at s
29 | set colorbox horiz user origin .1,.12 size .8,.015
30 | set view 58, 64, 0.83
31 | set xrange [-10:10]
32 | set yrange [-10:10]
33 | set zrange [-10:10]
34 | #
35 | # Test labels
36 | #
37 | set label 1 "textcolor palette z" at 12,-10,-10 nopoint tc pal z
38 | set label 3 "tc pal z" at 12, -6, -6 nopoint tc pal z
39 | set label 4 "tc pal z" at 12, -3, -3 nopoint tc pal z
40 | set label 5 "tc pal z" at 12, -0, 0 nopoint tc pal z
41 | set label 6 "tc pal z" at 12, 3, 3 nopoint tc pal z
42 | set label 7 "tc pal z" at 12, 6, 6 nopoint tc pal z
43 | set label 8 "tc pal z" at 12, 9, 9 nopoint tc pal z
44 | #
45 | set xlabel 'xlabel should be lt 4' tc lt 4
46 | set cblabel 'color cblabel' textcolor lt 3
47 | #
48 | set label 10 "textcolor lt 1" at -10,-8,24 front nopoint tc lt 1
49 | set label 11 "tc lt 2" at -10,-8,21 front nopoint tc lt 2
50 | set label 12 "tc lt 3" at -10,-8,18 front nopoint tc lt 3
51 | set label 13 "textcolor default" at -10,-8,15 front nopoint tc def
52 | set label 14 "textcolor cb 5" at -10,-8,12 front nopoint tc pal cb 5
53 | set label 15 "tc cb 0" at -10,-8,9 front nopoint tc pal cb 0
54 | set label 16 "tc cb -5" at -10,-8,6 front nopoint tc pal cb -5
55 | set label 17 "textcolor frac .75" at -10,-8,3 nopoint tc pal frac .75
56 | set label 18 "tc frac .25" at -10,-8,0 nopoint tc pal frac .25
57 | #
58 | set ylabel 'ylabel should still be black'
59 | #set zlabel 'zlabel should have yet another color' tc lt 2
60 | #
61 | splot y
62 | #
63 | pause -1 "Hit return to continue"
64 | #
65 |
66 | reset
67 |
68 |
--------------------------------------------------------------------------------
/gnuplot.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software: you can redistribute it and/or modify
3 | * it under the terms of the GNU Lesser General Public License as published by
4 | * the Free Software Foundation, either version 3 of the License, or
5 | * (at your option) any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * GNU Lesser General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU Lesser General Public License
13 | * along with this program. If not, see .
14 | *
15 | * URL: https://github.com/martinruenz/gnuplot-cpp
16 | * AUTHOR: Martin Rünz, 2015
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | class GnuplotPipe {
28 | public:
29 | inline GnuplotPipe(bool persist = true) {
30 | std::cout << "Opening gnuplot... ";
31 | pipe = popen(persist ? R"(gnuplot -persist)" : "gnuplot", "w");
32 | if (!pipe)
33 | std::cout << "failed!" << std::endl;
34 | else
35 | std::cout << "succeded." << std::endl;
36 | }
37 | inline virtual ~GnuplotPipe(){
38 | if (pipe) pclose(pipe);
39 | }
40 |
41 | void sendLine(const std::string& text, bool useBuffer = false){
42 | if (!pipe) return;
43 | if (useBuffer)
44 | buffer.push_back(text + "\n");
45 | else
46 | fputs((text + "\n").c_str(), pipe);
47 | }
48 | void sendEndOfData(unsigned repeatBuffer = 1){
49 | if (!pipe) return;
50 | for (unsigned i = 0; i < repeatBuffer; i++) {
51 | for (auto& line : buffer) fputs(line.c_str(), pipe);
52 | fputs("e\n", pipe);
53 | }
54 | fflush(pipe);
55 | buffer.clear();
56 | }
57 | void sendNewDataBlock(){
58 | sendLine("\n", !buffer.empty());
59 | }
60 |
61 | void writeBufferToFile(const std::string& fileName){
62 | std::ofstream fileOut(fileName);
63 | for (auto& line : buffer) fileOut << line;
64 | fileOut.close();
65 | }
66 |
67 | private:
68 | GnuplotPipe(GnuplotPipe const&) = delete;
69 | void operator=(GnuplotPipe const&) = delete;
70 |
71 | FILE* pipe;
72 | std::vector buffer;
73 | };
74 |
--------------------------------------------------------------------------------
/gnuplot/demo/orbits.dem:
--------------------------------------------------------------------------------
1 | # Ellipse demo - 2D Solar System viewer
2 |
3 | reset
4 |
5 | set zeroaxis
6 | set xtics axis
7 | set ytics axis
8 | set size ratio 1
9 | set xrange [-40:40]
10 | set yrange [-40:40]
11 | unset border
12 | set key right out
13 | set title "Orbits of selected Solar System objects"
14 | set angles degrees
15 | set datafile separator "\t"
16 | if (strstrt(GPVAL_TERM,"wxt") || strstrt(GPVAL_TERM,"qt")) {
17 | set label 1 "Use Ctrl+mousewheel to zoom!" at graph 0.5,0.05 center
18 | set style textbox opaque
19 | set label 1 front boxed
20 | }
21 |
22 | fn = 'orbital_elements.dat'
23 |
24 | # functions to calculate the parameters of the ellipses from orbital elements
25 | # the actual 3D orbits are projected onto the ecliptic plane
26 | f1(w,W,i) = cos(w)*cos(W)-sin(w)*sin(W)*cos(i)
27 | f2(w,W,i) = cos(w)*sin(W)+sin(w)*cos(W)*cos(i)
28 |
29 | angle(w,W,i) = atan2(f2(w,W,i), f1(w,W,i))
30 | # center coordinates
31 | cx(a,e,i,w,W) = -a*e*f1(w,W,i)
32 | cy(a,e,i,w,W) = -a*e*f2(w,W,i)
33 | # axes
34 | fa(a,e,i,w,W) = 2*a*sqrt(1-sin(w)**2*sin(i)**2)
35 | fb(a,e,i,w,W) = 2*a*sqrt(1-e**2)*sqrt(1-cos(w)**2*sin(i)**2)
36 | afromq(q,e) = q/(1-e)
37 |
38 | # the ellipse style needs five columns:
39 | # center x, center y, major axis, minor axis, orientation
40 |
41 | plot fn using (cx($2,$3,$4,$5,$6)):\
42 | (cy($2,$3,$4,$5,$6)):\
43 | (fa($2,$3,$4,$5,$6)):\
44 | (fb($2,$3,$4,$5,$6)):\
45 | (angle($5,$6,$4)) index 0 with ellipses lw 3 title "Planets",\
46 | fn using (cx($2,$3,$4,$5,$6)):\
47 | (cy($2,$3,$4,$5,$6)):\
48 | (fa($2,$3,$4,$5,$6)):\
49 | (fb($2,$3,$4,$5,$6)):\
50 | (angle($5,$6,$4)) index 1 every ::0::20 with ellipses lw 1 title "Minor planets",\
51 | fn using (cx($2,$3,$4,$5,$6)):\
52 | (cy($2,$3,$4,$5,$6)):\
53 | (fa($2,$3,$4,$5,$6)):\
54 | (fb($2,$3,$4,$5,$6)):\
55 | (angle($5,$6,$4)) index 2 every ::0::10 with ellipses lw 1 title "Comets",\
56 | fn using (cx($2,$3,$4,$5,$6)):\
57 | (cy($2,$3,$4,$5,$6)):\
58 | (fa($2,$3,$4,$5,$6)):\
59 | (fb($2,$3,$4,$5,$6)):\
60 | (angle($5,$6,$4)) index 3 every ::0::10 with ellipses lw 1 title "Distant objects"
61 |
62 | pause -1
63 |
64 | set size ratio -1
65 | set view equal xy
66 | set xrange [*:*]
67 | set yrange [-100:100]
68 | set key inside left
69 | replot
70 |
71 | pause -1
72 | reset
73 |
--------------------------------------------------------------------------------
/gnuplot/demo/scatter2.dat:
--------------------------------------------------------------------------------
1 | 25. 1.0 .99443
2 | 25. 10.0 .9406
3 | 25. 20.0 .8749
4 | 25. 30.0 .8030
5 | 25. 40.0 .7195
6 | 25. 50.0 .6190
7 | 25. 60.0 .4844
8 | 25. 70.0 .3409
9 | 25. 80.0 .3170
10 | 25. 90.0 .3273
11 | 25. 100.0 .3451
12 | 25. 110.0 .3656
13 | 25. 120.0 .3872
14 | 25. 130.0 .4096
15 | 25. 140.0 .4321
16 | 25. 150.0 .4549
17 | 25. 160.0 .4777
18 | 25. 170.0 .5005
19 | 25. 180.0 .5223
20 | 25. 190.0 .5460
21 | 25. 200.0 .5687
22 | 25. 250.0 .6798
23 | 25. 300.0 .7889
24 | 25. 350.0 .8962
25 | 25. 400.0 1.0015
26 | 25. 450.0 1.1046
27 | 25. 500.0 1.2063
28 | 25. 600.0 1.4058
29 | 25. 700.0 1.6008
30 | 25. 800.0 1.7920
31 |
32 | 50. 1.0 .99571
33 | 50. 10.0 .9546
34 | 50. 20.0 .9066
35 | 50. 30.0 .8552
36 | 50. 40.0 .8013
37 | 50. 50.0 .7436
38 | 50. 60.0 .6818
39 | 50. 70.0 .6171
40 | 50. 80.0 .5541
41 | 50. 90.0 .5017
42 | 50. 100.0 .4706
43 | 50. 110.0 .4605
44 | 50. 120.0 .4622
45 | 50. 130.0 .4711
46 | 50. 140.0 .4841
47 | 50. 150.0 .4996
48 | 50. 160.0 .5166
49 | 50. 170.0 .5346
50 | 50. 180.0 .5533
51 | 50. 190.0 .5724
52 | 50. 200.0 .5906
53 | 50. 250.0 .6898
54 | 50. 300.0 .7888
55 | 50. 350.0 .8880
56 | 50. 400.0 .9851
57 | 50. 450.0 1.0813
58 | 50. 500.0 1.1758
59 | 50. 600.0 1.3615
60 | 50. 700.0 1.5430
61 | 50. 800.0 1.7208
62 |
63 | 75. 1.0 .99661
64 | 75. 10.0 .9647
65 | 75. 20.0 .9283
66 | 75. 30.0 .8904
67 | 75. 40.0 .8518
68 | 75. 50.0 .8124
69 | 75. 60.0 .7723
70 | 75. 70.0 .7323
71 | 75. 80.0 .6934
72 | 75. 90.0 .6572
73 | 75. 100.0 .6255
74 | 75. 110.0 .6012
75 | 75. 120.0 .5847
76 | 75. 130.0 .5756
77 | 75. 140.0 .5731
78 | 75. 150.0 .5770
79 | 75. 160.0 .5839
80 | 75. 170.0 .5937
81 | 75. 180.0 .6055
82 | 75. 190.0 .6188
83 | 75. 200.0 .6333
84 | 75. 250.0 .7149
85 | 75. 300.0 .8027
86 | 75. 350.0 .8916
87 | 75. 400.0 .9802
88 | 75. 450.0 1.0684
89 | 75. 500.0 1.1560
90 | 75. 600.0 1.3293
91 | 75. 700.0 1.4995
92 |
93 | 100. 1.0 .99727
94 | 100. 10.0 .9720
95 | 100. 20.0 .9438
96 | 100. 30.0 .9153
97 | 100. 40.0 .8866
98 | 100. 50.0 .8579
99 | 100. 60.0 .8295
100 | 100. 70.0 .8017
101 | 100. 80.0 .7749
102 | 100. 90.0 .7497
103 | 100. 100.0 .7268
104 | 100. 110.0 .7074
105 | 100. 120.0 .6913
106 | 100. 130.0 .6793
107 | 100. 140.0 .6712
108 | 100. 150.0 .6668
109 | 100. 160.0 .6657
110 | 100. 170.0 .6679
111 | 100. 180.0 .6728
112 | 100. 190.0 .6801
113 | 100. 200.0 .6889
114 | 100. 250.0 .7494
115 | 100. 300.0 .8233
116 | 100. 350.0 .9027
117 | 100. 400.0 .9839
118 | 100. 450.0 1.0653
119 |
--------------------------------------------------------------------------------
/gnuplot/demo/fillcrvs.dem:
--------------------------------------------------------------------------------
1 | #
2 | ### Demo for 'with filledcurves'
3 |
4 | reset
5 |
6 | set title
7 | set key outside
8 | set title "plot with filledcurve [options]"
9 | plot [-10:10] [-5:3] \
10 | 1.5+sin(x)/x with filledcurve x2, \
11 | sin(x)/x with filledcurve, \
12 | 1+sin(x)/x with lines, \
13 | -1+sin(x)/x with filledcurve y1=-2, \
14 | -2.5+sin(x)/x with filledcurve xy=-5,-4., \
15 | -4.3+sin(x)/x with filledcurve x1, \
16 | (x>3.5 ? x/3-3 : 1/0) with filledcurve y2
17 | pause -1 'Press Return to continue'
18 |
19 | set key on
20 | set title "Intersection of two parabolas"
21 | plot x*x with filledcurves, 50-x*x with filledcurves, x*x with line lt 1
22 | pause -1 'Press Return to continue'
23 |
24 | set grid front
25 | set title "Filled sinus and cosinus curves"
26 | plot 2+sin(x)**2 with filledcurve x1, cos(x)**2 with filledcurve x1
27 | pause -1 'Press Return to continue'
28 |
29 | set title "The red bat: abs(x) with filledcurve xy=2,5"
30 | plot abs(x) with filledcurve xy=2,5
31 | pause -1 'Press Return to continue'
32 |
33 | set title "Some sqrt stripes on filled graph background"
34 | plot [0:10] [-8:6] \
35 | -8 with filledcurve x2 lt 15, \
36 | sqrt(x) with filledcurves y1=-0.5, \
37 | sqrt(10-x)-4.5 with filledcurves y1=-5.5
38 | pause -1 'Press Return to continue'
39 |
40 | reset
41 | set title "Let's smile with parametric filled curves"
42 | set size square
43 | set key off
44 | unset border
45 | unset xtics
46 | unset ytics
47 | set grid
48 | set arrow 1 from -0.1,0.26 to 0.18,-0.17 front size 0.1,40 lt 5 lw 4
49 | set label 1 "gnuplot" at 0,1.2 center front
50 | set label 2 "gnuplot" at 0.02,-0.6 center front
51 | set parametric
52 | set xrange [-1:1]
53 | set yrange [-1:1.6]
54 | plot [t=-pi:pi] \
55 | sin(t),cos(t) with filledcurve xy=0,0 lt 15, \
56 | sin(t)/8-0.5,cos(t)/8+0.4 with filledcurve lt 3, \
57 | sin(t)/8+0.5,cos(t)/8+0.4 with filledcurve lt 3, \
58 | t/5,abs(t/5)-0.8 with filledcurve xy=0.1,-0.5 lt 1, \
59 | t/3,1.52-abs(t/pi) with filledcurve xy=0,1.8 lt -1
60 | pause -1 'Press Return to continue'
61 |
62 | reset
63 |
64 | set title "world.dat plotted with filledcurves"
65 | set format x ""
66 | set format y ""
67 | set grid layerdefault linewidth 0.5
68 | set object 1 rect from graph 0, 0 to graph 1, 1 behind fc rgb "#afffff" fillstyle solid 1.00 border -1
69 | set xrange [ -180.000 : 180.000 ]
70 | set yrange [ -70.0000 : 80.0000 ]
71 | set lmargin 1
72 | plot 'world.dat' with filledcurve notitle fs solid 1.0 lc rgb 'dark-goldenrod'
73 | pause -1 'Press Return to continue'
74 |
75 | reset
76 |
--------------------------------------------------------------------------------
/gnuplot/demo/autoscale.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo of constraint autoscaling: Autoscaling with limits.
3 | #
4 |
5 | set multiplot layout 2, 2 title "Autoscaling with constraints (y-axis always unaffected)"
6 |
7 | unset key
8 | # set title offset 0,-0.4
9 | # set xlabel offset 0,0.4
10 |
11 | set ytics 5
12 |
13 | set title "unconstrained"
14 | set ylabel "[*:*]"
15 | set yrange [*:*]
16 | set xlabel "[*:*]"
17 | set xrange [*:*]
18 | plot "3.dat"
19 |
20 | set title "minimum range guaranteed"
21 | set ylabel "[*<-5:5<*]"
22 | set yrange [*<-5:5<*]
23 | set xlabel "[*<-40:30<*]"
24 | set xrange [*<-40:30<*]
25 | plot "3.dat"
26 |
27 | set title "clip to maximum range"
28 | set ylabel "[-20<*:*<20]"
29 | set yrange [-20<*:*<20]
30 | set xlabel "[-30<*:*<10]"
31 | set xrange [-30<*:*<10]
32 | plot "3.dat"
33 |
34 | set title "mixed"
35 | set xlabel "[-30<*<10:10<*<15]"
36 | set xrange [-30<*<10:10<*<15]
37 | set ylabel "[*:0<*<10]"
38 | set yrange [*:0<*<10]
39 | plot "3.dat"
40 |
41 | unset multiplot
42 |
43 | pause -1 "Hit return to continue"
44 |
45 |
46 | set multiplot layout 2, 2 title "Autoscaling with constraints (x-axis always unaffected)"
47 |
48 | unset key
49 | set ytics 5
50 |
51 | set title "unconstrained"
52 | set ylabel "[*:*]"
53 | set yrange [*:*]
54 | set xlabel "[*:*]" offset 0, 0.4
55 | set xrange [*:*]
56 | plot "3.dat"
57 |
58 | set title "minimum range guaranteed"
59 | set ylabel "[*<-15:20<*]"
60 | set yrange [*<-15:20<*]
61 | set xlabel "[*<-10:10<*]"
62 | set xrange [*<-10:10<*]
63 | plot "3.dat"
64 |
65 | set ytics 2
66 |
67 | set title "clip to maximum range"
68 | set ylabel "[-8<*:*<5]"
69 | set yrange [-8<*:*<5]
70 | set xlabel "[-40<*:*<30]"
71 | set xrange [-40<*:*<30]
72 | plot "3.dat"
73 |
74 | set title "mixed"
75 | set xlabel "[-30<*<10:-10<*<45]"
76 | set xrange [-30<*<10:-10<*<45]
77 | set ylabel "[-8<*<-6:7<*<9]"
78 | set yrange [-8<*<-6:7<*<9]
79 | plot "3.dat"
80 |
81 | unset multiplot
82 |
83 | pause -1 "Hit return to continue"
84 | unset xlabel
85 | unset ylabel
86 |
87 | set multiplot layout 2, 2 title "Autoscaling with constraints"
88 |
89 | set ytics 50
90 |
91 | set autoscale xy
92 | set title "autoscale xy"
93 | plot "silver.dat"
94 |
95 | set yrange [15<*<25:*]
96 | set title "set yrange [15<*<25:*]"
97 | plot "silver.dat"
98 |
99 | set autoscale ymin
100 | set title "set autoscale ymin"
101 | plot "silver.dat"
102 |
103 | set ytics 20
104 | set yrange [15<*<25:135<*<225]
105 | set title "set yrange [15<*<25:135<*<225]"
106 | plot "silver.dat"
107 |
108 | unset multiplot
109 |
110 | pause -1 "Hit return to continue"
111 | reset
112 |
--------------------------------------------------------------------------------
/gnuplot/demo/clipobject.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Demo and test for clipping applied to objects.
3 | # axis coordinates run from [-1:1]
4 | # graph coordinates from from [0:1]
5 | # screen coordinates from from [0.2:0.8]
6 | #
7 | reset
8 |
9 | set title "Default object clipping"
10 | set label 1 at graph 0.5, 0.9 center
11 | set label 1 "Outer = screen coords\nMiddle = graph coords\nInner = axis coords"
12 |
13 | set xrange[-1:1]
14 | set yrange[-1:1]
15 | set macros
16 | fs="fillstyle solid 1.0 border lc rgb 'black' lw 2"
17 | unset key
18 |
19 | set lmargin at screen 0.2
20 | set rmargin at screen 0.8
21 | set tmargin at screen 0.8
22 | set bmargin at screen 0.2
23 |
24 | set object 1 rectangle from screen 0.1,screen 0.1 to screen 0.4, screen 0.4
25 | set object 1 fc rgb '#880000' @fs
26 |
27 | set object 11 rectangle from first -1.1,first -1.1 to first -0.9, first -0.9
28 | set object 11 fc rgb 'red' @fs
29 | set object 11 front
30 |
31 | set object 111 rectangle from graph -.1, -.1 to graph .1,.1
32 | set object 111 fc rgb "#DDAA00' @fs
33 |
34 |
35 | set object 2 circle at screen 0.2, screen 0.8 radius screen 0.1
36 | set object 2 fc rgb '#008800' @fs
37 |
38 | set object 22 circle at first -1, 1 radius first .15
39 | set object 22 fc rgb 'green' @fs
40 | set object 22 front
41 |
42 | set object 222 circle at graph 0, graph 1 radius graph 0.1
43 | set object 222 fc rgb '#00DDAA' @fs
44 |
45 |
46 | set object 3 polygon from screen 0.6,screen 0.6 rto 0.4,0 rto -0.2,0.4
47 | set object 3 fc rgb '#BBBB00' @fs
48 |
49 | set object 33 polygon from first 0.8,first 0.8 rto first 0.4,0 rto first -0.2, 0.4
50 | set object 33 fc rgb 'yellow' @fs
51 | set object 33 front
52 |
53 | set object 333 polygon from graph .8,graph .8 rto graph 0.4,0 rto graph -0.2, 0.4
54 | set object 333 fc rgb '#AAAA88' @fs
55 |
56 | set object 4 ellipse at screen 0.8, screen 0.2 size screen 0.3, 0.25
57 | set object 4 fc rgb '#4444bb' @fs
58 |
59 | set object 44 ellipse at first 1, -1 size first 0.4, first 0.25
60 | set object 44 fc rgb "cyan" @fs
61 | set object 44 front
62 |
63 | set object 444 ellipse at graph 1,graph 0 size first 0.8, first 0.5
64 | set object 444 fc rgb '#6666ff' @fs
65 |
66 |
67 | plot 0
68 |
69 | pause -1 "Hit return to continue"
70 |
71 | set title "Object property 'noclip'"
72 |
73 | do for [i=1:4]{ set object i noclip; set object i*11 noclip; set object i*111 noclip; }
74 |
75 | plot 0
76 |
77 | pause -1 "Hit return to continue"
78 |
79 | set title "Clipping in 3D projection ('set view map')"
80 | do for [i=1:4]{ set object i clip; set object i*11 clip; set object i*111 clip; }
81 | set view map
82 | set zrange [.1:100]
83 | set log z
84 | splot 0
85 |
86 | pause -1 "Hit return to continue"
87 |
88 | undefine fs
89 | reset
90 |
--------------------------------------------------------------------------------
/gnuplot/demo/hidden2.dem:
--------------------------------------------------------------------------------
1 | #
2 | # PM3D surfaces are not fully included in the calculation of hidden line removal.
3 | # Older versions of gnuplot allowed you to approximate the correct occlusion
4 | # by drawing the surface twice, once "with pm3d" to produce the surface you
5 | # want to show, and once "with lines lt -2" to include the same surface in
6 | # hidden3d calculations but drawn with invisible lines.
7 | # Current gnuplot does the approximation for you so the extra copy of the
8 | # surface is no longer necessary.
9 | #
10 | set isosamples 25,25
11 | set xyplane at 0
12 | unset key
13 |
14 | set palette rgbformulae 31,-11,32
15 | set style fill solid 0.5
16 | set cbrange [-1:1]
17 |
18 | set title "Mixing pm3d surfaces with hidden-line plots"
19 |
20 | f(x,y) = sin(-sqrt((x+5)**2+(y-7)**2)*0.5)
21 |
22 | set hidden3d front
23 | splot f(x,y) with pm3d, x*x-y*y with lines lc rgb "black"
24 |
25 | pause -1 "Hit return to continue"
26 | reset
27 |
28 | #
29 | # Image surfaces are similarly overlooked in the calculation of hidden line removal.
30 | # I.e. this demo doesn't actually work yet. It's here for testing.
31 | #
32 | set isosamples 25,25
33 | set xyplane at 0
34 | unset key
35 |
36 | set cbrange [0:255]
37 | set palette cubehelix
38 |
39 | set title "Mixing image surface with hidden-line plots"
40 |
41 | set hidden3d front
42 | splot 'blutux.rgb' binary array=(128,128) flip=y format='%uchar%uchar%uchar' origin=(-10,-10,0) dx=0.156 dy=0.156 using ($1+$2+$3)/3 with image, \
43 | x*x-y*y with lines lc rgb "black"
44 |
45 | pause -1 "Hit return to continue"
46 | reset
47 | #
48 | # Another example of pm3d hidden surface removal,
49 | # this time using pm3d depth-ordering
50 | #
51 | set multiplot title "Interlocking Tori"
52 | set title "PM3D surface\nno depth sorting"
53 |
54 | set parametric
55 | set urange [-pi:pi]
56 | set vrange [-pi:pi]
57 | set isosamples 50,20
58 |
59 | set origin -0.02,0.0
60 | set size 0.55, 0.9
61 |
62 | unset key
63 | unset xtics
64 | unset ytics
65 | unset ztics
66 | set border 0
67 | set view 60, 30, 1.5, 0.9
68 | unset colorbox
69 |
70 | set pm3d scansbackward
71 | splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, \
72 | 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d
73 |
74 | set title "PM3D surface\ndepth sorting"
75 |
76 | set origin 0.40,0.0
77 | set size 0.55, 0.9
78 | set colorbox vertical user origin 0.9, 0.15 size 0.02, 0.50
79 | set format cb "%.1f"
80 |
81 | set pm3d depthorder
82 | splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, \
83 | 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d
84 |
85 | unset multiplot
86 |
87 | pause -1 "Hit return to continue"
88 |
89 | reset
90 |
--------------------------------------------------------------------------------
/gnuplot/demo/imageNaN.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Explore the effect of image data pixels that are
3 | # missing/NaN/Inf/garbage/...
4 | # Test 2D and 3D versions of the generic and
5 | # terminal-optimized image code.
6 | # The four tests should all come out the same.
7 | #
8 |
9 | set title "Treatment of missing/undefined/NaN/Inf data"
10 | unset key
11 | set tic scale 0
12 | set border 3 front
13 |
14 | set cbrange [-2:7]
15 | set cblabel "Score"
16 | set cbtics 0,1,5
17 |
18 | set xrange [-0.5:4.5]
19 | set yrange [-0.5:5.5]
20 |
21 | set datafile missing "?"
22 | set ytics ("-Inf" 5, "Inf" 4, "NaN" 3, "Junk" 2, "?" 1, "0" 0)
23 | unset xtics
24 |
25 | # Define the test data as a named data block
26 | $matrixdata << EOD
27 | 0 5 4 3 0
28 | ? 2 2 0 1
29 | Junk 1 2 3 5
30 | NaN 0 0 3 0
31 | Inf 3 2 0 3
32 | -Inf 0 1 2 3
33 | EOD
34 |
35 | set xlabel "First column contains various odd values"
36 |
37 | set view map
38 | plot $matrixdata matrix with image
39 |
40 | pause -1 "Hit return to continue"
41 | #
42 | #
43 | set title "Same thing in 'pixels' mode (2D)"
44 |
45 | plot $matrixdata matrix with image pixels
46 |
47 | pause -1 "Hit return to continue"
48 |
49 | set title "Same thing passing data value through 'using 1:2:($3)'"
50 |
51 | plot $matrixdata matrix using 1:2:($3) with image pixels
52 |
53 | pause -1 "Hit return to continue"
54 |
55 | set title "Same thing in 3D mode"
56 |
57 | splot $matrixdata matrix with image
58 |
59 | pause -1 "Hit return to continue"
60 |
61 | set title "Same thing in 'pixels' mode (3D)"
62 |
63 | splot $matrixdata matrix with image pixels
64 |
65 | pause -1 "Hit return to continue"
66 |
67 | set title "3D image with pixel value in 4th column"
68 |
69 | splot $matrixdata matrix using 1:2:(0):3 with image
70 |
71 | pause -1 "Hit return to continue"
72 |
73 | reset
74 |
75 | $DATA << EOD
76 | 0 0 0
77 | 0 1 -1
78 | 0 2 -4
79 | 0 3 -9
80 |
81 | 1 0 1
82 | 1 1 0
83 | 1 2 -3
84 | 1 3 -8
85 |
86 | 2 0 4
87 | 2 1 3
88 | 2 2 0
89 | 2 3 -5
90 |
91 | 3 0 9
92 | 3 1 8
93 | 3 2 NaN
94 | 3 3 9
95 |
96 | EOD
97 |
98 | unset xtics
99 | unset ytics
100 | unset key
101 |
102 | set title "image from non-matrix data"
103 | set label 1 at 3,2 "NaN\nshould appear as\nbackground" front center
104 | plot $DATA with image
105 | pause -1 "Hit return to continue"
106 |
107 | set title "negative values mapped to log-scale colorbar"
108 | set label 2 at 0,2.5 "Negative values become NaN\nwith a log-scale color mapping"
109 | set cbrange [0.1:10]
110 | set log cb
111 | plot $DATA with image, $DATA using 1:2:(sprintf("%g",$3)) with labels tc rgb "green"
112 |
113 | pause -1 "Hit return to continue"
114 |
115 | reset
116 |
--------------------------------------------------------------------------------
/sweepMethod.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Иван Ильин on 08.10.2020.
3 | //
4 |
5 | #include
6 | #include
7 | #include "gnuplot.h"
8 | #include "vemath.h"
9 |
10 | using namespace std;
11 | using namespace vemath;
12 |
13 | int main() {
14 |
15 | // MOTION OF PLANETS
16 | ComplexPlot y_A;
17 | ComplexPlot y_SW;
18 | ComplexPlot y_SW_err;
19 |
20 | // range of integration
21 | double x_0 = 0;
22 | double x_N = PI;
23 | // initial conditions
24 | double y_0 = 1.0f;
25 | double y_N = 0.5f;
26 | // integration step
27 | double h = 0.001;
28 |
29 | // the number of steps (calculated automatically)
30 | int N = (x_N - x_0) / h;
31 |
32 | vector> matrix;
33 | vector d(N);
34 | vector y(N);
35 | // Ay = d, here we fullfit the A matrix and d vector
36 | for(int i = 0; i < N; i++) {
37 | matrix.push_back({});
38 | for(int j = 0; j < N; j++) {
39 | if(j == i-1) {
40 | matrix[i].push_back(1.0f);
41 | } else if(j == i) {
42 | matrix[i].push_back(-2.0f);
43 | } else if(j == i + 1) {
44 | matrix[i].push_back(1.0f);
45 | } else {
46 | matrix[i].push_back(0.0f);
47 | }
48 | }
49 | d[i] = (h*h*sin(h*i));
50 | }
51 |
52 | // taking into account the initial conditions in A matrix
53 | matrix[0][0] = 1;
54 | matrix[0][1] = 0;
55 |
56 | matrix[N-1][N-1] = 1;
57 | matrix[N-1][N-2] = 0;
58 | // taking into account the initial conditions in d vector
59 | d[0] = y_0;
60 | d[N-1] = y_N;
61 | // back propagation
62 | for(int i = 1; i < N; i++) {
63 | double ksi = matrix[i][i-1] / matrix[i-1][i-1];
64 | matrix[i][i-1] = 0;
65 | matrix[i][i] -= ksi * matrix[i-1][i];
66 | d[i] -= ksi * d[i-1];
67 | }
68 |
69 | y[N-1] = d[N-1] / matrix[N-1][N-1];
70 | for(int i = N-2; i >= 0; i--)
71 | y[i] = (d[i] - matrix[i][i+1] * y[i+1]) / matrix[i][i];
72 | // save y in .dat file
73 | for(int i = 0; i < N; i++)
74 | y_SW.push(h*i, y[i]);
75 |
76 | saveVectorPoint2DToFile(y_SW.real(), "y_SW.dat");
77 |
78 | // analytical solution
79 | for(int i = 0; i < N; i++) {
80 | y_A.push(h*i, -sin(h*i) + h*i*(y_N - y_0)/PI + y_0);
81 | y_SW_err.push(h*i, abs(y_SW.v_c[i].second - y_A.v_c[i].second));
82 | }
83 | saveVectorPoint2DToFile(y_A.real(), "y_A.dat");
84 | saveVectorPoint2DToFile(y_SW_err.real(), "y_SW_err.dat");
85 |
86 | GnuplotPipe gp;
87 | gp.sendLine(R"(plot "y_SW.dat" with lines, "y_A.dat" with lines)");
88 | //gp.sendLine(R"(plot "y_SW_err.dat" with lines)");
89 | }
90 |
--------------------------------------------------------------------------------
/gnuplot/demo/solar_params.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Calculate solar position in equatorial coordinates (ascension, declination)
3 | # then convert to horizontal coordinates (altitude, azimuth).
4 | # Parameters L, g, lambda, and eps are appoximated using values chosen
5 | # for accuracy in the era on either side of Jan 2000.
6 | #
7 | # Input:
8 | # Date - string with format "dd-mm-YYYY HH:MM"
9 | # Latitude - in degrees
10 | # Longitude - in degrees
11 | #
12 | # Output:
13 | # Function definitions
14 | # Azimuth(t) = Solar azimuth at time t
15 | # Altitude(t) = Solar altitude at time t
16 | # where t is time in seconds relative to local solar noon on Date.
17 | # sunrise, sunset (string containing local standard time)
18 | # sunlight (string containing time between sunrise, sunset)
19 | #
20 | # Local values:
21 | Minute = 60.
22 | Hour = 3600.
23 | Day = 86400.
24 | TimeFormat = "%d-%m-%Y %H:%M"
25 | Phi = Latitude
26 | set angle degrees
27 | #
28 | # n = local time in days since noon on 1 Jan 2000
29 | # L = mean solar longitude in ecliptic coordinates
30 | # = 280.460° + 0.9856474° * n
31 | # g = orbital anomaly
32 | # = 357.528° + 0.9856003° * n
33 | # lamba = solar longitude
34 | # = L + 1.915° * sin(g) + 0.020° * sin(2g)
35 | # eps = obliquity of the ecliptic
36 | # = 23.439° - 0.0000004° * n
37 |
38 | n = (strptime(TimeFormat, Date) - strptime(TimeFormat, "01-01-2000 12:00")) / Day
39 |
40 | L = n * 0.9856474 + 280.460
41 | L = L - 360 * int(L / 360.)
42 | if (L < 0) { L += 360. }
43 |
44 | g = n * 0.9856003 + 357.528
45 | g = g - 360 * int(g / 360.)
46 | if (g < 0) { g += 360. }
47 |
48 | lambda = L + 1.915 * sin(g) + 0.020 * sin(2*g)
49 |
50 | eps = 23.439 - n * 0.0000004
51 |
52 | # Equatorial coordinates
53 | # RAsc = right ascension
54 | # Dec = declination
55 |
56 | RAsc = atan2( cos(eps) * sin(lambda), cos(lambda) )
57 | Dec = asin( sin(eps) * sin(lambda) )
58 |
59 | # Length of day
60 | daylength = 2.0 * acos( -sin(Dec)*sin(Phi) / cos(Phi) )
61 | # Correction for displacement of this location from center of timezone
62 | corr = Longitude - floor(Longitude/15.0) * 15.0 - 7.5
63 | rise = (daylength/2.0 - corr) * Day/360.
64 | set = (daylength/2.0 + corr) * Day/360.
65 |
66 | sunlight = strftime("%tH h %tM m", daylength * Day/360.)
67 | sunrise = strftime("%tH:%tM", (Day/2)-rise)
68 | sunset = strftime("%tH:%tM", (Day/2)+set)
69 |
70 | # Horizontal coordinates
71 |
72 | h(t) = 360. * t / Day
73 | Altitude(t) = asin( sin(Dec) * sin(Phi) + cos(Dec) * cos(Phi) * cos(h(t)) )
74 |
75 | cosAzi(t) = ( sin(Dec) * sin(Phi) - cos(Dec) * cos(h(t)) * sin(Phi) ) \
76 | / cos(Altitude(t))
77 | sinAzi(t) = ( -cos(Dec) * sin(h(t)) ) \
78 | / cos(Altitude(t))
79 | Azimuth(t) = atan2( sinAzi(t), cosAzi(t) )
80 |
81 |
--------------------------------------------------------------------------------
/gnuplot/demo/vector.dem:
--------------------------------------------------------------------------------
1 | # This file demonstrates
2 | # -1- saving contour lines as a gnuplottable datablock
3 | # -2- plotting a vector field on the same graph
4 | # -3- manipulating columns using the '$1,$2' syntax.
5 | # the example is taken here from Physics is the display of equipotential
6 | # lines and electrostatic field for a dipole (+q,-q)
7 |
8 | print "\n This file demonstrates"
9 | print " -1- saving contour lines as a gnuplottable datablock"
10 | print " -2- plotting a vector field on the same graph"
11 | print " -3- manipulating columns using the '$1,$2' syntax."
12 | print " the example is taken here from Physics is the display of equipotential"
13 | print " lines and electrostatic field for a dipole (+q,-q)"
14 | #
15 | r(x,y)=sqrt(x*x+y*y)
16 | v1(x,y)= q1/(r((x-x0),y))
17 | v2(x,y)= q2/(r((x+x0),y))
18 | #
19 | vtot(x,y)=v1(x,y)+v2(x,y)
20 | #
21 | e1x(x,y)= q1*(x-x0)/r(x-x0,y)**3
22 | e1y(x,y)= q1*(y)/r(x-x0,y)**3
23 | e2x(x,y)= q2*(x+x0)/r(x+x0,y)**3
24 | e2y(x,y)= q2*(y)/r(x+x0,y)**3
25 | etotx(x,y)=e1x(x,y)+e2x(x,y)
26 | etoty(x,y)=e1y(x,y)+e2y(x,y)
27 | enorm(x,y)=sqrt(etotx(x,y)*etotx(x,y)+etoty(x,y)*etoty(x,y))
28 | dx1(x,y)=coef*etotx(x,y)/enorm(x,y)
29 | dy1(x,y)=coef*etoty(x,y)/enorm(x,y)
30 | dx2(x,y)=coef*etotx(x,y)
31 | dy2(x,y)=coef*etoty(x,y)
32 | #
33 | coef=.7
34 | x0=1.
35 | q1=1
36 | q2=-1
37 | xmin=-10.
38 | xmax=10.
39 | ymin=-10.
40 | ymax=10.
41 | #
42 | reset
43 | unset autoscale
44 | set xr [xmin:xmax]
45 | set yr [ymin:ymax]
46 | set isosam 31,31
47 | #set view 0, 0, 1, 1
48 | set view map
49 | unset surface
50 | set contour base
51 | set cntrparam order 4
52 | set cntrparam linear
53 | set cntrparam levels discrete -3,-2 ,-1 ,-0.5 ,-0.2 ,-0.1 ,-0.05 ,-0.02 ,0 ,0.02 ,0.05 ,0.1 ,0.2 ,0.5 ,1 ,2 ,3
54 | set cntrparam points 5
55 | #
56 | set label "-q" at -1,0 center
57 | set label "+q" at 1,0 center
58 | splot vtot(x,y) w l
59 | print "Now create a in-memory datablock with equipotential lines"
60 | pause -1 "Hit return to continue"
61 |
62 | set table $equipo2
63 | replot
64 | unset table
65 | reset
66 | pause 0
67 |
68 | plot $equipo2 w l
69 | print "Now create a x/y datablock for plotting with vectors "
70 | print "and display vectors parallel to the electrostatic field"
71 | pause -1 "Hit return to continue"
72 | set isosam 31,31
73 |
74 | set table $field2xy
75 | splot vtot(x,y) w l
76 | unset table
77 | pause 0
78 |
79 | unset autoscale
80 | set xr [xmin:xmax]
81 | set yr [ymin:ymax]
82 | set isosam 31,31
83 | set key under Left reverse
84 | plot $field2xy u 1:2:(coef*dx1($1,$2)):(coef*dy1($1,$2)) w vec, \
85 | $equipo2 w l
86 | pause -1 "Hit return to continue"
87 |
88 | reset
89 |
90 |
--------------------------------------------------------------------------------
/gnuplot/demo/array.dem:
--------------------------------------------------------------------------------
1 | #
2 | # Use an array to hold the sum of values in each columnn
3 | #
4 | array Sum[20]
5 | do for [i=5:13] {
6 | stats 'immigration.dat' skip 2 using (column(i)) nooutput
7 | Sum[i] = STATS_sum
8 | print sprintf("Sum[%2d] = %d",i,Sum[i])
9 | }
10 | #
11 | # Use the stored sum to normalize values in each column
12 | #
13 | set style fill transparent solid 0.2 border -1
14 | set style data filledcurve y=0
15 | set tics scale 0
16 | set xrange [] noextend
17 | set xlabel "Decade"
18 | set title "Use of an array to aid normalization and to plot summed values"
19 |
20 | set multiplot
21 | plot for [i=5:13] 'immigration.dat' using 1:(column(i)/Sum[i]) title columnhead
22 |
23 | #
24 | # Plot the array values themselves in a separate inset
25 | #
26 |
27 | set size 0.4, 0.3
28 | set origin 0.05, 0.6
29 |
30 | unset xtics
31 | unset ytics
32 | set border 0
33 | set xlabel "Total"
34 | set xrange [4:15]
35 | set yrange [0:*]
36 | unset title
37 | set boxwidth 1.0 absolute
38 |
39 | plot Sum using 1:2:($1-4) with boxes lc variable notitle
40 |
41 | unset multiplot
42 |
43 | pause -1 " to continue"
44 | reset
45 |
46 | set title "Fit function to values stored in an array"
47 | set xtics nomirror
48 |
49 | array A[100]
50 | do for [i=1:100] { A[i] = sin(2*pi*i/100.) + 0.1*rand(0) }
51 | a = b = c = 0.01
52 | set key title "before fit"
53 | plot A with points title "Array A", c+cos(a+b*x) with lines
54 |
55 | pause -1 " to fit function to array values"
56 |
57 | set fit nolog
58 | fit c+cos(a+b*x) A using 1:2 via a,b,c
59 |
60 | set key title "after fit"
61 | plot A with points title "Array A", c+cos(a+b*x) with lines
62 |
63 | pause -1 " to continue"
64 | reset
65 |
66 | #
67 | # Illustrate loading an array from a data file
68 | # This could be done using a preliminary 'plot' command, perhaps together
69 | # with 'set table' if you don't actually want generate a plot, but here
70 | # we use 'stats'. The first run is just to pick up the array size needed.
71 | # The second run stores one value into each array element.
72 | #
73 | set title "Illustrate loading an array from a column in a data file\n".\
74 | "Note that first data point in the file is 'line 0'\n".\
75 | "but it goes into array element Data[1]"
76 |
77 | set yrange [0:20]
78 | set border 3
79 | set tics nomirror
80 | set key left center nobox
81 |
82 | FILE = 'orbital_elements.dat'
83 |
84 | stats FILE index 2 using 2 prefix "A"
85 | array Data[A_records]
86 |
87 | stats FILE index 2 using (Data[int($0+1)] = $2) prefix "B"
88 |
89 | plot FILE index 2 using 2 title "Data from file" with lines lw 2, \
90 | Data using 0:2:(sprintf("Data[%d]",$1)) with labels point pt 6 ps 2 center offset 0,1 title "Data[i]"
91 |
92 | pause -1 " to continue"
93 | reset
94 |
--------------------------------------------------------------------------------
/gnuplot/demo/rgb_variable.dat:
--------------------------------------------------------------------------------
1 | 0 0 0 0x000000
2 | 255 0 0 0xff0000
3 | 255 255 0 0xffff00
4 | 255 255 255 0xffffff
5 | 0 255 255 0x00ffff
6 | 255 0 255 0xff00ff
7 | 0 255 0 0x00ff00
8 | 0 0 255 0x0000ff
9 | 56 34 136 0x382288
10 | 210 19 250 0xd213fa
11 | 144 131 60 0x90833c
12 | 168 58 172 0xa83aac
13 | 62 228 194 0x3ee4c2
14 | 226 198 176 0xe2c6b0
15 | 199 26 61 0xc71a3d
16 | 195 67 71 0xc34347
17 | 176 72 149 0xb04895
18 | 1 236 174 0x01ecae
19 | 239 105 220 0xef69dc
20 | 117 32 153 0x752099
21 | 56 129 84 0x388154
22 | 199 150 233 0xc796e9
23 | 152 219 89 0x98db59
24 | 134 93 151 0x865d97
25 | 19 124 131 0x137c83
26 | 242 126 61 0xf27e3d
27 | 127 236 178 0x7fecb2
28 | 108 232 116 0x6ce874
29 | 61 197 61 0x3dc53d
30 | 126 184 65 0x7eb841
31 | 154 147 192 0x9a93c0
32 | 214 70 48 0xd64630
33 | 190 191 110 0xbebf6e
34 | 86 154 187 0x569abb
35 | 167 246 146 0xa7f692
36 | 208 229 46 0xd0e52e
37 | 31 222 37 0x1fde25
38 | 1 145 248 0x0191f8
39 | 26 38 174 0x1a26ae
40 | 187 140 16 0xbb8c10
41 | 250 227 2 0xfae302
42 | 172 97 104 0xac6168
43 | 217 94 113 0xd95e71
44 | 125 54 250 0x7d36fa
45 | 192 134 174 0xc086ae
46 | 22 56 102 0x163866
47 | 151 84 21 0x975415
48 | 94 81 77 0x5e514d
49 | 8 227 30 0x08e31e
50 | 230 239 244 0xe6eff4
51 | 16 154 93 0x109a5d
52 | 137 80 70 0x895046
53 | 159 128 122 0x9f807a
54 | 200 250 199 0xc8fac7
55 | 15 41 113 0x0f2971
56 | 210 128 24 0xd28018
57 | 126 242 73 0x7ef249
58 | 150 139 223 0x968bdf
59 | 74 119 237 0x4a77ed
60 | 179 74 252 0xb34afc
61 | 234 9 140 0xea098c
62 | 119 56 99 0x773863
63 | 239 124 104 0xef7c68
64 | 249 85 88 0xf95558
65 | 211 234 72 0xd3ea48
66 | 146 223 190 0x92dfbe
67 | 135 203 65 0x87cb41
68 | 174 46 237 0xae2eed
69 | 89 109 52 0x596d34
70 | 30 180 49 0x1eb431
71 | 217 127 61 0xd97f3d
72 | 128 180 165 0x80b4a5
73 | 250 175 216 0xfaafd8
74 | 234 153 219 0xea99db
75 | 122 135 163 0x7a87a3
76 | 66 171 180 0x42abb4
77 | 142 131 94 0x8e835e
78 | 54 81 213 0x3651d5
79 | 14 168 249 0x0ea8f9
80 | 148 155 169 0x949ba9
81 | 94 197 205 0x5ec5cd
82 | 133 74 178 0x854ab2
83 | 253 226 172 0xfde2ac
84 | 74 54 131 0x4a3683
85 | 131 198 59 0x83c63b
86 | 103 183 35 0x67b723
87 | 144 157 175 0x909daf
88 | 26 143 165 0x1a8fa5
89 | 67 213 44 0x43d52c
90 | 105 251 26 0x69fb1a
91 | 44 224 121 0x2ce079
92 | 95 190 168 0x5fbea8
93 | 154 93 246 0x9a5df6
94 | 0 108 32 0x006c20
95 | 91 205 67 0x5bcd43
96 | 47 205 112 0x2fcd70
97 | 228 173 117 0xe4ad75
98 | 54 53 144 0x363590
99 | 146 243 190 0x92f3be
100 | 42 196 100 0x2ac464
101 | 49 129 49 0x318131
102 | 195 70 53 0xc34635
103 | 29 67 226 0x1d43e2
104 | 133 201 242 0x85c9f2
105 | 41 157 150 0x299d96
106 |
--------------------------------------------------------------------------------