Wprowadzenie do programu gnuplot Bogdan Kreczmer CiR PWR pokój budynek C bogdan.kreczmer@pwr.edu.pl Copyright c Bogdan Kreczmer Niniejszy dokument zawiera materiały do wykładu na temat wizualizacji danych sensorycznych. Jest on udostępiony pod warunkiem wykorzystania wyłacznie do własnych prywatnych potrzeb i może on być kopiowany wyłacznie w całości, razem z ninijesza strona tytułowa. Skład FoilTEX
gnuplot Główni autorzy: Thomas Williams, Colin Kelley http://www.gnuplot.info/ ftp://ftp.gnuplot.info/pub/gnuplot/ gnuplot jest programem przeznaczonym do: tworzenia rysunków wykresów funkcji jedno i dwuargumentowych (funkcje moga być parametryzowane), obrazowania danych pomiarowych, tworzenia wykresów interpolujacych przebiegi funkcji na podstawie zbioru danych pomiarowych. Przy interpolacji brane sa pod uwagę błędy zwiazane z zadanymi wartościami. Jest to program zorientowany na polecenia tekstowe w pracy interaktywnej lub wsadowej. gnuplot
Tryby pracy Tryb interaktywny SunOS > gnuplot gnuplot>_... gnuplot>exit SunOS >_ Możliwe sposoby pracy z programem gnuplot: Tryb potokowy SunOS > generator_polecen gnuplot Tryb wsadowy SunOS > gnuplot plik_komend.asci gnuplot
Podpowiedzi - help gnuplot> help gnuplot is a command-driven interactive function and data plotting program. It is case sensitive (commands and function names written in lowercase are not the same as those written in CAPS). All command names may be abbreviated as long as the abbreviation is not ambiguous. Any number of commands may... Help topics available: batch/interactive bugs commands comments coordinates copyright environment expressions glossary graphical introduction line-editing new-features old_bugs plotting seeking-assistance set show startup substitution syntax time/date Help topic: _ gnuplot
Najprostszy wykres Praca interakcyjna: gnuplot>plot.... Przetwarzanie wsadowe: SunOS >gnuplot sin.cmd -. -. Plik sin.cmd : Rysowanie plot Zatrzymanie aż do naciśnięcia klawisza ENTER pause - -. -. - - - Rysunek : Wykres funkcji sinus. gnuplot
Najprostszy wykres plot with lines.. plot w l.. -. -. -. Składnia sekcji with dla polecenia plot: -. - - - with <style> { {linestyle ls <line_style>} {{linetype lt <line_type>} {linewidth lw <line_width>} {pointtype pt <point_type>} {pointsize ps <point_size>}} } <style> = lines points linespoints impulses dots steps fsteps histeps errorbars xerrorbars yerrorbars xyerrorbars boxes xyerrorbars boxes boxerrorbars boxxyerrorbars financebars candlesticks candlesticks vector gnuplot
Polecenie test rotated ce+ntred text gnuplot>show terminal terminal type is x Terminal Test left justified centre+d text right justified test tics Rysunek : Test terminala. - gnuplot>test gnuplot
Przykłady stylów rysowania............ -. -. -. -. -. -. -. -. -. -. -. -. - - - - - - - - - plot with l lt plot with l lt lw plot with l lt lw............ -. -. -. -. -. -. -. -. -. -. -. -. - - - - - - - - - plot with points plot with points pt ps plot with p lt pt ps............ -. -. -. -. -. -. -. -. -. -. -. -. - - - - - - - - - plot with linespoints lt... w linesp lt lw pt ps... w linesp lt lw pt ps gnuplot
Przykłady stylów rysowania............ -. -. -. -. -. -. -. -. -. -. -. -. - - - - - - - - - plot with impulses plot with i lt lw plot with i lt lw............ -. -. -. -. -. -. -. -. -. -. -. -. - - - - - - - - - plot with steps plot w fsteps lt lw plot w histeps lt lw............ -. -. -. -. -. -. -. -. -. -. -. -. - - - - - - - - - plot with boxes... w candlesticks... w candlesticks lt lw gnuplot
Oś zera Polecenia: gnuplot> set yzeroaxis gnuplot> set xzeroaxis lt lw gnuplot> plot.... -. -. -. -. - - - Rysunek : Wykres funkcji sinus. gnuplot
Z radianów na stopnie Polecenia: gnuplot> set angles degrees gnuplot> plot [:].... -. -. -. -. - Rysunek : Wykres funkcji sinus. gnuplot
Funkcje parametryczne set parametric plot sin(t),cos(t) sin(t), cos(t).... -. -. -. -. - - -. -. -. -..... Rysunek : Wykres funkcji parametrycznej. gnuplot
Wzajemna proporcjonalność osi gnuplot>... gnuplot> set size ratio gnuplot> set parametric gnuplot> plot sin(t),cos(t) noratio ratio: ratio:. sin(t), cos(t) sin(t), cos(t) sin(t), cos(t)...... -. -. -. - - - -. -. -. - -. - -... - - -. - -... - -. - -... set size {{no}square ratio <r> noratio} {<xscale>,<yscale>} gnuplot
Dane z pliku gnuplot>plot dane.asc "dane.asc" Plik dane.asc : Przyklad danych liczbowych x y.. Rysunek : Wykres zadany poprzez zbior punktów. gnuplot
Wczytywanie z wejścia standardowego gnuplot> plot "< awk /^ *[^]/ { print $, $} dane.asc" with lines Plik dane.asc : Przyklad danych liczbowych x y Dy..... "< awk / *[ ]/ print $, $ dane.asc" gnuplot
Kolejność współrzędnych - using gnuplot> plot dane.asc using : with lines dane.asc using : Plik dane.asc : Przyklad danych liczbowych y x.. Rysunek : Wykres zadany poprzez zbior punktów z jawnym wskazaniem współrzędnej x i y. gnuplot
gnuplot> plot "dane.asc" with errorbars Rysowanie wielkości błędu - errorbars "dane.asc" Plik dane.asc : Przyklad danych liczbowych x y Dy.......... Rysunek : Wykres zadany poprzez zbior punktów. gnuplot
Dane razem z poleceniami plot - with lines, - notitle with errorbars x y Dy.......... e e.......... - gnuplot
Rysowanie wielkości błędu - errorbars gnuplot> plot "dane.asc" with lines, "dane.asc" with errorbars "dane.asc" "dane.asc" Plik dane.asc : Przyklad danych liczbowych x y Dy.......... Rysunek : Wykres zadany poprzez zbior punktów. gnuplot
Rysowanie wielkości błędu - xyerrorbars gnuplot> plot "dane.asc" with xyerrorbars "dane.asc" Plik dane.asc : Przyklad danych liczbowych x y Dx Dy.................. Rysunek : Wykres zadany poprzez zbior punktów z informacja o błędach. gnuplot
gnuplot> plot "dane.asc" smooth csplines Rysowanie z wygładzaniem dane.asc Plik dane.asc : Przyklad danych liczbowych x y.. Rysunek : Wykres zadany poprzez zbior punktów. Rysunek z wygładzaniem. gnuplot
Rysowanie z wygładzaniem gnuplot> plot dane.asc smooth csplines w l lw,\ dane.asc smooth bezier w l lt lw, "dane.asc" w linesp lt ps dane.asc dane.asc "dane.asc" Plik dane.asc : Przyklad danych liczbowych x y.. Rysunek : Wykresy zadane tym samym zbiorem punktów. gnuplot
Wygładzanie parametryzowane gnuplot>plot dane.asc using ::() smooth acsplines title "Współczynnik ",\ dane.asc using ::() smooth acsplines title "Współczynnik ",\ dane.asc notitle with errorbars Wspolczynnik Wspolczynnik Plik dane.asc : Przyklad danych liczbowych x y Dy.......... Rysunek : Wygładzanie parametryzowane. gnuplot
Wygładzanie parametryzowane gnuplot>plot... \ dane.asc using ::(/($*$)) smooth acsplines\ title "Wspolczynnik wyliczany" with lines lw Plik dane.asc : Przyklad danych liczbowych x y Dy.......... Wspolczynnik Wspolczynnik Wspolczynnik wyliczany Rysunek : Wygładzanie parametryzowane wartościami z trzeciej kolumny. gnuplot
Zakres - range gnuplot> plot [:] [:] dane.asc with lines dane.asc Drugi sposób: set xrange [:] set yrange [:] plot dane.asc w lines Rysunek : Wykres zadany poprzez zbior punktów z własnym ustawieniem zakresu zmian współrzędnych. gnuplot
Nazwa wykresu - title gnuplot> plot [:] [:] dane.asc title "Przykladowe dane" with lines\ dane.asc smooth bezier notitle w lines Przykladowe dane Rysunek : Wykres zadany poprzez zbior punktów z własnym ustawieniem zakresu zmian współrzędnych. gnuplot
Definiowanie własnych funkcji gnuplot> ogrd(x,d)=x-d gnuplot> ogrg(x,d)=x+d gnuplot> wspol(x,s)=s/(x*x) gnuplot> plot dane.asc using :(ogrg($,$)) title "Ograniczenie gorne" with lines,\ dane.asc using :(ogrd($,$)) title "Ograniczenie dolne" with lines,\ dane.asc notitle with errorbars,\ dane.asc using ::(wspol($,)) smooth acsplines\ title "Wspolczynnik wyliczany" with lines lw Plik dane.asc : Przyklad danych liczbowych x y Dy......... Ograniczenie gorne Ograniczenie dolne Wspolczynnik wyliczany gnuplot
Parametryzacja wykresu gnuplot>... gnuplot> moje_x(x,y)=.*($)*sin($*./) gnuplot> moje_y(x,y)=.*($)*cos($*./) gnuplot> wspol(x,s)=s/(x*x) gnuplot> set parametric gnuplot> plot dane.asc using (moje_x($,$)):(moje_y($,$))\ title "Krzywa modulowana" with lines,\ dane.asc using (moje_x($,$)):(moje_y($,$)):(wspol($,))\ smooth acsplines title "Wygladzony",\ sin(t),cos(t) Plik dane.asc : Przyklad danych liczbowych x y Dy....... -. - -. Krzywa modulowana Wygladzony sin(t), cos(t) - -. - -... gnuplot
Biegunowy układ współrzędnych gnuplot>... gnuplot> set grid polar gnuplot> set xtics axis gnuplot> set ytics axis gnuplot> set polar gnuplot> set size ratio gnuplot> plot dane.asc using ($/):($/)\ title "Krzywa modulowana" with lines,\ dane.asc using ($/):($/):(wspol($,))\ smooth acsplines title "Wygladzony",\ sin(t), sin(t)+. Krzywa modulowana Wygladzony sin(t) sin(t)+. Plik dane.asc : Przyklad danych liczbowych x y Dy..... gnuplot
Siatka i podziałka gnuplot> set ytics gnuplot> set mytics gnuplot> set mxtics gnuplot> set grid gnuplot> plot dane.asc with lines set grid set grid xtics set grid xtics ytics mytics dane.asc dane.asc dane.asc set grid {{no}{m}xtics} {{no}{m}ytics} {{no}{m}ztics} {{no}{m}xtics} {{no}{m}ytics} {polar {<angle>}} { {linestyle <major_linestyle>} {linetype lt <major_linetype>}... gnuplot