PasteRack.org
Paste # 429
2020-01-23 06:22:29

Fork as a new paste.

Paste viewed 449 times.


Embed:

  1. #lang racket
  2. (require plot)
  3. (plot-new-window? #t)
  4.  
  5. ;;; 3D Functions
  6. ;;;(plot3d (surface3d  (x y) (* (cos x) (sin y)))
  7. ;;;                     (- pi) pi (- pi) pi)
  8. ;;;          #:title "An R × R  R function"
  9. ;;;          #:x-label "x" #:y-label "y" #:z-label "cos(x) sin(y)")
  10. ;::(parameterize ([plot-title  "An R × R  R function"]
  11. ;;;                 [plot-x-label "x"]
  12. ;;;                 [plot-y-label "y"]
  13. ;;;                 [plot-z-label "cos(x) sin(y)"])
  14. ;;;    (plot3d (contour-intervals3d  (x y) (* (cos x) (sin y)))
  15. ;;;                                 (- pi) pi (- pi) pi)))
  16.  
  17.  
  18. ;;; Simple Function
  19. ;(plot (function sin (- pi) pi #:label "y = sin(x)"))
  20.  
  21. ;;; Functions with color, style and returned
  22. ;(plot (list (axes)
  23. ;              (function sqr -2 2)
  24. ;              (function  (x) x) #:color 0 #:style 'dot)
  25. ;              (inverse sqr -2 2 #:color 3)))
  26.  
  27.  
  28. ;(plot (lines
  29. ;         (reverse
  30. ;          (for/fold ([lst (list (vector 0 0))]) ([i  (in-range 1 15)])
  31. ;            (match-define (vector x y) (first lst))
  32. ;            (cons (vector i (+ y (* 1/100 (- (random) 1/2)))) lst)))
  33. ;         #:color 6 #:label "Random walk"))
  34.  
  35. ; Random Points
  36. (define points'(#(0 7) #(1 2) #(2 5) #(3 12) #(4 1)))
  37.  
  38. ; Draw Random Points
  39. (plot (lines points #:x-max 4 #:x-min 0 #:y-min 0 #:y-max 13 #:label "Function 1") #:title "Test Graphe")
  40.  
  41. ; Draw Two Graph
  42. ; (plot (list (axes) (function sqr) (lines points))) works too but apparently (axes) is not necessary
  43. (plot (list (function sqr) (lines points)))

=>