1

I am making a graph in PGFPlots, and I have many lines along my axes. My MWE contains two. Each have different error value, and my data are in coordinate form, not in table form. Would I have to readjust my data to fit into table form (and then use the addition of errors like this question?) or is there another way to define my errors with my data in coordinate form?

I am unfamiliar with using a tabular structure for my data in PGFPlots. If I must I will look at other questions on this site, but I would appreciate an explanation for that too.

Here is my MWE:

\documentclass[11pt,a4paper]{article}

\newcommand{\textsharp}{$\sharp$}

\usepackage{mathtools}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{transparent}

\usepackage[hyphens]{url}
\usepackage{breakurl} 
\usepackage[breaklinks]{hyperref}
\hypersetup{
    colorlinks = false,
    allbordercolors = white,
    pdfborder = 0 0 0,
    breaklinks=true}
%\usepackage{cite}
\def\UrlBreaks{\do\/\do-}

\usepackage{cleveref}

\usepackage{bookman}
\usepackage[T1]{fontenc}

\usepackage{geometry}

%\usepackage[square, super]{natbib}

\usepackage{ragged2e}

\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}
\usepackage{tikz}

\geometry{
tmargin=20mm, 
bmargin=20mm, 
lmargin=20mm, 
rmargin=20mm,
}

\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    title={Change of Guitar String Frequency due to Change in Humidity over Time},
    xlabel={Time (s $\times 10^4$)},
    ylabel={Average $\Delta$Frequency (Hz $\times 10^{-2}$)},
    xmin=0, xmax=24,
    ymin=0, ymax=50,
    xtick={0,2,4,6,8,10,12,14,16,18,20,22,24},
    ytick={0,5,10,15,20,25,30,35,40,45,50},
    legend pos=outer north east,
    ymajorgrids=true,
    xmajorgrids=true,
    xminorgrids=true,
    yminorgrids=true,
]

\addplot[ % E STRING
    color=blue,
    only marks,
    % scatter,
    mark=*,
    mark size=2.9pt,
    error bars/.cd,
    y dir=both,
    y explicit,
    ]
    coordinates {
    (0,0)(2.88,9)(5.76,12)(8.64,25)(11.52,13)(14.4,14)(17.28,15)(20.16,15)(23.04,13)
    };
    \legend{E String (Base $f = 82.41$ Hz)}
\addplot [
    domain=0:23.04, 
    samples=200, 
    color=blue,
    ]
    {0.0006*x + 13.78};
    \addlegendentry{Line of Best Fit - E String}

    \addplot[ % A STRING
    color=red,
    only marks,
    % scatter,
    mark=*,
    mark size=2.9pt,
    ]
    coordinates {
    (0,0)(2.88,3)(5.76,4)(8.64,9)(11.52,9)(14.4,5)(17.28,7)(20.16,8)(23.04,6)
    };
    \addlegendentry{A String (Base $f = 110$ Hz)}
\addplot [
    domain=0:23.04, 
    samples=200, 
    color=red,
    ]
    {0.0015*x + 4.49};
    \addlegendentry{Line of Best Fit - A String}
\end{axis}
\end{tikzpicture}
\end{document}
0

So I decided to switch to an external .dat file for my data points in my graph. I was able to use the method from the question I linked to solve my problem in both linking the tables and compiling the pdf. It also compiles faster this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.