绘制图形需要未定义的控制序列帮助

绘制图形需要未定义的控制序列帮助

当我尝试从 Multisim 插入绘制直流传输曲线的图表时,我遇到了一个小问题,但我不知道为什么。如果有人能解释如何解决这个问题,我将不胜感激。代码是下面的块,错误是“未定义的控制序列”。谢谢。同样值得注意的是,数据在 csv 文件中,并用逗号分隔。

\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}

编辑:最小工作示例

\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{Question\newline}

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=$100\Omega$] (4, 5) % The resistor
      to [short] (0, 5);
\end{circuitikz}
\caption{Fig Text}
\end{figure}

\paragraph{Answer\newline}

\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}

数据文件标题为 - 问题 1 图表结果.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

答案1

我本来不打算写答案,但在评论中很难澄清这一点。以下是我所做的。

\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{Question\newline}

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=$100\Omega$] (4, 5) % The resistor
      to [short] (0, 5);
\end{circuitikz}
\caption{Fig Text}
\end{figure}

\paragraph{Answer\newline}

\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}

在此处输入图片描述

显然,还有很多可以改进的地方,但你看到的只是一点点图。为什么只有一点点?因为图数据与所考虑的区域只有很小的重叠:

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

相关内容