python画图代码大全表白
时间: 2023-06-26 20:09:33 浏览: 158
好的,以下是一些常用的 Python 画图代码:
1. Matplotlib 绘图库
```python
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
plt.plot(x, y)
plt.xlabel('x axis')
plt.ylabel('y axis')
plt.title('title')
plt.show()
```
2. Seaborn 绘图库
```python
import seaborn as sns
tips = sns.load_dataset("tips")
sns.scatterplot(x="total_bill", y="tip", data=tips)
sns.regplot(x="total_bill", y="tip", data=tips)
sns.lmplot(x="total_bill", y="tip", data=tips)
```
3. Plotly 绘图库
```python
import plotly.express as px
df = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(df, x="year", y="lifeExp", color='country')
fig.show()
```
4. Bokeh 绘图库
```python
from bokeh.plotting import figure, output_file, show
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
output_file("line.html")
p = figure(title="title", x_axis_label='x axis', y_axis_label='y axis')
p.line(x, y)
show(p)
```
希望这些代码对你有帮助!
阅读全文