转发层级蒲公英图怎么写?
本帖最后由 18687012175 于 2024-12-27 11:46 编辑怎么用python搞蒲公英图? import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# 生成随机点
theta = np.random.uniform(0, 2 * np.pi, 100)
r = np.random.uniform(0, 1, 100)
data = pd.DataFrame({'theta': theta, 'r': r})
# 创建极坐标图
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
sns.scatterplot(x='theta', y='r', data=data, alpha=0.5)
ax.set_title('Dandelion Plot', va='bottom')
plt.show()
用Seaborn
页:
[1]