TransWikia.com

Is there an easy way to encapsulate a tikz drawing using "plot" commands as part of a node style?

TeX - LaTeX Asked by Jason S on December 1, 2020

I want to overlay a function on top of a block, as shown in "bounded reciprocal" below.

Is there an easy way to do this? Someone had referred me to the approach in my PIctrl shape below
but I am not sure how to do something similar with a plot command.

enter image description here

documentclass[border=2mm]{standalone}
usepackage{tikz}
usetikzlibrary{positioning, calc}
begin{document}
begin{tikzpicture}[
    PIctrl/.style={
        append after command={
             pgfextra{letlastnodetikzlastnode} 
            ($(lastnode.south west) + (0.5em,0.5em)$) edge
            ($(lastnode.south east) + (-0.5em,0.5em)$) edge
            ($(lastnode.north west) + (0.5em,-0.5em)$) edge[-, very thick]
            ($(lastnode.north west) + (0.5em,-1.5em)$)
            ($(lastnode.north west) + (0.5em,-1.5em)$) edge[-, very thick]
            ($(lastnode.north east) + (-0.8em,-0.8em)$)
        }
    },
    blockheight/.style = {
        minimum height=10mm
    },
    block/.style={
        draw,
        % The shape:
        rectangle, minimum size=6mm, minimum width=12mm,
        blockheight,
        node distance=5mm,
    },
    every node/.style = {font=sffamily},
    every label/.style={
        font=sffamilyscriptsize
    },
    >=latex
      ]
      
node[block, PIctrl, label={below:PI controller}] (block1) at (0,0) {};

node[block, right=10mm of block1, label={below:bounded reciprocal}] (block2) {};
coordinate (recip0) at ($(block2.south west)+(1.5mm,1.5mm)$);
draw[shift=(recip0)] (0,0) -- (0,7mm);
draw[shift=(recip0)] (0,0) -- (9mm,0);
draw[shift=(recip0),
           scale=0.5, domain=0.17:0.55, smooth, variable=x, 
           black, dash pattern = {on 0.5mm off 0.5mm}, dash phase=0.9mm ] plot ({x}, {0.25/x});
draw[shift=(recip0),
           scale=0.5, domain=0:1.8, samples=40, smooth, variable=x, 
           black, thick ] plot ({x}, {0.25/max(x,0.3)});

draw [->] (block1) -- (block2);


end{tikzpicture}
end{document}

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