how to draw 1D plot

44 views
Skip to first unread message

Loylick

unread,
Feb 25, 2017, 7:54:33 AM2/25/17
to deal.II User Group

Hi!

I was looking through the documentation but I could not figure out how to make graphic output of a simiple 1D plot like one I attached to this post.
I had to output my data to a file and draw the graph by hand to show it to you. My data are just two columns: X, Y. When I look at gnuplot file generated by
Dealii I see that it tries to draw my data as 2D plot.
Regards, Alex

    MatrixOut matrix_out;
   
FullMatrix<double> DBvsF;
   
DBvsF.reinit(2, 1000);
    std
::vector<double>   frequency;
   

   
double w;
   
double e = parameters.get_double("dissip");
   
unsigned int l;
   
unsigned int sz = frequency.size()-1;
   
   
for ( l=0; l<1000 ;  l++) {
        step
= sqrt(w);
        w
+=step;
       
double val = log(DbAtFreq(w, &frequency, e));
       
DBvsF(0, l)= w;
       
DBvsF(1, l) = val;
   
}
       

   std
::ofstream out("DBvsFrequency.plt");
   matrix_out
.build_patches(DBvsF, "M");
   matrix_out
.write_gnuplot(out);


Wolfgang Bangerth

unread,
Feb 26, 2017, 11:49:36 AM2/26/17
to dea...@googlegroups.com
That's too complicated. MatrixOut is intended to visualize the elements of a
matrix, but you really just want to visualize pairs (x_i,y_i). Just output
these one by one to a file:

ofstream output("M");
for (l=0...) {
...
output << w << ' ' << val << std::endl;
}

and then visualize the resulting data using gnuplot's "plot" command.

Best
W.



--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Loylick

unread,
Feb 26, 2017, 6:25:53 PM2/26/17
to deal.II User Group, bang...@colostate.edu
Thank you, I thought that there was a more generic way of drawing 1D plots in Dealii.

Reply all
Reply to author
Forward
0 new messages