TeX - LaTeX Asked by Pleba on April 3, 2021
I am trying to draw this kind of image, which is the representation of a normal domain with respect to the x-axis, but I am not very skilled at LaTeX. Is there anyone who knows how to do that?
This is certainly not the most elegant solution, but can perhaps serve as a starting point.
I used pgfplots
as a basis to draw the coordinate system as well as the "normal domain". Everything is drawn within a single axis
block. The boundary lines at the top and bottom are created using the curve through
interpolation functionality from the hobby
tikzlibrary. Therefore I defined the coordinates (A) to (F) (lower boundary, from left to right) and (G) to (L) (upper boundary, from right to left). Of course, you can adjust the coordinates to your personal preference. For filling the domain I used pattern=north east lines
from the tikzlibrary patterns
.
Here is the complete code:
documentclass[tikz, border=5pt]{standalone}
usepackage{pgfplots}
usetikzlibrary{hobby, patterns}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[axis lines=center,
xmin=-1, xmax=8, ymin=-1, ymax=8,
line width=1pt,
xtick={2, 6}, xticklabels={$a$, $b$},
ytick={2, 6}, yticklabels={},
xlabel={normalsize $x$}, xlabel style={yshift=-.5*pgfkeysvalueof{/pgfplots/major tick length},anchor=north east,inner xsep=0pt},
ylabel={normalsize $y$}, ylabel style={xshift=-.5*pgfkeysvalueof{/pgfplots/major tick length}, anchor=north east, inner ysep=0pt}
]
% define the coordinates (interpolation points) for the lower boundary
coordinate (A) at (2,2);
coordinate (B) at (2.2,2.3);
coordinate (C) at (3,1.9);
coordinate (D) at (4,2.3);
coordinate (E) at (5,1.8);
coordinate (F) at (6,2);
% define the coordinates (interpolation points) for the upper boundary
coordinate (G) at (6,6);
coordinate (H) at (5,6.2);
coordinate (I) at (4,5.8);
coordinate (J) at (3,6.1);
coordinate (K) at (2.2,5.7);
coordinate (L) at (2,6);
% draw the domain as a single closed curved that interpolates through A, B, C, D, E and F runs straight to G interpolates through H, I, J, K and L and runs again straight to A
draw[pattern=north east lines, pattern color=red] (A) to [curve through = {(B) (C) (D) (E)}] (F) to (G) to [curve through = {(H) (I) (J) (K)}] (L) to (A);
% draw the dashed red lines
draw[red, dashed] (2,0) -- (A);
draw[red, dashed] (6,0) -- (F);
% add the function name to the upper and lower boundary
node at (4,6.5) {$beta (x)$};
node at (4,1.5) {$alpha (x)$};
end{axis}
end{tikzpicture}
end{document}
And this is the result:
Correct answer by Nico on April 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP