Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Bàn luậnmatplotlib.pyplot.text[x, y, s, fontdict=None, **kwargs]
Parameters:
- Trong bài viết này, chúng ta sẽ xem làm thế nào để thêm văn bản bên trong cốt truyện trong matplotlib. Hàm matplotlib.pyplot.text [] được sử dụng để thêm văn bản bên trong cốt truyện. Cú pháp thêm văn bản tại một vị trí tùy ý của các trục. Nó cũng hỗ trợ các biểu thức toán học.
- Cú pháp: matplotlib.pyplot.text [x, y, s, fontdict = none, ** kwargs]
- Nơi x, y - tọa độ
- S - Văn bản được thêm vào bên trong lô [chuỗi]
fontdict - tham số tùy chọn. Nó ghi đè các thuộc tính văn bản mặc định Adding mathematical equations inside the plot.
Python3
** kwargs - thuộc tính văn bản
Ví dụ 1: Thêm phương trình toán học bên trong cốt truyện.
import
matplotlib.pyplot as plt
import
numpy as np
Các
numpy as np
1=
numpy as np
3matplotlib.pyplot as plt
3
matplotlib.pyplot as plt
4=
matplotlib.pyplot as plt
6matplotlib.pyplot as plt
7matplotlib.pyplot as plt
7matplotlib.pyplot as plt
9
Các
x
7
Output:
numpy as np
5numpy as np
6import
7=
numpy as np
9matplotlib.pyplot as plt
3 Adding rectangular box around the text by using the keyword ‘bbox’. bbox is a dictionary of Rectangle properties.
Python3
** kwargs - thuộc tính văn bản
Ví dụ 1: Thêm phương trình toán học bên trong cốt truyện.
import
matplotlib.pyplot as plt
import
numpy as np
matplotlib.pyplot as plt
4=
matplotlib.pyplot as plt
6matplotlib.pyplot as plt
7matplotlib.pyplot as plt
7matplotlib.pyplot as plt
9
Các
numpy as np
5numpy as np
6import
7=
numpy as np
9matplotlib.pyplot as plt
3
x
1x
2x
3=
numpy as np
9matplotlib.pyplot as plt
3
Ví dụ 2: Thêm hộp hình chữ nhật xung quanh văn bản bằng cách sử dụng từ khóa ‘Bbox. Bbox là một từ điển của các thuộc tính hình chữ nhật.
x
7
Output:
Các Adding the text “Sine wave” inside the plot.
Python3
** kwargs - thuộc tính văn bản
Ví dụ 1: Thêm phương trình toán học bên trong cốt truyện.
import
matplotlib.pyplot as plt
import
numpy as np
matplotlib.pyplot as plt
23
Các
matplotlib.pyplot as plt
4=
matplotlib.pyplot as plt
6matplotlib.pyplot as plt
7matplotlib.pyplot as plt
7matplotlib.pyplot as plt
9
Các
x
7
Output:
numpy as np
5numpy as np
6import
7=
numpy as np
9matplotlib.pyplot as plt
3Using annotation along with text inside plot
Python3
** kwargs - thuộc tính văn bản
Ví dụ 1: Thêm phương trình toán học bên trong cốt truyện.
import
matplotlib.pyplot as plt
import
numpy as np
matplotlib.pyplot as plt
77
import
0matplotlib.pyplot as plt
79,
matplotlib.pyplot as plt
69,
matplotlib.pyplot as plt
83,
0
Các
matplotlib.pyplot as plt
4=
matplotlib.pyplot as plt
6matplotlib.pyplot as plt
7matplotlib.pyplot as plt
7matplotlib.pyplot as plt
9
Các
numpy as np
5numpy as np
6import
7=
numpy as np
9matplotlib.pyplot as plt
3
x
1x
2x
3=
numpy as np
9matplotlib.pyplot as plt
3
Ví dụ 2: Thêm hộp hình chữ nhật xung quanh văn bản bằng cách sử dụng từ khóa ‘Bbox. Bbox là một từ điển của các thuộc tính hình chữ nhật.
Các
x
7
Output: