0
votes

In my simulations, I have two numerical grids that overlap each other. One of them (the smaller one) is not rectangular but has a curved boundary (at least the area in which I care about it).

I would like to visualize those two numerical grids and how they overlap each other in gnuplot as a 2D plot. The result should look similar to this:

enter image description here

The red grid spans the entire area, the black grid is a subset of the red one with a curved boundary. The blue line is an approximation of the boundary.

This looks good so far, except for the fact that this is a 3D-plot at which I look exactly from above; i.e. in gnuplot I can rotate it if I wanted to.

gnuplot> show view
    view is 0 rot_x, 270 rot_z, 1 scale, 1 scale_z

Viewed from this angle none of the information of the z-axis is visible. It sort of removes the reason for a 3D plot as all you can see are the grids on which your data live. And this is precisely what I want.

But then, I rather have a 2D plot since those are more efficient to handle in gnuplot and also gnuplot generates a huge margin around 3D plots which reduces the useable area. How can I get this mesh projected into a 2D plane and get gnuplot to visualise it?


How to create above plot: I have one variable that is defined on the entire grid, but is non-zero (and always positive) only on the black part of the grid. The data are stored in the file "values.dat" in the usual way---in three columns in polar coordinates:

r (radius) -- theta (polar angle) -- value

Then you can get above plot with:

set style line 1 lt 1 dt 3 lc rgb "red"
set style line 2 lt 1 lc rgb "black"
set view 0, 270, 1, 1
splot "values.dat" u 1:2:(1.0) w l ls 1, \
      "values.dat" u 1:2:($3>0.0?1.0:NaN) w l ls 2

The blue line in the graph is additional and comes from a separate approximation of the grid boundary but is not really relevant for the question here.

1
you did this graph in gnuplot? Where is the code for generating this plot? How does the data for the grid spacing look like?theozh
@theozh, I've added a section to my question, explaining the data structure and the gnuplot commands.Christian K
I just figured that the set view map command in gnuplot did exactly what I want! Success!Christian K

1 Answers

0
votes

The gnuplot command

set view map

does exactly what I want.

From the gnuplot documentation:

It supports both 3D projection or orthogonal 2D projection into a 2D plot-like map.