문제

I'm trying to plot data obtained with FreeFEM++ using gnuplot.

From FreeFEM I have saved the data with the following code:

{ ofstream ff("sol.dat");
    for (int i=0;i<Th.nt;i++){
            for ( int j=0; j<3; j++){
                    ff<<Th[i][j].x << "\t" << Th[i][j].y << "\t" << u[][Vh(i,j)] << endl;
            }
            ff<<Th[i][0].x << "\t" << Th[i][0].y << "\t" << u[][Vh(i,0)] << "\n\n\n";
    }

}

A sample of the first lines of data is:

0.635787    -0.0440338  0.0056924
0.65234 -0.063181   0.00797757
0.655369    -0.0412323  0.00795786
0.635787    -0.0440338  0.0056924


0.597634    -0.0376 3.06323e-33
0.613904    -0.0585366  0.0030425
0.616879    -0.0388107  0.0030295
0.597634    -0.0376 3.06323e-33

where for some reason which I don't know there is a data point repeated two times in each 'pack'. But this is how they tell you to do it in the FreeFem manual. Apparently GNUPLOT needs the spaces between 'packs of data' for some reason.

I'm trying to plot the data with the gnuplot script:

set pm3d at b
set palette rgbformulae 30,31,32
set hidden3d
splot "sol.dat" with lines palette

It plots fine but I think pm3d is not doing anything. I thought pm3d would include the colored pattern of heat intensity in the bottom of the plot. Also I don't find the way to fill with solid color the gaps between the lines in the plot.

OUTPUT SAMPLE

Thank you.

도움이 되었습니까?

해결책

An answer to this requires first a proper explanation of different possibilities to organize the data:

  1. Two empty rows separate two different data sets. These aren't connected at all, no lines are drawn between them. In your case this is required, because gnuplot doesn't support the kind of grid you have for a single surface.

  2. pm3d works only within a single data set, and needs a regular grid (see the pm3d demos). Two lines (isolines) of a single surface must be separated by only one empty row.

Still you have an irregular grid, which pm3d can't handle. Inside gnuplot you can use dgrid3d to resample your input data to get a regular grid and plot that one with pm3d.

But dgrid3d affects all data files of a one splot command. So you'll also need multiplot to use two splot commands.

The following script shows how it could work, but as I don't have the full data set and don't know how dgrid3d copes with that many data sets (see 1. above), this is only a very rough guide:

set multiplot

set pm3d at b
set dgrid3d 200,200
unset key
splot 'sol.dat' nosurface

unset dgrid3d
unset pm3d
splot 'sol.dat' with lines palette

unset multiplot

That should work, but you probably need to tune the dgrid3d call. Also, some other enhancements may be required (plotting the border, tics and colorbox only once etc.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top