PLplot to wieloplatformowy pakiet oprogramowania do tworzenia wykresów naukowych, których symbole wykresu (UTF-8) i tekst są w praktyce ograniczone jedynie tym, jakie czcionki systemowe obsługujące Unicode są zainstalowane na komputerze użytkownika. Biblioteki podstawowej PLplot można używać do tworzenia standardowych wykresów x-y, wykresów półlogarytmicznych, wykresów log-logarytmicznych, wykresów konturowych, wykresów powierzchni 3D, wykresów siatkowych, wykresów słupkowych i kołowych. Na jednej stronie można umieścić wiele wykresów (tego samego lub różnych rozmiarów), a w przypadku urządzeń, które je obsługują, dozwolonych jest wiele stron. Obsługiwane systemy operacyjne: Linux, MacOS, Windows

instalacja Lista pakietów Ubuntu:packages.ubuntu search: plplot libplplot-dev plplot-doc plplot-examples libplplot-data

sudo apt-get -y install libplplot-dev

git clone git://git.code.sf.net/p/plplot/plplot plplot.git

Przykłady:

sudo apt-get -y install plplot-examples

Szukamy lokalizacji:

sudo updatedb locate plplot

Przykładowy wynik:

/usr/share/doc/plplot-examples/examples/c

sudo apt-get -y install plplot-doc

kompilacja Makefile + pkg-config CMake linka poleceń: -lplplot -I /usr/include/plplot

sterowniki Sterowniki plików ( ang. file devices) nieinteraktywne qt cairo svg ps driver psttf driver pdf gd driver pstex driver

Sterowniki urządzeń interaktywnych qt cairo xwin driver tk driver aqt driver wxwidgets driver wxWidgets Driver Basics

przykłady /usr/share/doc/plplot-examples/ sourceforge examples

2D line plot

// Simple demo of a 2D line plot. // // Copyright (C) 2011 Alan W. Irwin // // This file is part of PLplot. // // PLplot is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published // by the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // PLplot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with PLplot; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // //

#include "plcdemos.h" #define NSIZE 101

int main( int argc, char *argv[] ) { PLFLT x[NSIZE], y[NSIZE]; PLFLT xmin = 0., xmax = 1., ymin = 0., ymax = 100.; int i;

// Prepare data to be plotted. for ( i = 0; i < NSIZE; i++ )

x[i] = (PLFLT) ( i ) / (PLFLT) ( NSIZE - 1 ); y[i] = ymax * x[i] * x[i];

// Parse and process command line arguments plparseopts( &argc, argv, PL_PARSE_FULL );

// Initialize plplot plinit();

// Create a labelled box to hold the plot. plenv( xmin, xmax, ymin, ymax, 0, 0 ); pllab( "x", "y=100 x#u2#d", "Simple PLplot demo of a 2D line plot" );

// Plot the data that was prepared above. plline( NSIZE, x, y );

// Close PLplot library plend();

exit( 0 ); }

ODE

Rozwiązanie ODE z użyciem biblioteki GNU GSL i grafika za pomocą biblioteki PLplot

/*

gcc o.c -Wall -Wextra -lm -lplplot -lgsl -lgslcblas

*/

#include #include #include #include #include #include #include #include #include #include

int ode_func(double t, const double y[], double f[], void *params) { double k = *((double*)params); (void)t; f = y; f = k * y * (1.0 - y * y) - y; return GSL_SUCCESS; }

/* Some methods ask for you to give the Jacobian of it too * for better performance. You have to calculate this by hand. */ int ode_jac(double t, const double y[], double *dfdy, double dfdt[], void *params) { double k = *((double*)params); (void)t; gsl_matrix_view dfdy_mat = gsl_matrix_view_array(dfdy, 2, 2); gsl_matrix *m = &dfdy_mat.matrix; gsl_matrix_set(m, 0, 0, 0.0); gsl_matrix_set(m, 0, 1, 1.0); gsl_matrix_set(m, 1, 0, -(1.0 + 2.0 * k * y * y)); gsl_matrix_set(m, 1, 1, k * (1.0 * y * y)); /* Autonomous. */ dfdt = 0.0; dfdt = 0.0; return GSL_SUCCESS; }

int main(int argc, char **argv) { enum Constexpr {n_points = 1000}; double mu = 1.0; gsl_odeiv2_system sys = {ode_func, ode_jac, 2, &mu}; gsl_odeiv2_driver * d= gsl_odeiv2_driver_alloc_y_new( &sys, gsl_odeiv2_step_rk8pd, 1e-6, 1e-6, 0.0 ); int i; double t = 0.0; double t1 = 100.0; /* Initial condition: f = 0 with speed 0. */ double y = {1.0, 0.0}; double dt = t1 / n_points; double datax[n_points]; double datay[n_points];

for (i = 0; i < n_points; i++) { double ti = i * dt; int status = gsl_odeiv2_driver_apply(d, &t, ti, y); if (status != GSL_SUCCESS) { fprintf(stderr, "error, return value=%d\n", status); break;

/* Get output. */ printf("%.5e %.5e %.5e\n", t, y, y); datax[i] = y; datay[i] = y;

/* Cleanup. */ gsl_odeiv2_driver_free(d);

/* Plot. */ if (argc > 1 && argv == '1') { plsdev("xwin"); plinit(); plenv( gsl_stats_min(datax, 1, n_points), gsl_stats_max(datax, 1, n_points), gsl_stats_min(datay, 1, n_points), gsl_stats_max(datay, 1, n_points), 0, 1 ); plstring(n_points, datax, datay, "*"); plend();

return EXIT_SUCCESS; }

Linki plplot sourceforge github PLplotNet plplot for .NET