Sử dụng python định nghĩa số liệu

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
4 sử dụng khái niệm của một hình hiện tại và các thành phần hiện tại. Hình được xác định thông qua một số hình được truyền đến
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
5. Hình với các số đã được thiết lập để làm hiện tại. Ngoài ra, nếu không có con số nào tồn tại, một cái mới được tạo ra

Ghi chú

Chúng tôi không khuyến khích làm việc với nhiều hình thông qua giao diện pyplot vì quản lý con số hiện tại là cồng kềnh và dễ bị lỗi. Thay vào đó, chúng tôi khuyên bạn nên sử dụng phương pháp tiếp cận rõ ràng và các phương thức gọi trên các trường hợp hình và hệ thống. Xem các giao diện ứng dụng Matplotlib [API] để giải thích về sự thay đổi giữa các giao diện bến và rõ ràng. Giao diện ứng dụng Matplotlib [API] để biết giải thích về sự đánh đổi giữa giao diện ngầm và rõ ràng.

Tạo Hình 1

Tạo Hình 2

Bây giờ chuyển trở lại Hình 1 và thực hiện một số thay đổi

Tổng thời gian chạy của tập lệnh. [0 phút 1. 092 giây] [ 0 phút 1. 092 giây]

Art Gallery được tạo ra bởi Sphinx-Gallery

Ghi chú

Nhấn vào đây để tải xuống mã ví dụ đầy đủ tại đây để tải xuống mã ví dụ đầy đủ

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
6 tạo ra một số và một lưới các ô với một cuộc gọi duy nhất, trong khi cung cấp kiểm tra giám sát hợp lý về cách các lô riêng lẻ được tạo ra. Đối với các trường hợp được sử dụng nâng cao hơn, bạn có thể sử dụng
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
7 để bố trí biểu đồ con cục bộ tổng quát hơn hoặc
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
8 để bổ sung các ô phụ tại các vị trí tùy chọn trong hình

import matplotlib.pyplot as plt
import numpy as np

# Some example data to display
x = np.linspace[0, 2 * np.pi, 400]
y = np.sin[x ** 2]

A con number only have a subplot#

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
0 mà không có đối số trả về
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
1 và một
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
2

Đây thực sự là cách đơn giản nhất và được khuyến nghị để tạo ra một hình và trục duy nhất

Sắp xếp các ô theo một hướng#

Hai tham số tùy chọn đầu tiên của

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
6 xác định số lượng hàng và cột của lưới phụ

Khi chỉ xếp hạng theo một hướng,

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
4 đã trả về là một mảng numpy 1D chứa danh sách các bộ phận được tạo

Nếu bạn đang tạo chỉ một vài phần, thật thuận tiện khi giải nén chúng ngay lập tức cho các biến chuyên dụng cho từng phần. Bằng cách đó, chúng ta có thể sử dụng

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
5 thay vì nhiều hơn
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
6

Để có các ô phụ bên cạnh, hãy truyền các tham số

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
7 cho một hàng và hai cột

Sắp xếp các ô theo hai hướng#

Khi sắp xếp chồng theo hai hướng,

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
4 được trả về là một mảng 2D

Nếu bạn phải đặt các tham số cho từng Subplot, nó sẽ tiện dụng để lặp lại tất cả các ô con trong lưới 2D bằng cách sử dụng

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
9.
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]

Bạn cũng có thể sử dụng Tuple-Unpacking trong 2D để gán tất cả các ô con cho các biến chuyên dụng

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
1

Chia sẻ mạng#

Theo mặc định, mỗi thành phần được chia theo tỷ lệ riêng lẻ. Do đó, nếu các phạm vi khác nhau, các đánh giá đánh dấu của các ô con không căn cứ

Bạn có thể sử dụng chia sẻ hoặc chia sẻ để điều chỉnh trục ngang hoặc dọc

Cài đặt chia sẻ hoặc chia sẻ thành

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
10 cho phép chia sẻ toàn cầu trên toàn bộ lưới, tức là các trục y của các ô phụ được xếp hạng theo chiều dọc có cùng thang đo khi sử dụng
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
11

Đối với các ô phụ đang chia sẻ trục, một bộ nhãn Đánh dấu là đủ. Nhãn đánh dấu của các thành phần bên trong được tự động xóa bởi Sharex và Sharey. Vẫn còn một khoảng trống không được sử dụng giữa các ô con

Để kiểm tra chính xác vị trí của các ô con, người ta có thể làm rõ ràng ràng buộc với

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
7

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
13, after that call method
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
14 of it. Ví dụ, chúng ta có thể giảm chiều cao giữa các ô dọc bằng cách sử dụng
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
15.
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
16 là một phương pháp tiện dụng để loại bỏ nhãn và ve từ các ô con không có ở trần của lưới

Ngoài

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
10 và
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
18, both Sharex và Sharey đều chấp nhận các giá trị 'hàng' và 'col' để chia sẻ các giá trị duy nhất trên mỗi hàng hoặc cột.
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
0

Nếu bạn muốn một cấu trúc chia sẻ phức tạp hơn, trước tiên bạn có thể tạo lưới các phần không chia sẻ, sau đó gọi

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
19 hoặc
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
00 để thêm thông tin chia sẻ một hậu thế.
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
3

trục cực#

Tham số subplot_kw của

fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
6 kiểm tra các subplot thuộc tính [xem thêm
fig, axs = plt.subplots[2, 2]
axs[0, 0].plot[x, y]
axs[0, 0].set_title['Axis [0, 0]']
axs[0, 1].plot[x, y, 'tab:orange']
axs[0, 1].set_title['Axis [0, 1]']
axs[1, 0].plot[x, -y, 'tab:green']
axs[1, 0].set_title['Axis [1, 0]']
axs[1, 1].plot[x, -y, 'tab:red']
axs[1, 1].set_title['Axis [1, 1]']

for ax in axs.flat:
    ax.set[xlabel='x-label', ylabel='y-label']

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer[]
8]. Cụ thể, điều này có thể được sử dụng để tạo ra một lưới các cực

Tổng thời gian chạy của tập lệnh. [0 phút 7,949 giây] [ 0 phút 7. 949 giây]

Art Gallery được tạo ra bởi Sphinx-Gallery

Làm thế nào để bạn vẽ nhiều biểu đồ trên các hình khác nhau trong Python?

Quản lý nhiều hình trong Pyplot. .

Nhập matplotlib. pyplot as PLT Nhập Numpy as NP T = NP. Sắp xếp [0,0, 2. 0, 0,01] S1 = NP. error [2*np. pi*t] s2 = np. Error [4*np.

Chủ Đề