0

I used gnuplot to plot this data

0.20    0.41
0.40    0.67
0.75    1.10
2.35    2.20
1.35    1.45
0.25    0.26
1.20    1.22

This is the code

set xlabel "t"
set ylabel "ln{{T_n-T_e}{T_w -T_e}}"

fit t*x 'data.txt' via t

unset key

plot 'data.txt', t*x

and its graph.

It is not possible to set the y axis a the expression enter image description here

enter image description here

  • 1
    No idea in gnuplot, but in R plots with the tikzDevice you can include LaTeX equations in plot labels like here. – Fran Mar 04 '24 at 00:33
  • 1
    Why not use pgfplots instead of gnuplot? – Andrey L. Mar 05 '24 at 09:41
  • 1
    Kindly see my Tikz-solution here: https://tex.stackexchange.com/a/712310/245790 . // Are you sure you intended to post a La/TeX related question here? If so, please add some information in your question to give us some idea, what you try to achieve. Thank you – MS-SPO Mar 06 '24 at 07:41

1 Answers1

1

Here's a way to do it in Tikz as Andrey L suggested:

  • see the pgfplots manual for details (or on ctan)
  • your posted data miss one point, so there's a difference
  • you should add some names to your data
X       Y
0.20    0.41
0.40    0.67
0.75    1.10
2.35    2.20
1.35    1.45
0.25    0.26
1.20    1.22

result

Basic hierarchical structure:

  • new tikzpicture environment
  • inside tikzpicture: new axis environment
  • inside axis: add as many plots as you need via \addplot
  • specify details for axis, addplot or table, see below, i.e. do it in the right place
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{pgfplots,pgfplotstable}

\begin{document} \begin{tikzpicture} % ~~~ frame, title, labels etc. ~~~~~~~~~~ \begin{axis}[ title=Whatever title you want here, xlabel={$t$ [s]}, ylabel=$\ln{\frac{T_H-T_e}{T_w-T_e}}$, ] % ~~~ first curve or data ~~~~~~~~~~~ \addplot [ only marks, mark=+, ] table {data.txt}; % ~~~ adding a regression ~~~~~~ \addplot [ dotted, teal, ] table [ y={create col/linear regression={y=Y}}, ] {data.txt}; \end{axis} \end{tikzpicture} \end{document}

MS-SPO
  • 11,519