1

A similar question is asked here. Basically, I have three columns (A, B, C) and they represent measurements A(B) and C(B). Say, B is time, A temperature and C any other physical quantity that depends on A.

I would like to plot on x1 temperature, on x2 time and on y1 C as it evolves with time. The mentioned solution works for a few datapoints but is not usable for a larger dataset because it essentially modifies the labels and I lose control over the labels. I would like the plot to look like: enter image description here with temperature on the x1 axis in a nice form that is something like: enter image description here Obviously they will not be initially equidistant because the relationship between temperature and time is: enter image description here

Any idea how to approach this? The test data is here https://pastebin.com/CqAHjBJe

atapaka
  • 1,172
  • 4
  • 14
  • 30

2 Answers2

0

As I understand your question, you want to link x1 and x2 axes, correct? For this you need an expression and the inverse of it. Check help link.

I would say that this makes only sense in the range of your (linear?!) temperature increase over time. From the graph, I read the values:

# Time
t0 = 73
t1 = 287
# Temperature
T0 = 179
T1 = 1252

I guess, one could also think about a way to extract these values automatically.

Script:

### link x1 and x2 axes
reset session

FILE = "SO76860010.dat"

# Time
t0 = 73
t1 = 287
# Temperature
T0 = 179
T1 = 1252

set datafile separator comma
set xlabel "Time"
set xrange[t0:t1]
set xtics nomirror

set x2label "Temperature"
set link x2 via (x-t0)*real(T1-T0)/(t1-t0) + T0 inverse (x-T0)*real(t1-t0)/(T1-T0) + t0
set x2tics 100
set grid x2,y

set ylabel "Quantity"
set key noautotitle

plot FILE u 2:3 w l lc "red"
### end of script

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72
  • 1
    If you look at the plot of `t` vs `T` there is no simple functional relationship between them. `T` is measured as a function of `t`, and while ideally there is a functional relationship that was input into the machine, there is no reason to assume that the machine followed it exactly (you can see it at several points that the temperature overshoots the target). For that reason, `set link` is not a good option. – atapaka Aug 08 '23 at 15:40
  • @atapaka so far, for me the values of an axis were either strictly increasing or strictly decreasing but not both. You can either plot your quantity versus time or versus temperature. I don't see how you want to "link" two axes if one is not monotonic. Well, you could go to 3D. x=time, y=temparature, z=quantity. – theozh Aug 08 '23 at 18:30
0

If I understand well, you want something like this:

image

reset; set datafile separator "\t ,";
set grid x2tics ytics
set xlabel 'Temperature'
set ylabel 'signal'
set x2label 'time' offset 0,-0.5

set xtics nomirror
set x2tics nomirror

set xrange[0:300]
set x2range[0:300]

plot '013_d2.dat' u 2:3:xtic("".int($1)) every 100 axes x2y1 w d lc 1 notitle ,\
'' u 2:3 axes x2y1 w l lc 1 t 'Measurement'

The key of the solution is assigning some of your time data to the xtics by: using 2:3:xtics(1). However, you have too much data, therefore you have to make them fewer by every.

For a better look, you can round your temperature data by int($1/10)*10

If you want to examine the code, use it without the w d and lc specifiers.

EDIT: I have updated the answer using your data provided.

EDIT2: I have updated the answer reversing the x1-x2 axes (as the OP originally wanted).

Tom Solid
  • 2,226
  • 1
  • 13
  • 32
  • Although this might be what OP wants, but the plotted data together with the x2-axis is not correct or at least misleading. The real curve doesn't go backwards in time. – theozh Aug 09 '23 at 05:40
  • @theozh Tom Solid did it vice versa. The plot should have been `Column(3)` (y-axis) as a function of time (on `x2` axis) and then put the corresponding temperatures on the x1 axis. This is really what i wanted. This is because, the physical dependence of some value (think e.g. of amount of water in a sample) is on temperature but in an experiment, don't really control temperature but by measuring it, you adjust power in the heating element (or think of an isothermal step at a temperature to remove adsorbed water which causes that loop around 180C) and the only monoincreasing variable is time. – atapaka Aug 09 '23 at 07:48
  • @atapaka I beg your pardon. I'm used to x1 being the main axis and x2 the auxiliary one. – Tom Solid Aug 09 '23 at 08:43