Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{article}
- usepackage{tikz,amsmath,xcolor}
- usetikzlibrary{patterns}
- usepackage{pgfplots}
- usetikzlibrary{spy}
- begin{document}
- begin{tikzpicture}[spy using outlines={circle=.5cm, magnification=3, size=.5cm, connect spies}]
- tikzset{
- hatch distance/.store in=hatchdistance,
- hatch distance=10pt,
- hatch thickness/.store in=hatchthickness,
- hatch thickness=2pt
- }
- makeatletter
- pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
- {pgfqpoint{0pt}{0pt}}
- {pgfqpoint{hatchdistance}{hatchdistance}}
- {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
- {
- pgfsetcolor{tikz@pattern@color}
- pgfsetlinewidth{hatchthickness}
- pgfpathmoveto{pgfqpoint{0pt}{0pt}}
- pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
- pgfusepath{stroke}
- }
- makeatother
- begin{axis}[
- xmin=-4,xmax=4,
- xlabel={},
- ymin=0,ymax=3,
- axis on top,
- legend style={legend cell align=right,legend plot pos=right}]
- %begin{scope}
- %spy[green!70!black,size=2cm] on (2.5,1) in node [fill=white] at (8,2);
- %end{scope}
- addplot[color=gray,domain=-4:4,samples=100] {(1/pi)*(0.1/((x)^2+0.01)};
- addplot+[color=gray,mark=none,
- domain=-4:4,
- samples=100,
- pattern=flexible hatch,
- area legend,
- pattern color=orange]{(1/pi)*(0.1/((x)^2+0.01)} closedcycle;
- end{axis}
- end{tikzpicture}
- end{document}
- % used PGFPlots v1.16
- documentclass[border=5pt]{standalone}
- usepackage{pgfplots}
- usetikzlibrary{
- patterns,
- spy,
- }
- tikzset{
- hatch distance/.store in=hatchdistance,
- hatch distance=10pt,
- hatch thickness/.store in=hatchthickness,
- hatch thickness=2pt,
- }
- makeatletter
- pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
- {pgfqpoint{0pt}{0pt}}
- {pgfqpoint{hatchdistance}{hatchdistance}}
- {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
- {
- pgfsetcolor{tikz@pattern@color}
- pgfsetlinewidth{hatchthickness}
- pgfpathmoveto{pgfqpoint{0pt}{0pt}}
- pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
- pgfusepath{stroke}
- }
- makeatother
- begin{document}
- begin{tikzpicture}[
- % -------------------------------------------------------------------------
- % (only needed for the spy stuff)
- spy using outlines={
- circle,
- magnification=10,
- size=20mm,
- connect spies,
- },
- % -------------------------------------------------------------------------
- ]
- begin{axis}[
- xmin=-4,
- xmax=4,
- ymin=0,
- ymax=3.5, % <-- (adapted)
- axis on top,
- % (moved common options here)
- domain=-4:4,
- % -----------------------------
- % increased `samples' ...
- samples=1001,
- % ... and added `smooth'
- smooth,
- % -----------------------------
- ]
- addplot [
- color=gray,
- pattern=flexible hatch,
- pattern color=orange,
- % (simplified and corrected unbalanced braces)
- ] {(1/pi) * 0.1/(x^2+0.01)};
- % ---------------------------------------------------------------------
- % (only needed for the spy stuff)
- coordinate (spy) at (axis cs:-2.25,2.5);
- coordinate (A) at (axis cs:0,3.15);
- spy on (A) in node at (spy);
- % ---------------------------------------------------------------------
- end{axis}
- end{tikzpicture}
- end{document}
- documentclass{article}
- usepackage{tikz,amsmath,xcolor}
- usetikzlibrary{patterns}
- usepackage{pgfplots}
- usetikzlibrary{spy}
- begin{document}
- begin{tikzpicture}[spy using outlines={circle=.5cm, magnification=3, size=.5cm, connect spies}]
- tikzset{
- hatch distance/.store in=hatchdistance,
- hatch distance=10pt,
- hatch thickness/.store in=hatchthickness,
- hatch thickness=2pt
- }
- makeatletter
- pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
- {pgfqpoint{0pt}{0pt}}
- {pgfqpoint{hatchdistance}{hatchdistance}}
- {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
- {
- pgfsetcolor{tikz@pattern@color}
- pgfsetlinewidth{hatchthickness}
- pgfpathmoveto{pgfqpoint{0pt}{0pt}}
- pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
- pgfusepath{stroke}
- }
- makeatother
- begin{axis}[
- xmin=-4,xmax=4,
- xlabel={},
- % ymin=0,ymax=3,
- axis on top,
- legend style={legend cell align=right,legend plot pos=right}]
- %begin{scope}
- %spy[green!70!black,size=2cm] on (2.5,1) in node [fill=white] at (8,2);
- %end{scope}
- addplot[color=gray,domain=-4:4,samples=100] {(1/pi)*(0.1/((x)^2+0.01)};
- addplot+[color=gray,mark=none,
- domain=-4:4,
- samples=100,
- pattern=flexible hatch,
- area legend,
- samples=10000,
- pattern color=orange]{(1/pi)*(0.1/((x)^2+0.01)} closedcycle;
- end{axis}
- end{tikzpicture}
- end{document}
- documentclass{article}
- usepackage{tikz,amsmath,xcolor}
- usetikzlibrary{patterns}
- usepackage{pgfplots}
- usetikzlibrary{spy}
- begin{document}
- begin{tikzpicture}[spy using outlines={circle=.5cm, magnification=3, size=.5cm, connect spies}]
- tikzset{
- hatch distance/.store in=hatchdistance,
- hatch distance=10pt,
- hatch thickness/.store in=hatchthickness,
- hatch thickness=2pt
- }
- makeatletter
- pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
- {pgfqpoint{0pt}{0pt}}
- {pgfqpoint{hatchdistance}{hatchdistance}}
- {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
- {
- pgfsetcolor{tikz@pattern@color}
- pgfsetlinewidth{hatchthickness}
- pgfpathmoveto{pgfqpoint{0pt}{0pt}}
- pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
- pgfusepath{stroke}
- }
- makeatother
- begin{axis}[
- xmin=-4,xmax=4,
- xlabel={},
- % ymin=0,ymax=3,
- axis on top,
- legend style={legend cell align=right,legend plot pos=right}]
- %begin{scope}
- %spy[green!70!black,size=2cm] on (2.5,1) in node [fill=white] at (8,2);
- %end{scope}
- addplot[color=gray,domain=-4:4,samples=101,smooth] {(1/pi)*(0.1/((x)^2+0.01)};
- addplot+[color=gray,mark=none,
- domain=-4:4,
- samples=101,
- pattern=flexible hatch,
- area legend,
- pattern color=orange]{(1/pi)*(0.1/((x)^2+0.01)} closedcycle;
- end{axis}
- end{tikzpicture}
- end{document}
- declare function={
- % outer bound
- b=4;
- % function to use for the nonlinear spacing
- Y(x) = exp(x);
- % Y(x) = (x)^2; % alternative nonlinear spacing function
- % rescale samples to domain=-b:b
- X(x) = (x >= 0) * (b*(Y(x) - Y(0))/(Y(b) - Y(0)))
- - (x < 0) * (b*(Y(-x) - Y(0))/(Y(b) - Y(0)));
- % Lorentzian function
- L(x,xz,ep) = (1/pi) * (ep/((x-xz)^2 + (ep)^2));
- },
- addplot [
- color=gray,
- pattern=flexible hatch,
- pattern color=orange,
- % (simplified and corrected unbalanced braces)
- ] ({X(x)},{L(X(x),0,0.1)});
- documentclass[border=5pt]{standalone}
- usepackage{pgfplots}
- usetikzlibrary{
- patterns,
- spy,
- }
- tikzset{
- hatch distance/.store in=hatchdistance,
- hatch distance=10pt,
- hatch thickness/.store in=hatchthickness,
- hatch thickness=2pt,
- }
- makeatletter
- pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
- {pgfqpoint{0pt}{0pt}}
- {pgfqpoint{hatchdistance}{hatchdistance}}
- {pgfpoint{hatchdistance-2pt}{hatchdistance-2pt}}%
- {
- pgfsetcolor{tikz@pattern@color}
- pgfsetlinewidth{hatchthickness}
- pgfpathmoveto{pgfqpoint{0pt}{0pt}}
- pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
- pgfusepath{stroke}
- }
- makeatother
- begin{document}
- begin{tikzpicture}[
- % -------------------------------------------------------------------------
- % declare functions for nonlinear spacing, and for the Lorentzian
- declare function={
- % outer bound
- b=4;
- % function to use for the nonlinear spacing
- Y(x) = exp(x);
- % Y(x) = (x)^2; % alternative nonlinear spacing function
- % rescale samples to domain=-b:b
- X(x) = (x >= 0) * (b*(Y(x) - Y(0))/(Y(b) - Y(0)))
- - (x < 0) * (b*(Y(-x) - Y(0))/(Y(b) - Y(0)));
- % Lorentzian function
- L(x,xz,ep) = (1/pi) * (ep/((x-xz)^2 + (ep)^2));
- },
- % -------------------------------------------------------------------------
- % (only needed for the spy stuff)
- spy using outlines={
- circle,
- magnification=10,
- size=20mm,
- connect spies,
- },
- % -------------------------------------------------------------------------
- ]
- begin{axis}[
- xmin=-4,
- xmax=4,
- ymin=0,
- ymax=3.5, % <-- (adapted)
- axis on top,
- % (moved common options here)
- domain=-b:b,
- % -----------------------------
- % increased `samples' ...
- samples=51,
- % ... and added `smooth'
- smooth,
- ]
- addplot [
- color=gray,
- pattern=flexible hatch,
- pattern color=orange,
- % (simplified and corrected unbalanced braces)
- ] ({X(x)},{L(X(x),0,0.1)});
- % ---------------------------------------------------------------------
- % (only needed for the spy stuff)
- coordinate (spy) at (axis cs:-2.25,2.5);
- coordinate (A) at (axis cs:0,3.15);
- spy on (A) in node at (spy);
- ---------------------------------------------------------------------
- end{axis}
- end{tikzpicture}
- end{document}
Add Comment
Please, Sign In to add comment