Plot 在Racket中是否有任何函数可以绘制一个类似“quot;stem";用python绘图?

Plot 在Racket中是否有任何函数可以绘制一个类似“quot;stem";用python绘图?,plot,racket,Plot,Racket,干图在从基线到y的每个x位置绘制垂直线,并在那里放置一个标记 这样地: 您使用的图形由Python中的以下代码生成: import matplotlib.pyplot as plt import numpy as np x = np.linspace(0.1, 2 * np.pi, 41) y = np.exp(np.sin(x)) plt.stem(x, y, use_line_collection=True) plt.show() 尝试使用Racket构建类似的情节: #lang ra

干图在从基线到y的每个x位置绘制垂直线,并在那里放置一个标记 这样地:

您使用的图形由Python中的以下代码生成:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0.1, 2 * np.pi, 41)
y = np.exp(np.sin(x))

plt.stem(x, y, use_line_collection=True)
plt.show()
尝试使用Racket构建类似的情节:

#lang racket

(require plot)

(define my-linspace
  (λ (start stop [num 50])
    (range start stop (/ stop num))))

(define x (my-linspace 0 (* 2 pi) 41))
(define y (map exp (map sin x)))

(define my-blue '(32 119 180))

(plot
 #:x-min -0.3
 #:x-max 6.5
 #:y-min -0.2
 #:y-max 2.9
 #:x-label #f
 #:y-label #f
 (let ([data (map list x y)])
   (list
    (points data #:color my-blue #:sym 'fullcircle5)
    ; for each data point, draw a vertical line
    ; at its "x" ranging from height 0 to its "y"
    (list (map (λ (d) (vrule (first d) 0 (second d) #:color my-blue #:width 2)) data))
    (list (hrule 0 (first (first data)) (first (last data)) #:color "red" #:width 2)))))

哇,你的情节和我举的例子一模一样。非常感谢,我相信我会用它:)