Hi I would like to plot a graph of load voltage vs load current, I have been trying to do it with a tikzpicture
, but wonder if maybe it can be done with a tikzplot
? The bellow code is sort of what I am after, I want to plot the data and measure the gradient and get the yintercept
, I'm quite new at using pgfplot
so quite a step learning curve for me. My plot points would be
P1(0.750,7.50)
P2(0.409,8.192)
P3(0.281,8.437)
...
I can figure out the equation for the line and put this on as a label?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [ultra thick,-latex] (0,0)--(10,0) node [right, above]{$I_L$ Load Current};
\draw [ultra thick,-latex] (0,0)--(0,12) node [right]{$V_L$Load Voltage};
\coordinate (X2) at (4,0);
\coordinate (X1) at (6,0);
\coordinate (P1) at (0,5);
\coordinate (P2) at (0,7);
\coordinate (b) at (4,5);
\coordinate (d) at (6,7);
\coordinate (a) at (4,7);
\coordinate (c) at (6,5);
\node at (X2) [below] {$X2$};
\node at (X1) [below] {$X1$};
\node at (P2) [left] {$P2$};
\node at (P1) [left] {$P1$};
\draw [dashed] (a)node [above right] {$a$}--(X2);
\draw [dashed] (d)node [above right] {$d$}--(X1);
\draw [dashed] (P1)--(c)node [above right] {$c$};
\draw (P2)--(d)node [above right] {$d$};
\node at (b) [above right]{$b$};
%\draw (d)--++(0:2)node [right] {$ MC=AC$};
\draw (c)--(a)--++(135:5.65);
\draw (c)--++(-45:2) node [below] {$D$};
\end{tikzpicture}
\end{document}
This is what I have so far, but cant get it to look like the above example.. I'd like to take the dashed lines from some of my data points
\documentclass[convert = false, border=10pt]{standalone}
% http://sourceforge.net/projects/pgfplots/
\usepackage{pgfplots}
\usepackage{amsmath}
\usepackage{steinmetz}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=Voltage,
ylabel=Current]
\addplot[color=blue,mark=x] coordinates {
(0.750,7.5)
(0.409,8.192)
(0.2812,8.437)
(0.2143,8.571)
};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
This is one possible solution where the linear regression from
pgfplotstable
library is utilized. And the linear model is computed and shown in the legend.Y interception
is also shown in the graph.Code