Cómo calcular y mostrar un nuevo valor a partir de una regresión lineal

Cómo calcular y mostrar un nuevo valor a partir de una regresión lineal

El siguiente MWE muestra una plantilla que uso en la universidad para mostrar datos de calibración y la regresión lineal correspondiente. Ahora estaba preguntando si puedo calcular un valor de $X$ para un valor de $Y$ determinado y mostrarlo dentro de un gráfico similar al de la siguiente imagen.

mostrar valores calculados dentro de la trama

Hasta ahora tengo que calcular los valores a mano y darles los queridos pgfplots.

Espero que la pregunta sea lo suficientemente clara y que haya una solución semiautomática.

PD: uso LuaLaTeX para compilar. Para una mejor usabilidad, comenté la fuente que uso.

\documentclass{standalone}

\usepackage{luaotfload}
\usepackage[no-math]{fontspec}
%\defaultfontfeatures{Ligatures=TeX} %,Scale=MatchLowercase} still buggy
%\setmainfont{Linux Biolinum O}
%\setsansfont{Linux Biolinum O}
%\setmonofont{Linux Libertine Mono O}

\usepackage{polyglossia}
\setmainlanguage{german}
\usepackage[autostyle=true]{csquotes}

\usepackage[
    tbtags,
    sumlimits,
    intlimits,
    namelimits
    ]{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amscd}
\setcounter{MaxMatrixCols}{12}
\usepackage[german]{translator}
\usepackage[detect-all=true]{siunitx}
\sisetup{
%   strict,
    output-decimal-marker={,},
    exponent-product=\cdot,
    text-micro={\fontfamily{mdbch}\textmu},
    math-micro=\muup
}
\DeclareSIUnit\molar{M}
\usepackage[math-style=ISO,bold-style=ISO]{unicode-math}
\setmathfont{Asana Math}
\usepackage{lualatex-math}

\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    title={Kalibration für den Versuch XYZ},
    /pgf/number format/use comma,
    width=\linewidth,
    grid=major,
    grid style={dashed,gray!30},
    x label style={at={(axis description cs:.5,-.025)},anchor=north},
    y label style={at={(axis description cs:.05,.5)},anchor=south},
    xlabel=Konzentration~{[}\si{\milli\gram\per\milli\litre}{]},
    ylabel=Extinktion,
%   xtick={0,60,90,120,150,180},
    x tick label style={rotate=90,anchor=east},
    legend cell align=left,
    legend pos=north west,
    ]
    \addplot[
    only marks,
    thick,
    color=black,
    mark=*,
    mark options={fill=red},
    ] table [x=X,y=Y, row sep=\\] {
        X Y\\
        0 0\\
        25 0.17\\
        50 0.43\\
        75 0.60\\
        100 0.79\\
        125 1.01\\
        };
    \addlegendentry{Messpunkte}
    \addplot[thick,color=blue] table[row sep=\\,y={create col/linear regression={y=Y}},mark=none] {
        X Y\\
        0 0\\
        25 0.17\\
        50 0.43\\
        75 0.60\\
        100 0.79\\
        125 1.01\\
        };
    \addlegendentry{%
        $\pgfmathprintnumber{\pgfplotstableregressiona} \cdot x
        \pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$};
    \draw[thick,color=blue] (axis cs:20,-1) -- (axis cs:20,.15609);
    \draw[thick,color=blue] (axis cs:-20,.15609) -- (axis cs:20,.155);
    \node [coordinate,pin=below right:{\scriptsize\textit{minimal effective concentration}}] at (axis cs:20,.15609) {};
    \end{axis}
    \end{tikzpicture}
\end{document}

Respuesta1

La forma más sencilla de dibujar estas líneas es definir todos los valores como macros y calcular el valor de x con \pgfmathparse{(\myY-\pgfplotstableregressionb)/\pgfplotstableregressiona}. El resultado se puede guardar como \pgfmathsetmacro\myX{\pgfmathresult}.

% % Y-Value % %
\def\myY{0.155}
% % % % % % % %

\def\xMin{0}
\def\yMin{0} 

Los mínimos se utilizan para la intersección con el eje.

\documentclass{standalone}

\usepackage[german]{translator}
\usepackage[detect-all=true]{siunitx}
\sisetup{
%   strict,
    output-decimal-marker={,},
    exponent-product=\cdot,
    text-micro={\fontfamily{mdbch}\textmu},
    math-micro=\muup
}
\DeclareSIUnit\molar{M}


\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}

% % Y-Value % %
\def\myY{0.155}
% % % % % % % %

\def\xMin{0}
\def\yMin{0} 

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    title={Kalibration für den Versuch XYZ},
    /pgf/number format/use comma,
    width=\linewidth,
    grid=major,
    grid style={dashed,gray!30},
    x label style={at={(axis description cs:.5,-.025)},anchor=north},
    y label style={at={(axis description cs:.05,.5)},anchor=south},
    xlabel=Konzentration~{[}\si{\milli\gram\per\milli\litre}{]},
    ylabel=Extinktion,
%   xtick={0,60,90,120,150,180},
    xmin=\xMin,
    ymin=\yMin,
    x tick label style={rotate=90,anchor=east},
    legend cell align=left,
    legend pos=north west,
    ]
    \addplot[
    only marks,
    thick,
    color=black,
    mark=*,
    mark options={fill=red},
    ] table [x=X,y=Y, row sep=\\] {
        X Y\\
        0 0\\
        25 0.17\\
        50 0.43\\
        75 0.60\\
        100 0.79\\
        125 1.01\\
        };
    \addlegendentry{Messpunkte}
    \addplot[thick,color=blue] table[row sep=\\,y={create col/linear regression={y=Y}},mark=none] {
        X Y\\
        0 0\\
        25 0.17\\
        50 0.43\\
        75 0.60\\
        100 0.79\\
        125 1.01\\
        };
    \addlegendentry{%
        $\pgfmathprintnumber{\pgfplotstableregressiona} \cdot x
        \pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$};
        \pgfmathparse{(\myY-\pgfplotstableregressionb)/\pgfplotstableregressiona}     
    \pgfmathsetmacro\myX{\pgfmathresult} 
    \draw[thick,color=blue] (axis cs:\myX,\yMin) -- (axis cs:\myX,\myY);
    \draw[thick,color=blue] (axis cs:\xMin,\myY) -- (axis cs:\myX,\myY); 
    \node [coordinate,pin=below right:{\scriptsize\textit{minimal effective concentration}}] at (axis cs:\myX,\myY) {};
    \end{axis}
    \end{tikzpicture}
\end{document} 

información relacionada