3 回答

TA貢獻1854條經驗 獲得超8個贊
在 R 中,您可以像這樣非常接近:
library(ggridges)
set.seed(69)
df <- data.frame(x = as.vector(sapply(14:10, function(i) rnorm(30, i, 2))),
group = rep(letters[1:5], each = 30))
ggplot(df, aes(x, y = group, fill = group)) +
geom_vline(aes(xintercept = 10), size = 2, color = "#5078be") +
geom_density_ridges(size = 2, aes(color = group)) +
geom_vline(aes(xintercept = 3), size = 2) +
scale_fill_manual(values = c("#8f4b4a", "#c08f33", "#e2baba", "#ffe2ae", "#83a8f1")) +
scale_colour_manual(values = c("#5c1a08", "#8c5b01", "#af8987", "#d2ab83", "#5078be")) +
theme_void() +
theme(legend.position = "none")

TA貢獻1802條經驗 獲得超6個贊
您可以使用 z 軸來做到這一點。您仍然可以根據需要調整設計并隱藏軸等。
from scipy import exp
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits import mplot3d
def gaus(x, a, x0, sigma):
return a*exp(-(x-x0)**2/(2*sigma**2))
if __name__ == '__main__':
x = np.array([i for i in range(0, 100)])
y1 = gaus(x, 1, 50, 5)
y2 = gaus(x, 1, 45, 12)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.view_init(-90, 90)
ax.plot3D(x, y1, 100)
ax.plot3D(x, y2, 1)
plt.show()
添加回答
舉報