Create multiple subplots using plt.subplots
matplotlib.pyplot
as
plt
import
numpy
as
np
=
(
0
,
2
*
,
400
)
=
(
**
2
)
,
)
(
,
-
)
.
plot
(
,
)
(
,
-
)
fig
.
suptitle
(
'Sharing x per column, y per row'
)
(
,
)
(
,
**
2
,
'tab:orange'
)
(
,
-
,
'tab:green'
)
(
,
-
**
2
,
'tab:red'
)
for
in
():
()
ax1
.
plot
(
,
)
(
+
1
,
-
)
[
0
]
.
plot
(
,
**
2
)
[
1
]
.
plot
(
,
0.3
*
,
'o'
)
[
2
]
.
plot
(
,
,
'+'
)
[
0
]
.
plot
(
,
**
2
)
[
1
]
.
plot
(
,
0.3
*
,
'o'
)
[
2
]
.
plot
(
,
,
'+'
)
[
0
]
.
tick_params
(
labelbottom
=
True
)
(
sharex
=
True
,
sharey
=
True
)
(
'Sharing both axes'
)
[
0
]
.
plot
(
,
**
2
)
[
1
]
.
plot
(
,
0.3
*
,
'o'
)
[
2
]
.
plot
(
,
,
'+'
)
for
in
:
()
(
ax1
,
ax2
),
(
,
)
=
(
sharex
=
'col'
,
sharey
=
'row'
)
(
'Sharing x per column, y per row'
)
(
,
)
(
,
**
2
,
'tab:orange'
)
(
+
1
,
-
,
'tab:green'
)
(
+
2
,
-
**
2
,
'tab:red'
)
for
in
():
()
,
)
[
0
,
0
]
.
set_title
(
"main"
)
[
1
,
0
]
.
plot
(
,
**
2
)
[
1
,
0
]
.
set_title
(
"shares x with main"
)
[
1
,
0
]
.
sharex
(
[
0
,
0
])
[
0
,
1
]
.
plot
(
+
1
,
+
1
)
[
0
,
1
]
.
set_title
(
"unrelated"
)
[
1
,
1
]
.
plot
(
+
2
,
+
2
)
[
1
,
1
]
.
set_title
(
"also unrelated"
)
()
Download zipped: subplots_demo.zip