pvbrowser manual
Back Content Forward

external plot tools

Screenshot of gnuplot in pvbrowser
Screenshot of gnuplot in pvbrowser

Here is an example howto use gnuplot in pvserver. Input a Custom Widget "QImage". Use this for the id.

static int showGnuplot(PARAM *p, int id, DATA *d)
  FILE *fout;
  char buf[80];
  if(d == NULL) return 1; // you may use d for writing gnuplot.dem

  // write gnuplot file
  sprintf(buf,"%sgnuplot.dem",p->file_prefix); // p->file_prefix makes filenames unique for multiple clients
  fout = fopen(buf,"w");
  if(fout == NULL) return 1;
  fprintf(fout,"# gnuplot test.dem\n");
  fprintf(fout,"set output \"%sgnuplot.png\"\n",p->file_prefix);
  fprintf(fout,"set terminal png\n");
  fprintf(fout,"set xlabel \"x\"\n");
  fprintf(fout,"set ylabel \"y\"\n");
  fprintf(fout,"set key top\n");
  fprintf(fout,"set border 4095\n");
  fprintf(fout,"set xrange [-15:15]\n");
  fprintf(fout,"set yrange [-15:15]\n");
  fprintf(fout,"set zrange [-0.25:1]\n");
  fprintf(fout,"set samples 25\n");
  fprintf(fout,"set isosamples 20\n");
  fprintf(fout,"set title \"Radial sinc function.\"\n");
  fprintf(fout,"splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)\n");

  // run gnuplot
  sprintf(buf,"gnuplot %sgnuplot.dem",p->file_prefix);

  // send result to pvbrowser

  // temopary files will be cleaned up at browser exit
  return 0;

Back Content Forward