import
matplotlib.pyplot as plt
import
matplotlib.gridspec as gridspec
import
numpy as np
fig
=
plt.figure(figsize
=
(
12
,
6
))
gs
=
gridspec.GridSpec(
2
,
3
, width_ratios
=
[
1
,
2
,
1
], height_ratios
=
[
2
,
1
])
ax1
=
plt.subplot(gs[
0
,
0
])
ax2
=
plt.subplot(gs[
0
,
1
])
ax3
=
plt.subplot(gs[
0
,
2
])
ax4
=
plt.subplot(gs[
1
, :])
x
=
np.linspace(
0
,
10
,
100
)
y1
=
np.sin(x)
ax1.plot(x, y1, color
=
'blue'
)
ax1.set_title(
'Line Plot - Sine Function'
)
x
=
np.random.rand(
30
)
y2
=
3
*
x
+
np.random.randn(
30
)
ax2.scatter(x, y2, color
=
'green'
)
ax2.set_title(
'Scatter Plot'
)
categories
=
[
'A'
,
'B'
,
'C'
,
'D'
]
values
=
np.random.randint(
1
,
10
,
4
)
ax3.bar(categories, values, color
=
'orange'
)
ax3.set_title(
'Bar Plot'
)
labels
=
[
'Category 1'
,
'Category 2'
,
'Category 3'
]
sizes
=
np.random.randint(
1
,
10
,
3
)
ax4.pie(sizes, labels
=
labels, autopct
=
'%1.1f%%'
, colors
=
[
'lightcoral'
,
'lightblue'
,
'lightgreen'
])
ax4.set_title(
'Pie Chart'
)
plt.tight_layout()
plt.show()