![如何重绘并完成控制图?](https://linux22.com/image/439930/%E5%A6%82%E4%BD%95%E9%87%8D%E7%BB%98%E5%B9%B6%E5%AE%8C%E6%88%90%E6%8E%A7%E5%88%B6%E5%9B%BE%EF%BC%9F.png)
我正在尝试绘制一个块,但我不明白包装图表块,我想退出最后一个块并将其作为示例。也许可以使用pgfplots
和块来完成,但它应该schemabloc
更方便和有用(我想学习应用)。
平均能量损失:我尝试过很多次去理解这个包,但已经厌倦了。那是因为我分心了,代码没有上传。
\documentclass{article}
\usepackage{tikz}
\usepackage{schemabloc}
\begin{document}
\begin{tikzpicture}
\sbEntree{E}
\sbComp{comp}{E}
\sbRelier[$v_s$]{E}{comp}
\sbBloc{F}{$\alpha$}{comp}
\sbRelier[$$]{comp}{F}
\sbBloc[6]{int}{$\frac{1}{s}$}{F}
\sbRelier[$v_o$]{F}{int}
\sbRelier{F}{int}
\sbDecaleNoeudy[4]{F}{U}
\sbBlocr[-2]{R}{$\beta$}{U}
\sbRelieryx{F-int}{R}
\sbRelierxy[$v_f$]{R}{comp}
\end{tikzpicture}
\end{document}
更新 由于理解 schemabloc 包有点麻烦(至少对我来说),有人可以按照你的建议移植它吗?谢谢
答案1
对于左边的灯,Zarko 使用了style
;另一种方法是使用pic
。这是另一种简单的 TikZ 方法:使用通常的圆圈node
,然后通过在背景中绘制一些东西来装饰它。使用简单的 TikZ,您可以轻松完全控制您的图形。
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{backgrounds}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[>=latex]
\def\a{2.5} \def\b{2}
\path[nodes={minimum width=15mm, minimum height=10mm,draw,thick,fill=yellow!50}]
(0,0) node (alpha) {$\alpha$}
(0,-\b) node (beta) {$\beta$}
;
\path
(\a,0) node[circle,fill,inner sep=1mm] (R) {}
(-\a,0) node[circle,draw,thick,minimum size=10mm] (L) {}
;
\begin{scope}[on background layer]
\draw[gray] (L.45)--(L.-135) (L.-45)--(L.135);
\path
(L.center) node[left,red]{$+$}
(L.center) node[below,blue]{$-$}
;
\end{scope}
\draw[->] (L)--(alpha);
\draw[->] (R.0)--+(0:1) node[above left]{$v_0$};
\draw[<-] (L.180) node[above left]{$v_s$}--+(180:1);
\draw[->] (R) |- (beta) node[pos=.5,right]{$\beta=\dfrac{R_1}{R_1+R_F}$};
\draw[->] (beta) -| (L) node[pos=1,below right]{$v_f$};
\draw (alpha)--(R);
\end{tikzpicture}
\end{document}
答案2
采用纯 Ti钾Z 并不那么难……而且您可以完全控制方案。通过定义方案元素的通用样式(如下面的 MWE 所示),您可以为所有具有相似内容的图片提供统一的样式,就像这个简单的图片一样:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning,
quotes,
}
\tikzset{control/.style = {% can be used in any tikzpicture in document
arr/.style = {-{Triangle[angle=45:1pt 4]}},
box/.style = {draw, semithick, fill=olive!30,
minimum width=12mm, minimum height=9mm, outer sep=0pt},
dot/.style = {circle, fill, inner sep=1.5pt, outer sep=0pt,
node contents={}},
sum/.style = {circle, draw, semithick, minimum size=6mm, outer sep=0pt,
append after command={\pgfextra{\let\LN\tikzlastnode
\draw (\LN.north west) -- (\LN.south east)
(\LN.north east) -- (\LN.south west);
\node[left =-0.75mm, font=\footnotesize] at (\LN.center) {$+$};
\node[below=-0.50mm, font=\footnotesize] at (\LN.center) {$-$};
}},
node contents={}
},
every edge/.append style = {draw, arr}
}}
\begin{document}
\begin{tikzpicture}[control,
node distance = 4mm and 8mm,
]
\coordinate (in);
\node (n1) [sum, right=of in];
\node (n2) [box, right=of n1] {$\alpha$};
\node (n3) [dot, right=of n2];
\coordinate[right=of n3] (out);
%
\node (n4) [box, below=of n2] {$\beta$};
%
\path (in) edge ["$v_s$"] (n1)
(n1) edge (n2)
(n2) edge [-,"$v_o$"] (n3)
(n3) edge (out);
\draw[arr] (n3) |- (n4) node [pos=0.5,right] {$\beta=\frac{R_1}{R_1+R_\mathrm{F}}$};
\draw[arr] (n4) -| (n1) node [pos=0.9,right] {$v_\mathrm{f}$};
\end{tikzpicture}
\end{document}
答案3
请记住,它是一个框架,它将大量代码总结为命令,允许在几行中绘制复杂的图形,问题当然是理解每个命令的作用,特别是当它是另一种语言时。剩下的就是蛮力,它正在寻找手册,并且由于它具有带有图形结果的代码,您可以逐行检查每个代码的作用,这样您就可以理解部分代码,直到它给我们一个有用的结果; 对于一些无法再搜索或未实现的东西,您可以添加经典代码,但不会浪费一些细节,例如在命令中创建的节点,这里有一个例子,最后的注释行允许找到节点不会丢失。
结果:
使用代码查找节点:
梅威瑟:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\definecolor{color1}{HTML}{C2E1D2}
\usetikzlibrary{calc,arrows.meta}
\usepackage{schemabloc}
\begin{document}
\begin{tikzpicture}
\sbStyleBloc{black!80,very thick,fill=color1,text=black,inner sep=0}% modifies the style of the blocks, it can be updated on each line. page 3 of manual.
\sbStyleLien{>=Triangle,very thick} % modifies the arrow style
\sbEntree{E} %Macro that defines the initial point
\sbComp*{comp}{E} %creates a "comparation" shape and node at a defined distance from the start point E.
\sbRelier[$v_s$]{E}{comp} % Creates an arrow \macroinfrench[arrow_text]{start node name}{end node name}
\sbBloc{block1}{$\alpha$}{comp} % Creates a block \macro{new block node name}{block text}{name of the previous block}
\sbRelier[]{comp}{block1} % Arrow from comp to block1
\sbSortie[4]{S}{block1} % define the output node after block 1 \macro[shift]XXXX
\sbRelier[$v_0$]{block1}{S} % Arrow from block1 to S
\sbDecaleNoeudy[4]{S}{U} % create a node 4 units below S with the name U
\sbBlocr[4]{Fblock1}{$\beta$}{U} % create a feedback block. I have named it Fblock1 \macro[shift, the same value from S]XXXX
\sbRelieryx{block1-S}{Fblock1} % arrow that goes in X and then in Y from the midpoint of block1 y S
\sbRelierxy[$v_f$]{Fblock1}{comp} %
%adding other details using basic tikz code.
\draw[fill=black] (block1-S|-S) circle (1.5pt); % adot in Vo
\draw(comp.135) -- (comp.-45)(comp.45)--(comp.-135); % To draw a comparator symbol.
\draw(U)++(-18pt,0) node[anchor=180]{$\beta=\frac{R_1}{R_1+R_F}$}; % draw a text from a known node
%Some help code to find the nodes:
% \foreach \nodename in {E,comp,block1,S,U,Fblock1}{
% \node[draw, circle,fill=red,minimum size=3pt,inner sep=0,label={[red,label distance=-1pt]-90:\tiny\nodename}] at (\nodename.center){};
% }
\end{tikzpicture}
\end{document}
笔记:
我更喜欢使用独立环境,它允许我创建预编译的 tikz 绘图,然后将其作为图形合并到主文档中,但保留矢量格式,具有能够像任何图像一样以最佳方式缩放和定位它的优势。