Guest User

Untitled

a guest
Aug 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.65 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{tikz,amsmath,xcolor}
  3. usetikzlibrary{patterns}
  4. usepackage{pgfplots}
  5. usetikzlibrary{spy}
  6. begin{document}
  7. begin{tikzpicture}[spy using outlines={circle=.5cm, magnification=3, size=.5cm, connect spies}]
  8. tikzset{
  9. hatch distance/.store in=hatchdistance,
  10. hatch distance=10pt,
  11. hatch thickness/.store in=hatchthickness,
  12. hatch thickness=2pt
  13. }
  14.  
  15. makeatletter
  16. pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
  17. {pgfqpoint{0pt}{0pt}}
  18. {pgfqpoint{hatchdistance}{hatchdistance}}
  19. {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
  20. {
  21. pgfsetcolor{tikz@pattern@color}
  22. pgfsetlinewidth{hatchthickness}
  23. pgfpathmoveto{pgfqpoint{0pt}{0pt}}
  24. pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
  25. pgfusepath{stroke}
  26. }
  27. makeatother
  28.  
  29. begin{axis}[
  30. xmin=-4,xmax=4,
  31. xlabel={},
  32. ymin=0,ymax=3,
  33. axis on top,
  34. legend style={legend cell align=right,legend plot pos=right}]
  35. %begin{scope}
  36. %spy[green!70!black,size=2cm] on (2.5,1) in node [fill=white] at (8,2);
  37. %end{scope}
  38. addplot[color=gray,domain=-4:4,samples=100] {(1/pi)*(0.1/((x)^2+0.01)};
  39.  
  40. addplot+[color=gray,mark=none,
  41. domain=-4:4,
  42. samples=100,
  43. pattern=flexible hatch,
  44. area legend,
  45. pattern color=orange]{(1/pi)*(0.1/((x)^2+0.01)} closedcycle;
  46.  
  47.  
  48. end{axis}
  49. end{tikzpicture}
  50. end{document}
  51.  
  52. % used PGFPlots v1.16
  53. documentclass[border=5pt]{standalone}
  54. usepackage{pgfplots}
  55. usetikzlibrary{
  56. patterns,
  57. spy,
  58. }
  59. tikzset{
  60. hatch distance/.store in=hatchdistance,
  61. hatch distance=10pt,
  62. hatch thickness/.store in=hatchthickness,
  63. hatch thickness=2pt,
  64. }
  65.  
  66. makeatletter
  67. pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
  68. {pgfqpoint{0pt}{0pt}}
  69. {pgfqpoint{hatchdistance}{hatchdistance}}
  70. {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
  71. {
  72. pgfsetcolor{tikz@pattern@color}
  73. pgfsetlinewidth{hatchthickness}
  74. pgfpathmoveto{pgfqpoint{0pt}{0pt}}
  75. pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
  76. pgfusepath{stroke}
  77. }
  78. makeatother
  79. begin{document}
  80. begin{tikzpicture}[
  81. % -------------------------------------------------------------------------
  82. % (only needed for the spy stuff)
  83. spy using outlines={
  84. circle,
  85. magnification=10,
  86. size=20mm,
  87. connect spies,
  88. },
  89. % -------------------------------------------------------------------------
  90. ]
  91. begin{axis}[
  92. xmin=-4,
  93. xmax=4,
  94. ymin=0,
  95. ymax=3.5, % <-- (adapted)
  96. axis on top,
  97. % (moved common options here)
  98. domain=-4:4,
  99. % -----------------------------
  100. % increased `samples' ...
  101. samples=1001,
  102. % ... and added `smooth'
  103. smooth,
  104. % -----------------------------
  105. ]
  106.  
  107. addplot [
  108. color=gray,
  109. pattern=flexible hatch,
  110. pattern color=orange,
  111. % (simplified and corrected unbalanced braces)
  112. ] {(1/pi) * 0.1/(x^2+0.01)};
  113.  
  114. % ---------------------------------------------------------------------
  115. % (only needed for the spy stuff)
  116. coordinate (spy) at (axis cs:-2.25,2.5);
  117. coordinate (A) at (axis cs:0,3.15);
  118. spy on (A) in node at (spy);
  119. % ---------------------------------------------------------------------
  120.  
  121. end{axis}
  122. end{tikzpicture}
  123. end{document}
  124.  
  125. documentclass{article}
  126. usepackage{tikz,amsmath,xcolor}
  127. usetikzlibrary{patterns}
  128. usepackage{pgfplots}
  129. usetikzlibrary{spy}
  130. begin{document}
  131. begin{tikzpicture}[spy using outlines={circle=.5cm, magnification=3, size=.5cm, connect spies}]
  132. tikzset{
  133. hatch distance/.store in=hatchdistance,
  134. hatch distance=10pt,
  135. hatch thickness/.store in=hatchthickness,
  136. hatch thickness=2pt
  137. }
  138.  
  139. makeatletter
  140. pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
  141. {pgfqpoint{0pt}{0pt}}
  142. {pgfqpoint{hatchdistance}{hatchdistance}}
  143. {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
  144. {
  145. pgfsetcolor{tikz@pattern@color}
  146. pgfsetlinewidth{hatchthickness}
  147. pgfpathmoveto{pgfqpoint{0pt}{0pt}}
  148. pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
  149. pgfusepath{stroke}
  150. }
  151. makeatother
  152.  
  153. begin{axis}[
  154. xmin=-4,xmax=4,
  155. xlabel={},
  156. % ymin=0,ymax=3,
  157. axis on top,
  158. legend style={legend cell align=right,legend plot pos=right}]
  159. %begin{scope}
  160. %spy[green!70!black,size=2cm] on (2.5,1) in node [fill=white] at (8,2);
  161. %end{scope}
  162. addplot[color=gray,domain=-4:4,samples=100] {(1/pi)*(0.1/((x)^2+0.01)};
  163.  
  164. addplot+[color=gray,mark=none,
  165. domain=-4:4,
  166. samples=100,
  167. pattern=flexible hatch,
  168. area legend,
  169. samples=10000,
  170. pattern color=orange]{(1/pi)*(0.1/((x)^2+0.01)} closedcycle;
  171.  
  172.  
  173. end{axis}
  174. end{tikzpicture}
  175. end{document}
  176.  
  177. documentclass{article}
  178. usepackage{tikz,amsmath,xcolor}
  179. usetikzlibrary{patterns}
  180. usepackage{pgfplots}
  181. usetikzlibrary{spy}
  182. begin{document}
  183. begin{tikzpicture}[spy using outlines={circle=.5cm, magnification=3, size=.5cm, connect spies}]
  184. tikzset{
  185. hatch distance/.store in=hatchdistance,
  186. hatch distance=10pt,
  187. hatch thickness/.store in=hatchthickness,
  188. hatch thickness=2pt
  189. }
  190.  
  191. makeatletter
  192. pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
  193. {pgfqpoint{0pt}{0pt}}
  194. {pgfqpoint{hatchdistance}{hatchdistance}}
  195. {pgfpoint{hatchdistance-1pt}{hatchdistance-1pt}}%
  196. {
  197. pgfsetcolor{tikz@pattern@color}
  198. pgfsetlinewidth{hatchthickness}
  199. pgfpathmoveto{pgfqpoint{0pt}{0pt}}
  200. pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
  201. pgfusepath{stroke}
  202. }
  203. makeatother
  204.  
  205. begin{axis}[
  206. xmin=-4,xmax=4,
  207. xlabel={},
  208. % ymin=0,ymax=3,
  209. axis on top,
  210. legend style={legend cell align=right,legend plot pos=right}]
  211. %begin{scope}
  212. %spy[green!70!black,size=2cm] on (2.5,1) in node [fill=white] at (8,2);
  213. %end{scope}
  214. addplot[color=gray,domain=-4:4,samples=101,smooth] {(1/pi)*(0.1/((x)^2+0.01)};
  215.  
  216. addplot+[color=gray,mark=none,
  217. domain=-4:4,
  218. samples=101,
  219. pattern=flexible hatch,
  220. area legend,
  221. pattern color=orange]{(1/pi)*(0.1/((x)^2+0.01)} closedcycle;
  222.  
  223.  
  224. end{axis}
  225. end{tikzpicture}
  226. end{document}
  227.  
  228. declare function={
  229. % outer bound
  230. b=4;
  231. % function to use for the nonlinear spacing
  232. Y(x) = exp(x);
  233. % Y(x) = (x)^2; % alternative nonlinear spacing function
  234. % rescale samples to domain=-b:b
  235. X(x) = (x >= 0) * (b*(Y(x) - Y(0))/(Y(b) - Y(0)))
  236. - (x < 0) * (b*(Y(-x) - Y(0))/(Y(b) - Y(0)));
  237. % Lorentzian function
  238. L(x,xz,ep) = (1/pi) * (ep/((x-xz)^2 + (ep)^2));
  239. },
  240.  
  241. addplot [
  242. color=gray,
  243. pattern=flexible hatch,
  244. pattern color=orange,
  245. % (simplified and corrected unbalanced braces)
  246. ] ({X(x)},{L(X(x),0,0.1)});
  247.  
  248. documentclass[border=5pt]{standalone}
  249. usepackage{pgfplots}
  250. usetikzlibrary{
  251. patterns,
  252. spy,
  253. }
  254. tikzset{
  255. hatch distance/.store in=hatchdistance,
  256. hatch distance=10pt,
  257. hatch thickness/.store in=hatchthickness,
  258. hatch thickness=2pt,
  259. }
  260.  
  261. makeatletter
  262. pgfdeclarepatternformonly[hatchdistance,hatchthickness]{flexible hatch}
  263. {pgfqpoint{0pt}{0pt}}
  264. {pgfqpoint{hatchdistance}{hatchdistance}}
  265. {pgfpoint{hatchdistance-2pt}{hatchdistance-2pt}}%
  266. {
  267. pgfsetcolor{tikz@pattern@color}
  268. pgfsetlinewidth{hatchthickness}
  269. pgfpathmoveto{pgfqpoint{0pt}{0pt}}
  270. pgfpathlineto{pgfqpoint{hatchdistance}{hatchdistance}}
  271. pgfusepath{stroke}
  272. }
  273. makeatother
  274. begin{document}
  275. begin{tikzpicture}[
  276. % -------------------------------------------------------------------------
  277. % declare functions for nonlinear spacing, and for the Lorentzian
  278. declare function={
  279. % outer bound
  280. b=4;
  281. % function to use for the nonlinear spacing
  282. Y(x) = exp(x);
  283. % Y(x) = (x)^2; % alternative nonlinear spacing function
  284. % rescale samples to domain=-b:b
  285. X(x) = (x >= 0) * (b*(Y(x) - Y(0))/(Y(b) - Y(0)))
  286. - (x < 0) * (b*(Y(-x) - Y(0))/(Y(b) - Y(0)));
  287. % Lorentzian function
  288. L(x,xz,ep) = (1/pi) * (ep/((x-xz)^2 + (ep)^2));
  289. },
  290. % -------------------------------------------------------------------------
  291. % (only needed for the spy stuff)
  292. spy using outlines={
  293. circle,
  294. magnification=10,
  295. size=20mm,
  296. connect spies,
  297. },
  298. % -------------------------------------------------------------------------
  299. ]
  300. begin{axis}[
  301. xmin=-4,
  302. xmax=4,
  303. ymin=0,
  304. ymax=3.5, % <-- (adapted)
  305. axis on top,
  306. % (moved common options here)
  307. domain=-b:b,
  308. % -----------------------------
  309. % increased `samples' ...
  310. samples=51,
  311. % ... and added `smooth'
  312. smooth,
  313. ]
  314.  
  315. addplot [
  316. color=gray,
  317. pattern=flexible hatch,
  318. pattern color=orange,
  319. % (simplified and corrected unbalanced braces)
  320. ] ({X(x)},{L(X(x),0,0.1)});
  321.  
  322. % ---------------------------------------------------------------------
  323. % (only needed for the spy stuff)
  324. coordinate (spy) at (axis cs:-2.25,2.5);
  325. coordinate (A) at (axis cs:0,3.15);
  326. spy on (A) in node at (spy);
  327. ---------------------------------------------------------------------
  328.  
  329. end{axis}
  330.  
  331. end{tikzpicture}
  332. end{document}
Add Comment
Please, Sign In to add comment