如何创建这个坐标系?

如何创建这个坐标系?

我目前正在为我的电气工程教授撰写学期论文/讲义,并希望在论文中包含以下坐标系/图形/图表。(图像应向左旋转 90°。)

DA 转换器的共域

我对 TikZ / pstricks / pgfplots /... 的了解相当有限(至少可以这么说),因此我在创建这个东西时真的很挣扎。-.-

我尝试让坐标系运行起来,但我能想到的最好的办法是:

\documentclass[tikz]{standalone}

\begin{document}
 \begin{tikzpicture}
  \tikzset{help lines/.style = {color = lightgray}}

  \draw[thick, step=1cm, help lines] (-10, -10) grid (10, 10);
  \draw[ultra thin, step=.5cm, help lines] (-10, -10) grid (10, 10);

  \draw[ultra thick, -latex] (-10,0) -- (10,0);
  \draw[ultra thick, -latex] (0,-10) -- (0,10);

  \foreach \y in {-10,-9,...,10} { \draw [thick] (0, \y) -- (-0.2, \y); }

  \foreach \y in {-10,-9,...,10} { \node [anchor = east] at (-0.3, \y) {\y}; }
 \end{tikzpicture}
\end{document}

图像中的 y 轴范围从 -10 到 10。这不是什么大问题,但 x 轴实际上范围从 0 到 255,因为它代表一个 8 位间隔。这是我不知道如何正确完成的第一件事。对于图像的其余部分,我完全不知道该怎么做(尤其是坐标系上方的 HEX/DEC 标题)。

非常感激你们的“一点”帮助和一些神奇的力量。:)

答案1

我稍微修改了您的基本代码,因为这样可以更轻松地在工作表中设置步骤。如果您有任何疑问,请在评论中询问我。

我想使用 a 设置顶部节点,\foreach而且我几乎已经完成了,但是与上面的编号不同,顶部节点的连续性没有逻辑,如果你明白我的意思,所以我想不出以相同方式设置它们的规则。

输出

图1

代码

\documentclass[tikz,margin=10pt]{standalone}
\usepackage{amsmath}

\usetikzlibrary{calc,shapes}

\newcommand{\middlecoord}{13.6}
\newcommand{\middleline}{13.3}

\begin{document}
\begin{tikzpicture}
\tikzset{help lines/.style = {color = lightgray}}

\draw[thick, step=1cm, help lines] (0, -10) grid (27, 10);
\draw[ultra thin, step=2mm, help lines] (0, -10) grid (27, 10);

\draw[ultra thick, -latex] (0,0) -- (27,0) node[fill=white, above, pos=.9] {Digitalwerte}; % X
\draw[ultra thick, -latex] (\middleline,-10) -- (\middleline,10) node[fill=white, left, xshift=-1, pos=.95] {$U_A/V$}; % Y

\node[above=7mm,anchor=south] at (-1,10) {Hex.};
\node[above=3mm,anchor=south] at (-1,10) {Dez.};

\foreach \value/\acron [count=\xi starting from 0] in {
    0/00H, 5/05H, 15/0FH, 25/19H, 35/23H, 45/2DH, 55/37H, 65/41H, 75/4BH, 85/55H, 95/63H, 105/69H, 115/72H, 125/79H,
    135/87H, 145/91H, 155/9BH, 165/A5H, 175/AFH, 185/B9H, 195/C3H, 205/CDH, 215/D9H, 225/E1H, 235/EBH, 245/F5H, 255/FFH}{
    \draw[lightgray, thick] (\xi+1, 10) -- (\xi+1,10.3);
    \node[above=3mm,anchor=south] at (\xi,10) {\value};
    \node[above=7mm,anchor=south] at (\xi,10) {\acron};
}

\node[above=3mm,anchor=south] at (\middlecoord,11) {128};
\node[above=7mm,anchor=south] at (\middlecoord,11) {7CH};
\draw[thick] (\middleline, 10) -- (\middleline,10.3) -- (\middlecoord,11.3);

\foreach \y in {-10,...,10}{
    \node[fill=white,anchor=west] at (\middlecoord,\y) {\y};
    \draw[thick] (\middleline-.2,\y) -- (\middleline+.2,\y);
}

\draw[thick, lightgray] (0,10.3) -- (.475,10); % diagonal line 0
\draw[lightgray] (.475,10) -- (.475,-10); % middle vertical line at 0
\draw[thick] (.475,-10) -- (26,10); % thick diagonal line

% ----------------------------------------
% The small rectangle in the bottom right
% ----------------------------------------

\node[draw,thick,minimum width=1.5cm,minimum height=1cm,ellipse] (ellc) at (\middlecoord-.25,0) {};
\filldraw[white] (15,-.5) -- (26.5,-.5) -- (26.5,-9.5) -- (15,-9.5) -- cycle;

\draw[ultra thick, -latex] (15.5,-5) -- (25,-5);
\draw[ultra thick, -latex] (20.5,-9) -- (20.5,-1) node[left, xshift=-1, pos=.95] {$U_A/mV$};

\draw[ultra thick] (21,-5) -- (21,-4) -- (22,-4) -- (22,-3) -- (23,-3) -- (23,-2) -- (24,-2); \draw[dashed, ultra thick] (24,-2) -- (24,-1);
\draw[ultra thick] (20,-5) -- (20,-6) -- (19,-6) -- (19,-7) -- (18,-7) -- (18,-8) -- (17,-8); \draw[dashed, ultra thick] (17,-8) -- (17,-9);

\foreach \x [count=\xxi starting from 123] in {16,17,...,24}{
    \node[below=1mm,fill=white, font=\footnotesize] at (\x,-5) {\xxi};
    \draw[ultra thick] (\x,-5) -- (\x,-5.1);
}

\draw ($(ellc.south east)+(.2cm,0)$) -- ($(ellc.south east)+(2.5cm,-1cm)$);

\draw[ultra thick] (20.4,-3) -- (20.5,-3); \node[left=1mm,font=\footnotesize] at (20.5,-3) {156.86};
\draw[ultra thick] (20.4,-4) -- (20.5,-4); \node[left=1mm,font=\footnotesize] at (20.5,-4) {78.43};
\draw[ultra thick] (20.5,-7) -- (20.6,-7); \node[right=1mm,font=\footnotesize] at (20.5,-7) {156.86};
\draw[ultra thick] (20.5,-8) -- (20.6,-8); \node[right=1mm,font=\footnotesize] at (20.5,-8) {235.29};
\end{tikzpicture}
\end{document}

答案2

这是 pstricks 解决方案。第四象限中的图形框zoomed.eps通过以下方式作为文件包含\epsfbox\includegraphics由于某种原因,不起作用):

\documentclass[11pt, pdf, x11names]{standalone}
\usepackage{pstricks-add}
\usepackage{graphicx}
\usepackage{changes, stackengine}
\setstackEOL{\\}
\input{binhex}

\begin{document}

\psset{arrowinset=0, arrowsize =2.5pt 2, mathLabel=false, ylabelPos=r}
\sffamily
\begin{pspicture*}(-4,-10.2)(26,15)%[showgrid]
    \psgrid[gridcolor=LightSteelBlue3,subgridcolor=LightSteelBlue2, gridlabels=0](-1,-10)(26.5,10)
    \uput{10pt}[u](12.4,11.25){\Rnode{S}{\Longstack{\nhex{2}{128}H\\128}}}
    \pnode(12.4,10){A}\ncline[nodesep=3pt]{S}{A}
    \psset{linecolor=LightSteelBlue4!65!, origin={-0.5,0}}
    \multido{\i =5+10, \n=0+1}{26}{\uput{10pt}[u](\n,10){\Longstack{\nhex{2}{\i}H\\\i}}}
    \uput{10pt}[u](-1,10){\rnode{HD}{\Longstack{00H\\0}}}
    \pnode(-0.5,10){O}\ncdiag[armA=6pt, angleB=90, nodesepB=2pt]{HD}{O}
    \uput{10pt}[u](-2,10){\Longstack{Hex\\Dec}}
    \psaxes[labels=y, labelsep=-10pt, ticks=none, linewidth=1.5pt]{->}(12.8,0)(-0.5,-10)(26.5,10) [\llap{Digitalwerte\qquad }, 100][\llap{U\textsubscript{A}/V\hskip2.5em}, -90]
    \rput(12.75,0){ \ovalnode[linecolor=black]{F}{\phantom{Ahah!}}}
    \rput[r]{*270}(-2.8,12){\itshape\rlap{Abbildung 3.4.1.2 Aufteilung desn, Wertebereichs (0 . . 255) des DA-Wandlers in Quantisierungsstufen}}
    \uput{-10pt}[r](12.8,10){10}
    \psline[linewidth=1.5pt](0,-10)(25.5,10)
    \psline[doubleline](0,-10)(0,10)
    \psnode(20,-5){MG}{%
        \psframebox*[fillcolor=white, fillstyle=solid, framesep = 10pt] {%
            \hskip-0.5cm\epsfbox{zoomed.eps}\hskip0.5cm }
    }%
    \ncline[linecolor=black]{F}{MG}
\end{pspicture*}

\end{document} 

的代码zoomed.tex。请注意,必须使用 编译文件pdflatex,并且必须使用 转换生成的 .pdf 为.epsepspdftk我猜想由 生成的中间 .eps 文件auto-pst-pdf可能会被保存,但我不知道该怎么做。

%% zoomed.tex
\documentclass[pdf, x11names]{standalone}
\usepackage{pstricks-add}
\usepackage{changes}

\begin{document}

\psset{arrowinset=0, arrowsize =2.5pt 2, mathLabel=false, ylabelPos=r, linewidth=1.2pt, arrows=->, }
\sffamily\footnotesize
\begin{pspicture}%
    \psaxes[tickstyle=b, Ox=128,yAxis=false](0,0)(-5.5,0)(4.,0)
    \psaxes[tickstyle=b, labels=none, xAxis=false](-0.5,0)(-0.5,4)[,0][\llap{U\textsubscript{A}/V}\qquad, -90]
    \psset{arrows=c-c}
    \psaxes[tickstyle=t, labels=none, xAxis=false](-0.5,0)(-0.5,-3.9)
    \multido{\i=1+1, \n=78.43+78.43}{3}{\uput{8pt}[l](-0.5,\i){\n}\uput{8pt}[r](-0.5,-\i){$ - $\n}}
    \multido{\i=-4+1,\I=-3+1, \Iv=-2+1}{6}{\psline(\i, \I)(\I, \I)(\I,\Iv )}%
    \psline(2,3)(3,3)
    \psset{linestyle=dashed, dash =5pt 4pt}\psline(-4,-3.8)(-4,-3)\psline(3,3)(3,3.8)
\end{pspicture}

\end{document} 

在此处输入图片描述

相关内容