TransWikia.com

Undefined control sequence help required for plotting a graph

TeX - LaTeX Asked by dbradley on February 9, 2021

When trying to insert a graph plotting a DC transfer curve from Multisim I have been having a minor issue and I’m not sure why. If anyone could explain how to fix this I would be greatly appreciative. The code is the block below and the error is "undefined control sequence". Thank you. Important to note as well the data is in a csv file and is separated by commas.

begin{figure}[h]
    begin{tikzpicture}
    begin{axis}[
    
        title = {DC Transfer Characteristic},
        xlabel = {Current (A)},
        ylabel = {Voltage (V)},
        xmin = 0, xmax = 10,
        ymin = 0, ymin = 0.16,
        xtick = {0, 2, 4, 6, 8, 10},
        ytick = {0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16},
        legend pos=north west,
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    addplot table[col sep=comma] {test.csv};
    
    end{axis}
    end{tikzpicture}
    
caption{Current through the 100 $Omega$ resistor with a variation in the voltage source}
end{figure}

Edit: Min Working Example

documentclass[a4paper, 12pt]{article}
usepackage{circuitikz}
usepackage{pgfplots}

begin{document}

title{Laboratory Report 1}
author{John Doe}

date{today}

maketitle
newpage

section{Problem 1}

paragraph{Questionnewline}

Question Text

begin{figure}[h]centering
begin{circuitikz}
      draw (0,5)
      to [battery2 = $12V$] (0, 0) % The DC power source
      to [short] (2,0)
      to (2, -0) node[ground]() {}
      to [short] (2,0) 
      to [short] (4,0)
      to [short] (4,1)
      to (4, 1) node[nigfete](CD4007NM){CD4007NM} %The transistor
      (CD4007NM.base) node[anchor=east] {}
      (CD4007NM.collector) node[anchor=south,xshift=0.5cm] {}
      (CD4007NM.emitter) node[anchor=north] {}
      (CD4007NM.collector) to[short] ++(0,1)
      (CD4007NM.base) to[short] ++(0,1.26)
      to [short] (4, 2)
      to[R=$100Omega$] (4, 5) % The resistor
      to [short] (0, 5);
end{circuitikz}
caption{Fig Text}
end{figure}

paragraph{Answernewline}

begin{figure}[h]
    begin{tikzpicture}
    begin{axis}[
        title = {DC Transfer Characteristic},
        xlabel = {Current (A)},
        ylabel = {Voltage (V)},
        xmin = 0, xmax = 10,
        ymin = 0, ymin = 0.16,
        xtick = {0, 2, 4, 6, 8, 10},
        ytick = {0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16},
        legend pos=north west,
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    addplot table[col sep=comma] {Question 1 Graph Results.csv};
    
    end{axis}
    end{tikzpicture}
    
caption{Fig text}
end{figure}


end{document}

Data file titled – Question 1 Graph Results.csv:

X,Y
1.769000000000000000000000000000,0.000001881220000000000000000000
1.770000000000000000000000000000,0.000001881760000000000000000000
1.771000000000000000000000000000,0.000021185500000000000000000000
1.772000000000000000000000000000,0.000042243900000000000000000000
1.773000000000000000000000000000,0.000063328600000000000000000000
1.774000000000000000000000000000,0.000084418600000000000000000000
1.775000000000000000000000000000,0.000105510000000000000000000000
1.776000000000000000000000000000,0.000126601000000000000000000000
1.777000000000000000000000000000,0.000147691000000000000000000000
1.778000000000000000000000000000,0.000168781000000000000000000000
1.779000000000000000000000000000,0.000189869000000000000000000000
1.780000000000000000000000000000,0.000210955000000000000000000000
1.781000000000000000000000000000,0.000232041000000000000000000000
1.782000000000000000000000000000,0.000253125000000000000000000000
1.783000000000000000000000000000,0.000274207000000000000000000000
1.784000000000000000000000000000,0.000295288000000000000000000000
1.785000000000000000000000000000,0.000316367000000000000000000000
1.786000000000000000000000000000,0.000337445000000000000000000000
1.787000000000000000000000000000,0.000358521000000000000000000000
1.788000000000000000000000000000,0.000379596000000000000000000000
1.789000000000000000000000000000,0.000400670000000000000000000000
1.790000000000000000000000000000,0.000421741000000000000000000000
1.791000000000000000000000000000,0.000442812000000000000000000000
1.792000000000000000000000000000,0.000463880000000000000000000000
1.793000000000000000000000000000,0.000484947000000000000000000000
1.794000000000000000000000000000,0.000506013000000000000000000000
1.795000000000000000000000000000,0.000527077000000000000000000000
1.796000000000000000000000000000,0.000548139000000000000000000000
1.797000000000000000000000000000,0.000569200000000000000000000000
1.798000000000000000000000000000,0.000590260000000000000000000000
1.799000000000000000000000000000,0.000611317000000000000000000000
1.800000000000000000000000000000,0.000632374000000000000000000000
1.801000000000000000000000000000,0.000653428000000000000000000000
1.802000000000000000000000000000,0.000674482000000000000000000000
1.803000000000000000000000000000,0.000695533000000000000000000000
1.804000000000000000000000000000,0.000716583000000000000000000000
1.805000000000000000000000000000,0.000737632000000000000000000000
1.806000000000000000000000000000,0.000758678000000000000000000000
1.807000000000000000000000000000,0.000779724000000000000000000000
1.808000000000000000000000000000,0.000800768000000000000000000000
1.809000000000000000000000000000,0.000821810000000000000000000000
1.810000000000000000000000000000,0.000842851000000000000000000000
1.811000000000000000000000000000,0.000863890000000000000000000000
1.812000000000000000000000000000,0.000884927000000000000000000000
1.813000000000000000000000000000,0.000905963000000000000000000000
1.814000000000000000000000000000,0.000926998000000000000000000000
1.815000000000000000000000000000,0.000948031000000000000000000000
1.816000000000000000000000000000,0.000969062000000000000000000000
1.817000000000000000000000000000,0.000990092000000000000000000000
1.818000000000000000000000000000,0.001011120000000000000000000000
1.819000000000000000000000000000,0.001032147000000000000000000000
1.820000000000000000000000000000,0.001053172000000000000000000000
1.821000000000000000000000000000,0.001074196000000000000000000000
1.822000000000000000000000000000,0.001095218000000000000000000000
1.823000000000000000000000000000,0.001116238000000000000000000000
1.824000000000000000000000000000,0.001137257000000000000000000000
1.825000000000000000000000000000,0.001158274000000000000000000000
1.826000000000000000000000000000,0.001179290000000000000000000000
1.827000000000000000000000000000,0.001200305000000000000000000000
1.828000000000000000000000000000,0.001221317000000000000000000000
1.829000000000000000000000000000,0.001242328000000000000000000000
1.830000000000000000000000000000,0.001263338000000000000000000000
1.831000000000000000000000000000,0.001284346000000000000000000000
1.832000000000000000000000000000,0.001305353000000000000000000000
1.833000000000000000000000000000,0.001326358000000000000000000000
1.834000000000000000000000000000,0.001347361000000000000000000000
1.835000000000000000000000000000,0.001368363000000000000000000000
1.836000000000000000000000000000,0.001389363000000000000000000000
1.837000000000000000000000000000,0.001410362000000000000000000000
1.838000000000000000000000000000,0.001431359000000000000000000000
1.839000000000000000000000000000,0.001452355000000000000000000000
1.840000000000000000000000000000,0.001473349000000000000000000000
1.841000000000000000000000000000,0.001494342000000000000000000000
1.842000000000000000000000000000,0.001515333000000000000000000000
1.843000000000000000000000000000,0.001536322000000000000000000000
1.844000000000000000000000000000,0.001557310000000000000000000000
1.845000000000000000000000000000,0.001578297000000000000000000000
1.846000000000000000000000000000,0.001599281000000000000000000000
1.847000000000000000000000000000,0.001620265000000000000000000000
1.848000000000000000000000000000,0.001641247000000000000000000000
1.849000000000000000000000000000,0.001662227000000000000000000000
1.850000000000000000000000000000,0.001683205000000000000000000000
1.851000000000000000000000000000,0.001704183000000000000000000000
1.852000000000000000000000000000,0.001725158000000000000000000000
1.853000000000000000000000000000,0.001746132000000000000000000000
1.854000000000000000000000000000,0.001767105000000000000000000000
1.855000000000000000000000000000,0.001788076000000000000000000000
1.856000000000000000000000000000,0.001809045000000000000000000000
1.857000000000000000000000000000,0.001830013000000000000000000000
1.858000000000000000000000000000,0.001850979000000000000000000000
1.859000000000000000000000000000,0.001871944000000000000000000000
1.860000000000000000000000000000,0.001892907000000000000000000000
1.861000000000000000000000000000,0.001913869000000000000000000000
1.862000000000000000000000000000,0.001934829000000000000000000000
1.863000000000000000000000000000,0.001955788000000000000000000000
1.864000000000000000000000000000,0.001976745000000000000000000000
1.865000000000000000000000000000,0.001997700000000000000000000000
1.866000000000000000000000000000,0.002018654000000000000000000000
1.867000000000000000000000000000,0.002039607000000000000000000000
1.868000000000000000000000000000,0.002060558000000000000000000000
1.869000000000000000000000000000,0.002081507000000000000000000000
1.870000000000000000000000000000,0.002102455000000000000000000000
1.871000000000000000000000000000,0.002123401000000000000000000000
1.872000000000000000000000000000,0.002144346000000000000000000000
1.873000000000000000000000000000,0.002165289000000000000000000000
1.874000000000000000000000000000,0.002186231000000000000000000000
1.875000000000000000000000000000,0.002207171000000000000000000000
1.876000000000000000000000000000,0.002228110000000000000000000000
1.877000000000000000000000000000,0.002249047000000000000000000000
1.878000000000000000000000000000,0.002269982000000000000000000000
1.879000000000000000000000000000,0.002290916000000000000000000000
1.880000000000000000000000000000,0.002311849000000000000000000000
1.881000000000000000000000000000,0.002332780000000000000000000000
1.882000000000000000000000000000,0.002353709000000000000000000000
1.883000000000000000000000000000,0.002374637000000000000000000000
1.884000000000000000000000000000,0.002395563000000000000000000000
1.885000000000000000000000000000,0.002416488000000000000000000000
1.886000000000000000000000000000,0.002437412000000000000000000000
1.887000000000000000000000000000,0.002458333000000000000000000000
1.888000000000000000000000000000,0.002479253000000000000000000000
1.889000000000000000000000000000,0.002500172000000000000000000000
1.890000000000000000000000000000,0.002521089000000000000000000000
1.891000000000000000000000000000,0.002542005000000000000000000000
1.892000000000000000000000000000,0.002562919000000000000000000000
1.893000000000000000000000000000,0.002583832000000000000000000000
1.894000000000000000000000000000,0.002604743000000000000000000000
1.895000000000000000000000000000,0.002625652000000000000000000000
1.896000000000000000000000000000,0.002646560000000000000000000000
1.897000000000000000000000000000,0.002667466000000000000000000000
1.898000000000000000000000000000,0.002688371000000000000000000000
1.899000000000000000000000000000,0.002709275000000000000000000000
1.900000000000000000000000000000,0.002730177000000000000000000000
1.901000000000000000000000000000,0.002751077000000000000000000000
1.902000000000000000000000000000,0.002771976000000000000000000000
1.903000000000000000000000000000,0.002792873000000000000000000000
1.904000000000000000000000000000,0.002813769000000000000000000000

One Answer

I wasn't planning to write an answer but it is hard to clarify this in the comments. Here is what I did.

begin{filecontents}[overwrite]{test.csv}
X,Y
1.769000000000000000000000000000,0.000001881220000000000000000000
1.770000000000000000000000000000,0.000001881760000000000000000000
1.771000000000000000000000000000,0.000021185500000000000000000000
1.772000000000000000000000000000,0.000042243900000000000000000000
1.773000000000000000000000000000,0.000063328600000000000000000000
1.774000000000000000000000000000,0.000084418600000000000000000000
1.775000000000000000000000000000,0.000105510000000000000000000000
1.776000000000000000000000000000,0.000126601000000000000000000000
1.777000000000000000000000000000,0.000147691000000000000000000000
1.778000000000000000000000000000,0.000168781000000000000000000000
1.779000000000000000000000000000,0.000189869000000000000000000000
1.780000000000000000000000000000,0.000210955000000000000000000000
1.781000000000000000000000000000,0.000232041000000000000000000000
1.782000000000000000000000000000,0.000253125000000000000000000000
1.783000000000000000000000000000,0.000274207000000000000000000000
1.784000000000000000000000000000,0.000295288000000000000000000000
1.785000000000000000000000000000,0.000316367000000000000000000000
1.786000000000000000000000000000,0.000337445000000000000000000000
1.787000000000000000000000000000,0.000358521000000000000000000000
1.788000000000000000000000000000,0.000379596000000000000000000000
1.789000000000000000000000000000,0.000400670000000000000000000000
1.790000000000000000000000000000,0.000421741000000000000000000000
1.791000000000000000000000000000,0.000442812000000000000000000000
1.792000000000000000000000000000,0.000463880000000000000000000000
1.793000000000000000000000000000,0.000484947000000000000000000000
1.794000000000000000000000000000,0.000506013000000000000000000000
1.795000000000000000000000000000,0.000527077000000000000000000000
1.796000000000000000000000000000,0.000548139000000000000000000000
1.797000000000000000000000000000,0.000569200000000000000000000000
1.798000000000000000000000000000,0.000590260000000000000000000000
1.799000000000000000000000000000,0.000611317000000000000000000000
1.800000000000000000000000000000,0.000632374000000000000000000000
1.801000000000000000000000000000,0.000653428000000000000000000000
1.802000000000000000000000000000,0.000674482000000000000000000000
1.803000000000000000000000000000,0.000695533000000000000000000000
1.804000000000000000000000000000,0.000716583000000000000000000000
1.805000000000000000000000000000,0.000737632000000000000000000000
1.806000000000000000000000000000,0.000758678000000000000000000000
1.807000000000000000000000000000,0.000779724000000000000000000000
1.808000000000000000000000000000,0.000800768000000000000000000000
1.809000000000000000000000000000,0.000821810000000000000000000000
1.810000000000000000000000000000,0.000842851000000000000000000000
1.811000000000000000000000000000,0.000863890000000000000000000000
1.812000000000000000000000000000,0.000884927000000000000000000000
1.813000000000000000000000000000,0.000905963000000000000000000000
1.814000000000000000000000000000,0.000926998000000000000000000000
1.815000000000000000000000000000,0.000948031000000000000000000000
1.816000000000000000000000000000,0.000969062000000000000000000000
1.817000000000000000000000000000,0.000990092000000000000000000000
1.818000000000000000000000000000,0.001011120000000000000000000000
1.819000000000000000000000000000,0.001032147000000000000000000000
1.820000000000000000000000000000,0.001053172000000000000000000000
1.821000000000000000000000000000,0.001074196000000000000000000000
1.822000000000000000000000000000,0.001095218000000000000000000000
1.823000000000000000000000000000,0.001116238000000000000000000000
1.824000000000000000000000000000,0.001137257000000000000000000000
1.825000000000000000000000000000,0.001158274000000000000000000000
1.826000000000000000000000000000,0.001179290000000000000000000000
1.827000000000000000000000000000,0.001200305000000000000000000000
1.828000000000000000000000000000,0.001221317000000000000000000000
1.829000000000000000000000000000,0.001242328000000000000000000000
1.830000000000000000000000000000,0.001263338000000000000000000000
1.831000000000000000000000000000,0.001284346000000000000000000000
1.832000000000000000000000000000,0.001305353000000000000000000000
1.833000000000000000000000000000,0.001326358000000000000000000000
1.834000000000000000000000000000,0.001347361000000000000000000000
1.835000000000000000000000000000,0.001368363000000000000000000000
1.836000000000000000000000000000,0.001389363000000000000000000000
1.837000000000000000000000000000,0.001410362000000000000000000000
1.838000000000000000000000000000,0.001431359000000000000000000000
1.839000000000000000000000000000,0.001452355000000000000000000000
1.840000000000000000000000000000,0.001473349000000000000000000000
1.841000000000000000000000000000,0.001494342000000000000000000000
1.842000000000000000000000000000,0.001515333000000000000000000000
1.843000000000000000000000000000,0.001536322000000000000000000000
1.844000000000000000000000000000,0.001557310000000000000000000000
1.845000000000000000000000000000,0.001578297000000000000000000000
1.846000000000000000000000000000,0.001599281000000000000000000000
1.847000000000000000000000000000,0.001620265000000000000000000000
1.848000000000000000000000000000,0.001641247000000000000000000000
1.849000000000000000000000000000,0.001662227000000000000000000000
1.850000000000000000000000000000,0.001683205000000000000000000000
1.851000000000000000000000000000,0.001704183000000000000000000000
1.852000000000000000000000000000,0.001725158000000000000000000000
1.853000000000000000000000000000,0.001746132000000000000000000000
1.854000000000000000000000000000,0.001767105000000000000000000000
1.855000000000000000000000000000,0.001788076000000000000000000000
1.856000000000000000000000000000,0.001809045000000000000000000000
1.857000000000000000000000000000,0.001830013000000000000000000000
1.858000000000000000000000000000,0.001850979000000000000000000000
1.859000000000000000000000000000,0.001871944000000000000000000000
1.860000000000000000000000000000,0.001892907000000000000000000000
1.861000000000000000000000000000,0.001913869000000000000000000000
1.862000000000000000000000000000,0.001934829000000000000000000000
1.863000000000000000000000000000,0.001955788000000000000000000000
1.864000000000000000000000000000,0.001976745000000000000000000000
1.865000000000000000000000000000,0.001997700000000000000000000000
1.866000000000000000000000000000,0.002018654000000000000000000000
1.867000000000000000000000000000,0.002039607000000000000000000000
1.868000000000000000000000000000,0.002060558000000000000000000000
1.869000000000000000000000000000,0.002081507000000000000000000000
1.870000000000000000000000000000,0.002102455000000000000000000000
1.871000000000000000000000000000,0.002123401000000000000000000000
1.872000000000000000000000000000,0.002144346000000000000000000000
1.873000000000000000000000000000,0.002165289000000000000000000000
1.874000000000000000000000000000,0.002186231000000000000000000000
1.875000000000000000000000000000,0.002207171000000000000000000000
1.876000000000000000000000000000,0.002228110000000000000000000000
1.877000000000000000000000000000,0.002249047000000000000000000000
1.878000000000000000000000000000,0.002269982000000000000000000000
1.879000000000000000000000000000,0.002290916000000000000000000000
1.880000000000000000000000000000,0.002311849000000000000000000000
1.881000000000000000000000000000,0.002332780000000000000000000000
1.882000000000000000000000000000,0.002353709000000000000000000000
1.883000000000000000000000000000,0.002374637000000000000000000000
1.884000000000000000000000000000,0.002395563000000000000000000000
1.885000000000000000000000000000,0.002416488000000000000000000000
1.886000000000000000000000000000,0.002437412000000000000000000000
1.887000000000000000000000000000,0.002458333000000000000000000000
1.888000000000000000000000000000,0.002479253000000000000000000000
1.889000000000000000000000000000,0.002500172000000000000000000000
1.890000000000000000000000000000,0.002521089000000000000000000000
1.891000000000000000000000000000,0.002542005000000000000000000000
1.892000000000000000000000000000,0.002562919000000000000000000000
1.893000000000000000000000000000,0.002583832000000000000000000000
1.894000000000000000000000000000,0.002604743000000000000000000000
1.895000000000000000000000000000,0.002625652000000000000000000000
1.896000000000000000000000000000,0.002646560000000000000000000000
1.897000000000000000000000000000,0.002667466000000000000000000000
1.898000000000000000000000000000,0.002688371000000000000000000000
1.899000000000000000000000000000,0.002709275000000000000000000000
1.900000000000000000000000000000,0.002730177000000000000000000000
1.901000000000000000000000000000,0.002751077000000000000000000000
1.902000000000000000000000000000,0.002771976000000000000000000000
1.903000000000000000000000000000,0.002792873000000000000000000000
1.904000000000000000000000000000,0.002813769000000000000000000000
end{filecontents}
documentclass[a4paper, 12pt]{article}
usepackage{circuitikz}
usepackage{pgfplots}


begin{document}

title{Laboratory Report 1}
author{John Doe}

date{today}

maketitle
newpage

section{Problem 1}

paragraph{Questionnewline}

Question Text

begin{figure}[h]centering
begin{circuitikz}
      draw (0,5)
      to [battery2 = $12V$] (0, 0) % The DC power source
      to [short] (2,0)
      to (2, -0) node[ground]() {}
      to [short] (2,0) 
      to [short] (4,0)
      to [short] (4,1)
      to (4, 1) node[nigfete](CD4007NM){CD4007NM} %The transistor
      (CD4007NM.base) node[anchor=east] {}
      (CD4007NM.collector) node[anchor=south,xshift=0.5cm] {}
      (CD4007NM.emitter) node[anchor=north] {}
      (CD4007NM.collector) to[short] ++(0,1)
      (CD4007NM.base) to[short] ++(0,1.26)
      to [short] (4, 2)
      to[R=$100Omega$] (4, 5) % The resistor
      to [short] (0, 5);
end{circuitikz}
caption{Fig Text}
end{figure}

paragraph{Answernewline}

begin{figure}[h]
    begin{tikzpicture}
    begin{axis}[
        title = {DC Transfer Characteristic},
        xlabel = {Current (A)},
        ylabel = {Voltage (V)},
        xmin = 0, xmax = 10,
        ymin = 0, ymax = 0.16,
         xtick = {0, 2, 4, 6, 8, 10},
         ytick = {0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16},
        legend pos=north west,
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    addplot table[col sep=comma,x=X,y=Y] {test.csv};
    
    end{axis}
    end{tikzpicture}
    
caption{Fig text}
end{figure}


end{document}

enter image description here

Obviously there are many things one can improve, but you see a tiny bit of a plot. Why only a tiny bit? Because the plot data has only very small overlap with the area under consideration:

    xmin = 0, xmax = 10,
    ymin = 0, ymax = 0.16,

Answered by user228539 on February 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP