Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f31ba1a

Browse filesBrowse files
committed
Colormap
1 parent 152e0f0 commit f31ba1a
Copy full SHA for f31ba1a
Expand file treeCollapse file tree

18 files changed

+210
-12
lines changed

‎Makefile

Copy file name to clipboardExpand all lines: Makefile
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ PNG_EXT ?= .png
66

77
GIFS := $(patsubst %$(GIF_EXT)$(IN_EXT),%$(GIF_EXT),$(wildcard *$(IN_EXT)))
88
PNGS := $(patsubst %$(IN_EXT),%$(PNG_EXT),$(wildcard *$(IN_EXT)))
9-
PNGS := $(filter-out main$(PNG_EXT),$(PNGS))
9+
# Remove some special files that should not be rendered.
10+
PNGS := $(filter-out main$(PNG_EXT) template$(PNG_EXT),$(PNGS))
1011

1112
.PHONY: clean
1213

‎README.md

Copy file name to clipboardExpand all lines: README.md
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Minimal explained Gnuplot examples.
1313
1. [Label](label.gnuplot)
1414
1. [key](key.gnuplot)
1515
1. [key title](key-title.gnuplot)
16+
1. [columnheader](columnheader.gnuplot)
1617
1. Axis
1718
1. [Range](range.gnuplot)
1819
1. [offset graph](offset-graph.gnuplot)
@@ -34,6 +35,8 @@ Minimal explained Gnuplot examples.
3435
1. [Inline data](inline-data.gnuplot)
3536
1. [Samples](samples.gnuplot)
3637
1. [object circle](object-circle.gnuplot)
37-
1. [splot](splot.gnuplot)
38+
1. 3D
39+
1. [splot](splot.gnuplot)
40+
1. [pm3d](pm3d)
3841
1. [GIF animation](animation.gif.gnuplot)
3942
1. [Interactive](interactive/)

‎bibliography.md

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Bibliography
2+
3+
- <http://www.gnuplotting.org>

‎columnheader.gnuplot

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env gnuplot
2+
3+
# Take title from file. Skips the line.
4+
5+
plot '-' linewidth 3 title columnheader(1)
6+
Square
7+
1 1
8+
2 4
9+
3 9
10+
e

‎data-multiple.gnuplot

Copy file name to clipboardExpand all lines: data-multiple.gnuplot
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,45 @@
22

33
# Multiple plots from a single file.
44

5+
set multiplot layout 4,1
6+
7+
# Column choice method.
58
plot "square-line.data" using 1:2 title "Square", \
69
"square-line.data" using 3:4 title "Line"
10+
11+
# Double empty line separated data sets.
12+
plot '-' with lines
13+
1 1
14+
2 2
15+
3 3
16+
17+
18+
1 1
19+
2 4
20+
3 9
21+
e
22+
23+
# Select a single data set from multiple data set file.
24+
plot 'multiple.data' index 0 with lines linecolor rgb 'red', \
25+
'multiple.data' index 1 with lines linecolor rgb 'green'
26+
27+
# Choose by data name (from comments).
28+
plot 'multiple.data' index 'Square' with lines linecolor rgb 'red', \
29+
'multiple.data' index 'Line' with lines linecolor rgb 'green'
30+
31+
# TODO: same as above but inline?
32+
# Maybe the problem is that each `-` expects a new file.
33+
# http://stackoverflow.com/questions/10397750/embedding-multiple-datasets-in-a-gnuplot-command-script
34+
#plot '-' index 0 with lines linecolor rgb 'red', \
35+
#'-' index 1 with lines linecolor rgb 'green'
36+
#1 1
37+
#2 2
38+
#3 3
39+
40+
41+
#1 1
42+
#2 4
43+
#3 9
44+
#e
45+
46+
unset multiplot

‎data.gnuplot

Copy file name to clipboardExpand all lines: data.gnuplot
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# - newline separated rows
1111
# - lines starting with # are ignored
1212
# - single empty lines are ignored
13-
# - double empty lines mean a new data set
13+
# - double empty lines mean a new data set. Use `using lines` to observe it.
1414

1515
# C-like integers and floats are understood.
1616

‎inline-data.gnuplot

Copy file name to clipboardExpand all lines: inline-data.gnuplot
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,39 @@
22

33
## Inline data
44

5+
## -
6+
57
# Specify data without a separate file.
68

79
# http://stackoverflow.com/questions/3318228/gnuplotting-data-without-a-textfile
810

11+
# Uses the special filename `-`.
12+
13+
set multiplot layout 2,1
14+
915
set key outside
10-
plot '-' using 1:2
16+
17+
plot '-' lw 3
1118
0 0
1219
1 1
1320
2 4
1421
3 9
1522
4 16
1623
e
24+
25+
# Multiple data syntax looks like Bash EOF.
26+
plot '-' lw 3, '-' lw 3
27+
0 0
28+
1 1
29+
2 4
30+
3 9
31+
4 16
32+
e
33+
0 0
34+
1 1
35+
2 2
36+
3 3
37+
4 4
38+
e
39+
40+
unset multiplot

‎interactive/README.md

Copy file name to clipboardExpand all lines: interactive/README.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ Examples that require user to make input or wait like animations.
55
Put in a separate directory to avoid stalling the build.
66

77
1. [animation](animation.gnuplot)
8+
1. [size](size.gnuplot)
9+
1. [colormap.gif](colormap.gif.gnuplot)

‎interactive/colormap.gif.gnuplot

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env gnuplot
2+
3+
# Artistic colormap rendering.
4+
5+
# Placed here because it takes a long time, and is just artistic,
6+
# not a minimal example.
7+
8+
set key off
9+
set view map
10+
set samples 100
11+
set isosamples 100
12+
set xrange [ -10 : 10 ]
13+
set yrange [ -10 : 10 ]
14+
n = 100
15+
do for [i=1:n] {
16+
splot '++' using 1:2:(sin(($1**2 + $2**2) * 2*pi*i/n)) with pm3d
17+
}

‎interactive/size.gnuplot

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env gnuplot
2+
3+
# Maximize: http://stackoverflow.com/questions/22493766/how-to-make-gnuplot-plot-in-a-maximized-window
4+
5+
set terminal wxt size 1024,768
6+
plot x

‎introduction.md

Copy file name to clipboardExpand all lines: introduction.md
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,37 @@ has short form:
2424

2525
I recommend using the long form when scripting, and the short form for interactive sessions.
2626

27+
## File extension
28+
29+
<http://stackoverflow.com/questions/5497889/is-there-a-standard-file-extension-for-gnuplot-files>
30+
31+
There are a bunch of options.
32+
33+
I prefer `.gnuplot` as it is the clearest, but it has little support.
34+
35+
The shebang helps Vim there.
36+
2737
## Source code
2838

2939
cvs -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot login
3040
cvs -z3 -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot co -P gnuplot
41+
cd gnuplot
42+
cvs update -r Release_5_0_1
43+
# Ubuntu 14.04.
44+
sudo apt-get build-dep gnuplot
45+
sudo apt-get install lua5.2
46+
./prepare
47+
./configure
48+
time make
49+
./src/gnuplot --version
50+
# Install is needed for it to work.
51+
sudo make install
52+
gnuplot --version
53+
54+
When you get tired of it:
55+
56+
sudo make uninstall
3157

3258
Yes, CVS on SourceForge... but remember that this is a project started in 1985 :-)
59+
60+
TODO: how to checkout a given version????

‎key-title.gnuplot

Copy file name to clipboardExpand all lines: key-title.gnuplot
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
set key outside center right
66
plot \
7-
sin(x) title "my sin",\
8-
cos(x) title "my cos"
7+
sin(x) + 0 title "my sin",\
8+
sin(x) + 1 title "my sin + 1",\
9+
sin(x) + 2 notitle

‎key.gnuplot

Copy file name to clipboardExpand all lines: key.gnuplot
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
set multiplot layout 6,1
1010

11+
# Can also be done with `plot notitle` for a single plot.
1112
set key off
1213
plot sin(x) title "off"
1314

‎main.gnuplot

Copy file name to clipboardExpand all lines: main.gnuplot
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
## piecewise
7171

72-
step(x) = x>a ? 1 : 0
72+
step(x) = x > a ? 1 : 0
7373
p f(x)*(x<0.8) + g(x)*(x>=0.8)
7474
# disadvantage: both parts are always evaluated
7575

@@ -83,11 +83,11 @@
8383

8484
pr "as"."df"
8585

86-
if( 1 ){ pr "1" }
87-
if( 0 ){ pr "0" }
86+
if (1) { pr "1" }
87+
if (0) { pr "0" }
8888

89-
do for[i=1:5:2]{ pr i }
90-
do for[i=1:5:2]{ pr i }
89+
do for[i=1:5:2] { pr i }
90+
do for[i=1:5:2] { pr i }
9191

9292
## Not possible in 4.6:
9393

‎multiple.data

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Line
2+
1 1
3+
2 2
4+
3 3
5+
6+
7+
# Squaree
8+
1 1
9+
2 4
10+
3 9

‎palette.gnuplot

Copy file name to clipboard
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env gnuplot
2+
3+
## palette
4+
5+
# Represent an extra dimension with color.
6+
7+
# Variable point size is another option with `pointsize variable`:
8+
# http://gnuplot.sourceforge.net/demo/pointsize.html
9+
10+
set key off
11+
12+
set multiplot layout 3,1
13+
14+
# We could also add a `using 1:2:3` here,
15+
# but that is the default.
16+
# TODO how to make this smooth?
17+
plot '-' with lines palette linewidth 3
18+
19+
0 0 0
20+
1 1 1
21+
2 4 8
22+
3 9 27
23+
4 16 64
24+
e
25+
26+
# This example uses the special filename '+',
27+
# which makes x vary over the range,
28+
# so we can define everything with functions.
29+
plot '+' using 1:(sin($1)):($1**2) with lines palette linewidth 3
30+
31+
# Switch between two colors only:
32+
# http://stackoverflow.com/questions/8717805/how-to-make-points-one-color-when-a-third-column-equals-zero-and-another-color
33+
set palette model RGB defined ( 0 'red', 1 'green' )
34+
plot '+' using 1:(sin($1)):($1 < 0 ? 0 : 1) palette linewidth 3
35+
36+
unset multiplot

‎pm3d.gnuplot

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env gnuplot
2+
3+
## pm3d
4+
5+
## Heat maps
6+
7+
# Palette mapped 3D.
8+
9+
# Represent the third dimension as color, and fill in the entire image.
10+
11+
set view map
12+
set samples 10
13+
set isosamples 10
14+
set xrange [ -10 : 10 ]
15+
set yrange [ -10 : 10 ]
16+
splot '++' using 1:2:($1**2 + $2**2) with pm3d

‎with-line.gnuplot

Copy file name to clipboardExpand all lines: with-line.gnuplot
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
# Add a line to plotted data.
1010

1111
plot \
12-
"square.data" with line,\
12+
"square.data" with lines,\
1313
"line.data" w l,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.