l
play

L A T EX Graphics with PSTricks This presentation is also - PDF document

L A T EX Graphics with PSTricks This presentation is also available online. Please visit my home page and follow the links. http://www.math.msu.edu/ hensh 1. Resources (a) ImageMagick is a collection of (free) image manipulation tools. You


  1. L A T EX Graphics with PSTricks This presentation is also available online. Please visit my home page and follow the links. http://www.math.msu.edu/ ∼ hensh 1. Resources (a) ImageMagick is a collection of (free) image manipulation tools. You can find out more by visiting http://www.imagemagick.com (b) The L A T EX Graphics Companion. - Paperback: 608 pages - Publisher: Addison-Wesley Pub Co; 1st edition (April 15, 1997) - ISBN: 0201854694 (c) The L T EX Graphics Companion (2nd Edition). A - Paperback: 976 pages - Publisher: Addison-Wesley Professional; 2 edition (August 12, 2007) - ISBN: 0321508920 (d) PSTricks: Graphics and PostScript for T EX and L A T EX. - Paperback: 912 pages - Publisher: UIT Cambridge Ltd. (September 1, 2011) - ISBN: 1906860130 (e) The PSTricks web site. https://www.tug.org/PSTricks (f) PostScript(R) Language Tutorial and Cookbook (also called the “The Blue Book”) - Paperback: 256 pages - Publisher: Addison-Wesley Professional (January 1, 1985) - ISBN: 0201101793 2. PSTricks 1

  2. (a) We start with some examples. 30 25 20 y = x 2 15 10 5 − 5 − 4 − 3 − 2 − 1 1 2 3 4 5 Figure 1: Graphing simple functions. r - θ Coordinate System 3 2 r = 1 + 2 sin θ 1 1 2 3 4 5 6 − 1 Figure 2: Graphing with some fancy effects. 2

  3. b x - y Coordinate System r = 1 + 2 sin θ 3 2 1 − 2 − 1 1 2 Figure 3: Polar Graphs P (2 , 6) 1 Figure 4: Area between two curves. 3

  4. � u � v Figure 5: A pair of vectors � v � u u + � � v � v Figure 6: Vector addition with a grid. 4

  5. b b b (c) π 12 1 (b) (a) Figure 7: Polar Grid z y x Figure 8: Sketching a cylinder. 5

  6. b b z y x Figure 9: Position Vectors Figure 10: Level Curves 6

  7. b r = g 2 ( θ ) r = a θ = β r = g 1 ( θ ) θ = α Figure 11: Polar Area z x y Figure 12: A Tangent Line 7

  8. b xy = c c = 0 . 01 c = 0 . 025 1 c = 0 . 05 c = 0 . 075 c = 0 . 1 P 0 c = 0 . 11 − 1 1 c = 0 . 125 − 1 Figure 13: Lagrange Multipliers 8

  9. z x y Figure 14: Exposed Solid 9

  10. z y x Figure 15: Surface Integrals z y x Figure 16: Distorted Surface 10

  11. Figure 17: Fractals 11

  12. Isn’t Isn’t Tricks PSTricks Isn’t PSTric lots of fun ts of fun lots of 2013 2013 ! Figure 18: Lens Effects 2 C 1 − 1 1 2 3 − 1 Increasing Vector Magnitude Figure 19: Vector Field 12

  13. 3. PSTricks To use PSTricks you must include the following lines in the preamble of your document. \usepackage{pst-eucl} 1 \usepackage{calc} 2 \usepackage{pst-3dplot}% 3 \usepackage{pst-grad} 4 \usepackage{pst-plot,pst-math,pstricks-add}% 5 \usepackage{pst-all} 6 %\RequirePackage{pst-xkey} 7 We should mention that there have been some incompatibilities between the pstcol package (used by PSTricks) and the graphics packages mentioned above. Using colors with PSTricks is similar to what has already been discussed. The real power of the PSTricks package is the ability to create graphics using L A T EX-like syntax. 13

  14. (a) Preliminaries PSTricks provides users with the capability to draw using the familiar syntax of L A T EX. \psline[linecolor=blue,linewidth=1.25pt](-3,1)(2,2) 1 The previous example might be easier to understand if we include more detail in the sketch. Thus \showgrid 1 \psline[linecolor=blue,linewidth=1.25pt,arrowscale=2]{->}(-3,1)(2,2) 2 \newpsobject{showgrid}{psgrid}{% 1 gridlabels=0pt% 2 ,griddots=0% 3 ,gridwidth=0.5pt% 4 ,gridcolor=gray% 5 ,subgriddiv=0% 6 ,subgridwidth=0.25pt% 7 ,subgridcolor=red} 8 14

  15. b b b b (b) Basic Graphics Objects Here’s a curve. Notice that the points used can be turned on (as shown) or off. %\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 \pscurve[linecolor=red,linewidth=1.5pt,showpoints=true]% 3 (\xmin,1)(0,2)(3,1)(\xmax,\ymax) 4 %\end{pspicture} 5 where the values \xmin, \ymin, etc. have been defined previously as \def\xmin{-6}\def\xmax{6} 1 \def\ymin{-6}\def\ymax{6} 2 15

  16. b b b b b We begin by setting the default unit(s) in PSTricks using the command \psset{unit=1cm} . This is actually the default value. %\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 \pscurve[linecolor=red,linewidth=1.5pt,showpoints=true] 3 (\xmin,1)(0,2)(3,1)(\xmax,\ymax) 4 \psbezier[style=myCurveStyle,linecolor=green]{-}% 5 (-4,1)(-2,3)(1,-4)(5,5) 6 %\end{pspicture} 7 There are built-in shapes %\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 \psellipse[linecolor=blue,linewidth=1.5pt] 3 (1,0)(1,1.5) 4 \psdots[linecolor=red,linewidth=1.25pt](0,0) 5 \SpecialCoor 6 \uput{6pt}[180](0,0){$(0,0)$} 7 \NormalCoor 8 %\end{pspicture} 9 (0 , 0) 16

  17. Here is a circle centered at ( − 2 , − 1) of radius 2. %\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 \pscircle[linecolor=red,linewidth=1.5pt] 3 (-2,-1){2} 4 %\end{pspicture} 5 Here is the same object filled-in and clipped. %\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 \psclip{\myframe(\xmin,\ymin)(\xmax,\ymax)} 3 \pscircle*[linecolor=red,linewidth=1.5pt] 4 (-2,-1){2} 5 \endpsclip 6 \pswedge*[linecolor=white](-2,-1){1}{15}{105} 7 %\end{pspicture} 8 17

  18. Finally, we plot some functions. To do this we’ll use some custom macros that give the user better control over the coordinate system. \begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 \pstVerb{% 3 /f@ {dup mul} def % x^2 4 } 5 %%%%%%%%%%%%%%%%%%%% 6 %% Axes and Ticks %% 7 %%%%%%%%%%%%%%%%%%%% 8 \myaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax) 9 \xTickMarks{\xmin}{\xmax}{1} 10 \yTickMarks{\ymin}{\ymax}{5} 11 %%%%%%%%%%%%%%%%%%%%%%% 12 %% Graphical Objects %% 13 %%%%%%%%%%%%%%%%%%%%%%% 14 \psclip{\myframe(\xmin,\ymin)(\xmax,\ymax)} 15 \psplot[style=myPlotStyle] 16 {\xmin}{\xmax}{x f@} 17 \endpsclip 18 %%%%%%%%%%%% 19 %% Labels %% 20 %%%%%%%%%%%% 21 \SpecialCoor 22 \uput{6pt}[0](!3 dup f@){$y=x^2$} 23 \NormalCoor 24 \end{pspicture} 25 18

  19. 40 35 30 25 20 15 10 y = x 2 5 0 − 5 − 6 − 5 − 4 − 3 − 2 − 1 0 1 2 3 4 5 6 And again, using better grid controls. 40 y = x 2 35 30 25 20 15 10 5 0 − 5 − 6 − 5 − 4 − 3 − 2 − 1 0 1 2 3 4 5 6 19

  20. Here’s something useful for integration theory. Use the sketch to estimate the integral below. � 5 1 x dx 2 y = 1 1 x 1 2 3 4 5 6 20

  21. Here is the code \def\xmin{0}\def\xmax{6} 1 \def\ymin{0}\def\ymax{1} 2 \def\dommin{\xmin}\def\dommax{\xmax} 3 \VR{3in}{2.5in} 4 5 \newpsobject{newgrid}{psgrid}{% 6 gridlabels=0pt% 7 ,griddots=0% 8 ,gridwidth=0.5pt% 9 ,gridcolor=gray% 10 ,subgriddiv=4% 11 ,subgridwidth=0.25pt% 12 ,subgridcolor=red} 13 \begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 14 \newgrid 15 %%%%%%%%%%%%%%%%%%%% 16 %% Axes and Ticks %% 17 %%%%%%%%%%%%%%%%%%%% 18 \SpecialCoor 19 %% Labels go here 20 \rput[lr](!\xmax\space\xmax\space\xmin\space sub 15 div sub 21 \ymax\space\ymax\space\ymin\space sub 25 div sub){$y=\dfrac{1}{x}$} 22 \NormalCoor 23 \myaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax) 24 %% Change these as needed. #1 - start, #2 - end, #3 - increment 25 \xTickMarks{\xmin}{\xmax}{1} 26 \yTickMarks{\ymin}{\ymax}{1} 27 \psclip{\psframe(\xmin,\ymin)(\xmax,\ymax)} 28 %% Graphing directives go here, e.g., 29 \psplot[style=myPlotStyle] 30 {0.1}{\xmax}{1 x div} 31 \endpsclip 32 \SpecialCoor 33 \psline[fillstyle=crosshatch]{-}(3,0)(3.5,0)(!3.5 1 3 34 div)(!3 1 3 div)(3,0) 35 \psline[fillstyle=crosshatch]{-}(3.5,0)(4,0)(!4 1 3.5 36 div)(!3.5 1 3.5 div)(3.5,0) 37 \psline[fillstyle=crosshatch]{-}(4,0)(4.5,0)(!4.5 1 4 38 div)(!4 1 4 div)(4,0) 39 \psline[fillstyle=crosshatch]{-}(4.5,0)(5,0)(!5 1 4.5 40 div)(!4.5 1 4.5 div)(4.5,0) 41 \NormalCoor 42 \end{pspicture} 43 21

  22. (c) Plotting Data from a File Suppose that you wish to plot the following data. 0, 0 0.0628, 0.06279 0.1256, 0.12533 ... ... The following code does the trick. %\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax) 1 \showgrid 2 %% Axes and Ticks %% 3 \myaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax) 4 %% Graphical Objects %% 5 \psclip{\myframe(\xmin,\ymin)(\xmax,\ymax)} 6 \fileplot{plotData.txt} 7 \endpsclip 8 \SpecialCoor 9 \rput[lt](!\xmax\space\xmin\space sub 15 div 10 \ymax\space\ymax\space\ymin\space sub 25 div sub){$y=\sin x$} 11 \NormalCoor 12 %\end{pspicture} 13 y = sin x 22

  23. 4. Several examples from geometry. A B 30 ◦ 80 ◦ E C D B C A 40 ◦ 80 ◦ 77 ◦ 60 ◦ 50 ◦ 53 ◦ D E P T V R A C B E 23

  24. 5. A few exotic tricks. (a) A vector field. 2 1 − 2 − 1 1 2 − 1 − 2 24

  25. (b) An ice-cream cone. z z y y x x z y x 25

  26. b b (c) A level surface. f ( x, y, z ) = c S R ∆ P k ∇ f ( x k , y k , z k ) p u k v k ∆ σ k p ∆ A k 26

  27. Figure 20: Fractals - Sierpinski Triangle z y x Figure 21: Sphere The equation of a sphere with radius r centered at the origin is x 2 + y 2 + z 2 = r 2 27

  28. y 160 80 x 0 20 · 10 3 40 · 10 3 60 · 10 3 80 · 10 3 100 · 10 3 − 80 − 160 Figure 22: Brownian Motion 4 3 2 1 − 5 − 4 − 3 − 2 − 1 1 2 3 4 − 1 − 2 Figure 23: Not Sure What to Call This 28

  29. Figure 24: Tessellations?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend