sci绘图
时间: 2023-07-03 12:07:49 浏览: 113
SciPy 是一个强大的科学计算库,它也包含了一些常用的绘图工具。
使用 Matplotlib 绘图:
Matplotlib 是一个 Python 的 2D 绘图库,它可以帮助我们绘制线图、散点图、柱状图、直方图等等。
以下是一个简单的 Matplotlib 绘图示例:
```python
import matplotlib.pyplot as plt
import numpy as np
# 生成数据
x = np.linspace(0, 10, 100)
y = np.sin(x)
# 绘图
plt.plot(x, y)
plt.title('Sin(x)')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
```
使用 Seaborn 绘图:
Seaborn 是基于 Matplotlib 的一个数据可视化库,它可以让我们更轻松地绘制统计图表,例如热力图、分布图、条形图等等。
以下是一个简单的 Seaborn 绘图示例:
```python
import seaborn as sns
import numpy as np
# 生成数据
data = np.random.normal(size=(20, 6))
# 绘图
sns.boxplot(data=data)
```
使用 Plotly 绘图:
Plotly 是一个交互式的绘图库,它可以让我们创建漂亮的交互式图表和可视化应用程序。
以下是一个简单的 Plotly 绘图示例:
```python
import plotly.express as px
import numpy as np
# 生成数据
x = np.linspace(0, 10, 100)
y = np.sin(x)
# 绘图
fig = px.line(x=x, y=y, title='Sin(x)')
fig.show()
```
以上是三种常用的 Python 绘图库,它们都可以帮助我们绘制出优美的科学可视化图表。
阅读全文
相关推荐







