下面是在 matplotlib 中創建詞干圖的示例腳本。#!/usr/bin/env python3# -*- coding: utf-8 -*-import matplotlib.pyplot as pltimport numpy as np# returns 10 evenly spaced samples from 0.1 to 2*PIx = np.linspace(0.1, 2 * np.pi, 10)fig, ax = plt.subplots( figsize=(4.,3.), constrained_layout=True)markerline, stemline, baseline = ax.stem(x, np.cos(x), '-.', use_line_collection=True)markerline1, stemline1, baseline1 = ax.stem(x, np.cos(x*5), '-', use_line_collection=True)plt.setp(baseline, color='black', linewidth=2)plt.setp(baseline1, color='black', linewidth=2)plt.setp( stemline, color="green" )plt.setp( stemline1, color="red" )plt.show()問題 1.創建這些圖后,我想刪除例如 , , .如何刪除它們?markerline1stemline1baseline1問題 2.如果我想在不影響 其他設置的情況下刪除整個梗圖,我該怎么做?我發現從中刪除所有內容。axaxax.clear()ax根據matplotlib,用戶警告:在 Matplotlib 3.3 中,詞干圖上的單個線將添加為線集合,而不是單個線。此外,LineCollection 似乎有一個名為“屬性”的屬性,其中包含所有詞干線的 x,y 信息。segment問題 3.如何從 或 獲取對象?我正在探索修改對象是否是回答我的第一個問題的方法。LineCollectionaxfigLineCollection
添加回答
舉報
0/150
提交
取消