1

I have thickness measurements taken on a flat plate. Is there any excel like conditional formatting option in gnuplot? I would like to have four different plots with the values,

  1. Higher than a given number, say, in this case, 0.5
  2. Lower than 0.5
  3. Between a given range, say, 0.5 and 0.51
  4. Only the values 0.5?

How to modify the codes below?

    set pm3d map
    splot 't.dat' matrix

Here is my data file

0.509   0.510   0.515   0.529   0.521   0.516   0.515
0.511   0.506   0.512   0.528   0.524   0.517   0.512
0.510   0.506   0.506   0.530   0.524   0.522   0.505
0.511   0.509   0.513   0.516   0.511   0.520   0.510
0.524   0.516   0.512   0.511   0.507   0.518   0.492
0.525   0.521   0.515   0.517   0.518   0.522   0.500
0.530   0.521   0.513   0.512   0.511   0.519   0.503
0.562   0.516   0.510   0.516   0.522   0.518   0.508
0.520   0.518   0.512   0.517   0.518   0.518   0.510
0.510   0.509   0.503   0.507   0.523   0.519   0.522
0.506   0.500   0.424   0.507   0.523   0.527   0.519
0.509   0.430   0.500   0.513   0.519   0.528   0.524
0.506   0.503   0.503   0.506   0.513   0.528   0.533
0.506   0.517   0.519   0.524   0.524   0.526   0.528
0.525   0.517   0.499   0.520   0.521   0.524   0.518
0.519   0.518   0.516   0.519   0.521   0.520   0.519
0.521   0.502   0.515   0.518   0.518   0.523   0.522
0.515   0.519   0.519   0.534   0.524   0.525   0.516
0.517   0.510   0.522   0.532   0.533   0.530   0.525
0.520   0.457   0.526   0.530   0.530   0.531   0.524
0.530   0.520   0.531   0.529   0.527   0.526   0.524

Thanks!

4
  • This can be done, but what do you want to put on the heat map for those points for which the value is outside of range? Commented Feb 13, 2015 at 14:55
  • Maybe it is a option to plot contours for these values. Commented Feb 13, 2015 at 17:48
  • @Miguel, values outside the range with white color? So that looking at the plot I can have visual idea of the plate thickness condition. Commented Feb 16, 2015 at 15:51
  • @kuki Did you check my answer? Does that work for you? You can get white color either by skipping the data (second option in the answer) or by creating a palette where white is assigned to the range max or min: set palette defined (0.5 "white", 0.50000001 "black", 0.52333 "#8A2BE2", 0.54667 "red", 0.57 "yellow") then truncate the data point to that value (0.5 in this example) with a conditional plot as explained in my answer. Commented Feb 16, 2015 at 16:29

1 Answer 1

1

You can do conditional plots like this, but the conditional filtering will leave "holes" in your graph.

Without formatting:

set pm3d map
splot "./data" matrix

enter image description here

Plotting only values larger than 0.5:

set pm3d map
splot "./data" matrix u 1:2:($3 > 0.5 ? $3 : 1/0)

enter image description here

You see you have points missing. If you filter even more, you'll have more points missing, to the extreme that you might not have anything to plot (with < 0.5) because there is no way to interpolate. What you can do is substitute points outside of range by a fixed value. For instance, if the value is smaller than 0.5 substitute by 0.5, if it's larger than 0.53 substitute by 0.53:

set pm3d map
splot "./data" matrix u 1:2:($3 < 0.5 ? 0.5 : $3 > 0.53 ? 0.53 : $3)

enter image description here

For nicer display with these small matrices, you can think about interpolation:

set pm3d map interpolate 32,32
splot "./data" matrix u 1:2:($3 < 0.5 ? 0.5 : $3 > 0.53 ? 0.53 : $3)

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Miguel. I have a question or two. Hopefully you will be available to answer them based on your solutions.
@kuki Just ask. That's the purpose of SO after all.
I got the condition part but can't google it out why only column 1, 2 and 3 in 1:2:($3 > 0.5 ? $3 : 1/0). Is it more like row:column:values?
Yes, with matrix the using option works differently. Instead of columns it's indices referring to the position of the data points on the grid. 3 now refers to the value of each data point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.