TeX - LaTeX Asked on June 18, 2021
Edit:
I have the following code in which I want to change the length of arrows:
documentclass[preview,border=2pt,2pt]{standalone}
usepackage{tikz}
usetikzlibrary{shapes,backgrounds}
usetikzlibrary{calc}
usetikzlibrary{decorations.shapes}
usetikzlibrary{arrows.meta}
tikzset{decorate sep/.style 2 args=
{decorate,decoration={shape backgrounds,shape=circle,shape size=#1,shape sep=#2}}}
tikzset{>={Latex[width=1mm,length=3mm]}}
begin{document}
begin{tikzpicture}
tikzstyle{line} = [line width=.4pt]
tikzstyle{line1} = [->,line width=.2pt]
defr{0.5pt} %define the radius of spot
defax{10.2} %define the length of x-axis
defay{4} %define the length of y-axis
defx{9} %define the length of x
defy{3} %define the height of T=1
defz{0.7} %define the height between the arrow and label
draw[arrows=<->,line width=0.6pt]
(0,ay) coordinate node [below left] {$T$} -- (0,0) coordinate node[below] {$0$} -- (ax, 0) coordinate node [below left] {$x$};
draw[line] (0,y) -- (2,y) -- (4,0);
draw[line] (2,0) -- (4,y) -- (5,y) -- (7,0);
draw[line] (5,0) -- (7,y) -- (x,y);
draw[densely dotted] (x,y) -- (x,0);
node[below] at (2,0) {$1.6$};
node[below] at (4,0) {$1.7$};
node[below] at (5,0) {$1.75$};
node[below] at (7,0) {$1.85$};
node[below] at (x,0) {$2$};
node[left] at (0,y) {$1$};
node[left] at (0,y/2) {$0.5$};
draw[line1] (1.2, y+z) -- (1,y);
node[above] at (1.2, y+z) {$short$};
draw[line1] (4.7, y+z) -- (4.5,y);
node[above] at (4.7, y+z) {$medium$};
draw[line1] (8.2, y+z) -- (8,y);
node[above] at (8.2, y+z) {$tall$};
end{tikzpicture}
end{document}
I want to change length of arrows at the last three lines, e.g. "draw[line1] (1.2, y+z) — (1,y)…", but I am not sure how to do it and need help. Thanks.
Like this?
Instead arrows are used modified pin in nodes placed on path of fuzzy functions. By this the diagram code is much shorter:
documentclass[preview,border=2pt,2pt]{standalone}
usepackage{tikz}
usetikzlibrary{arrows.meta}
begin{document}
begin{tikzpicture}[
aligned pin/.style args = {[#1]#2:#3}% based on https://tex.stackexchange.com/questions/367130
{pin={[pin edge={{Straight Barb[angle=60:2pt 3]}-,
semithick, draw=black, shorten <=2pt},%
coordinate,
label={[%
append after command={%
node[inner sep=0pt, outer sep=0pt,%font=...
at=(tikzlastnode.#2),%
anchor=#1,%
]{#3}%
}%
]center:{}}%
]#2:{}}%
},
pin distance = 7mm,
lbl/.style = {inner sep=0pt,
aligned pin={[south west,xshift=-1ex]60:#1}},
line/.style = {},
]
defr{0.5pt} %define the radius of spot
defax{10.2} %define the length of x-axis
defay{4} %define the length of y-axis
defx{9} %define the length of x
defy{3} %define the height of T=1
defz{0.7} %define the height between the arrow and label
% axis
draw[arrows=<->,line width=0.6pt]
(0,ay) coordinate node [below left] {$T$} -- (0,0) node[below] {$0$}
-- (ax,0) node[below left] {$x$};
% fuzzy functions
draw[line width=.4pt]
(0,y) -- node[lbl=short] {} (2,y) -- (4,0) node[below] {1.7}
(2,0) node[below] {1.6} -- (4,y) -- node[lbl=medium] {} (5,y)
-- (7, 0) node[below] {1.85}
(5,0) node[below] {1.75} -- (7,y) -- node[lbl=tall] {} (x,y);
draw[densely dotted] (x,y) -- (x,0) node[below] {2};
node[left] at (0,y) {$1$};
node[left] at (0,y/2) {$0.5$};
end{tikzpicture}
end{document}
Answered by Zarko on June 18, 2021
Principle to draw shorter line as are follows from given coordinates is use the option shorten > = <amount>
(to make arrows shorten on destination coordinate) and shorten < = <amount>
(to make it shorted on the start coordinate). For illustration serve the following example:
documentclass[preview,border=2pt,2pt]{standalone}
usepackage{tikz}
usetikzlibrary{arrows.meta}
begin{document}
begin{tikzpicture}
draw[shorten > = 1cm, -Straight Barb]
(0,0) -- (2,0);
draw[red] (0,0.2) -- (2,0.2);
end{tikzpicture}
end{document}
This concept you can use at arrow of your choice (i.e. at last three arrows as I use in my first answer, where instead separated explicit drawn arrows and nodes above them are used pin
which is in its style definition shortened for 2pt).
Answered by Zarko on June 18, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP