sincos函数图例画笔宽度怎么写
时间: 2024-10-20 17:15:38 浏览: 22
在Matplotlib库中,如果你想改变sincos函数图例的线条宽度,你需要在创建图例时指定`linewidth`或`lw`参数。下面是一个示例:
```python
import matplotlib.pyplot as plt
from math import sin, cos
x = range(0, 40)
y_sincos = [sin(i) for i in x] + [cos(i) for i in x]
plt.plot(x, y_sincos, label='Sine and Cosine')
plt.legend(title='Functions', handles=[plt.Line2D([], [], color='blue', linestyle='', marker='o', markersize=5, linewidth=2)], fontsize=12, framealpha=0.5)
# 这里设置了图例线条的宽度为2
plt.legend(handles=[plt.Patch(facecolor='blue', edgecolor='black', linewidth=2)], prop={'weight': 'bold'})
plt.show()
阅读全文