seaborn 替换 matplotlib

seaborn to replace a matplotlib

我正在尝试用 seaborn 制作一个情节,我用 patplotlib

完成了一个简单的情节
 import matplotlib.pyplot as plt
    radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724]
    square = [1.0, 4.0, 9.0, 16.0, 25.0, 36.0]
    plt.plot(radius, area, label='Circle')
    plt.plot(radius, square, marker='o', linestyle='--', color='r', label='Square')
    plt.xlabel('Radius/Side')
    plt.ylabel('Area')
    plt.title('Area of Shapes')
    plt.legend()
    plt.show()

有什么想法吗?

像这样使用它,与默认的 matplotlib 图相比,您的图看起来会更好:

import seaborn as sb
import matplotlib.pyplot as plt

sb.set_style("darkgrid")
radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724]
square = [1.0, 4.0, 9.0, 16.0, 25.0, 36.0]
plt.plot(radius, area, label='Circle')
plt.plot(radius, square, marker='o', linestyle='--', color='r', label='Square')
plt.xlabel('Radius/Side')
plt.ylabel('Area')
plt.title('Area of Shapes')
plt.legend()
plt.show()

希望这对你有用。不过请检查缩进。可以找到 seaborn 的好资源 here