Showing posts with label GNUplot. Show all posts
Showing posts with label GNUplot. Show all posts

Monday, October 8, 2007

Basic Plotting

Plotting set of points (vector)

angles = [o:pi/3:2*pi]
y = sin(angles)
plot(angles, y)


Plot smoother curves (vector)


angles = linspace(0, 2*pi, 100) % 100 points equally spaced btw 0 and 2pi
y = sin(angles)
plot(angles, y)

Basic options
'.' = Set dots plot style
'@' = Set points plot style
'-@' = Set linespoints plot style
'^' = Set impulses plot style
'L' = Set steps plot style
'N' = Interpreted as the plot color if N is an integer in the range 1 to 6
'NM' = if N an integer in the range 1 to 6 -> color
if M an integer in the range 1 to 6 -> point style
This is only valid in combination with the '@' or '-@' specifier
'C' = plot color
'";title;"' = here '"title"' is the label for the key

1 = red / *
2 = greed / +
3 = blue / o
4 = magenta / x
5 = cyan / house
6 = brown / there exists

Example:

plot(x, y, "@12", x, y2, x, y3, "4", x, y4, "+"), This command plot
'y' with color 1 (red) and points of type 2 (+),
'y2' with lines
'y3' with lines of color 4 (magenta)
'y4' with points displayed as '+'

plot(b, '*'), plot the data in the var. b w. points displayed as '*'.

t = 0:0.1:6.3;
plot(t, cos(t), "-;cos(t);", t, sin(t), "+3; sin(t);")



Title and Labels

title('Graph of y = sin(x)')
xlabel('Angle')
ylabel('Value')


Colors and Styles
for symbols and lines in the plot command (see help plot)
(M = only available in Matlab)

w = white
m = magneta
c = cyan
r = red
g = green
b = blue
y = yellow
k = black

. = point
o = circle
x = x-mark
+ = plus
* = star
s = square (M)
d = diamond (M)
v = triangle (down) (M)
^ = triangle (up) (M)
< = triangle (left) (M)
> = triangle (right) (M)
p = pentagram (M)
h = hexagram (M)

- = solid
: = dotted (M)
-. = dashdot (M)
-- = dashed (M)


Extra

grid on % turn on grid
grid off
hold on % keep current plot to add more
hold off
figure (N) % plot graph in window N. If no number is specified, the next number is called. If command not called, graph will be plotted in exactly the same window.

More info:
1) plot is the user-defined function from the file /usr/share/octave/2.9.9/m/plot/plot.m
2) Additional help for built-in functions and operators is
available in the on-line version of the manual. Use the command
`doc ' to search the manual index.
3) See also: semilogx, semilogy, loglog, polar, mesh, contour,
__pltopt__ bar, stairs, errorbar, replot, xlabel, ylabel, title,
print.

Sunday, October 7, 2007

Install gnuplot on Ubuntu

Copied from Miscellaneous Debris

********************************************

Though there is gnuplot available in the Ubuntu/Debian repositories, there are reasons to compile gnuplot - first and most important gnu readline support! I don’t know why Debian maintainers don’t compile the GNU readline support into GNUplot - it’s some license issues - but it’s like that and this makes gnuplot practically unusable. Second having the pdf and wxWidgets terminal is not that bad at all :)

So here are the instructions:

First we compile and install wxWidgets

  • Download wxWidgets GTK 2.8.3
  • Untar it somewhere: tar xzf wxGTK-2.8.3.tar.gz
  • cd cd wxGTK-2.8.3/
  • mkdir buildgtk
  • cd buildgtk
  • ../configure
  • make
  • sudo paco -lp wxGTK-2.8.3 make install (or just make install if you don’t use paco)
  • sudo ldconfig (you may need to add /usr/local/lib to the file /etc/ld.so.conf before)

Than we are going to install the PDFlib lite

  • Download PDFlib Lite
  • tar xzf PDFlib-Lite-7.0.1.tar.gz
  • cd PDFlib-Lite-7.0.1
  • ./configure
  • make
  • sudo paco -lD make install
  • sudo ldconfig

Than we compile gnuplot

  • Download gnuplot 4.2
  • tar xzf gnuplot-4.2.0.tar.gz
  • cd gnuplot-4.2.0
  • ./configure –with-readline=gnu (check if we have the lines “pdf terminal: yes” and “wxt terminal: yes (EXPERIMENTAL)”, if you miss the jpeg, png and gif terminal install the libgd2-xpm-dev package; also check if you find “Readline library: GNU readline library with -lncurses”, if it says only minimal readline support than install the libreadline5-dev package; you need also the libx11-dev and libxt-dev package for the X11 terminal - libxt-dev package is normally not installed by default (at the debian page about gnuplot one can find the packages necessary to build gnuplot))
  • make (if you have problems here with some latex errors than disable the latex tutorial during the configure stage with “–without-tutorial”, if you get a “103: makeinfo: not found” error message than install the texinfo package)
  • sudo paco -lD make install

Than you have gnuplot installed with nice readline support (command line like in bash), a nice new wxWidgets terminal and a pdf terminal.