在來自 Seaborn 樣本資料的簡單線圖中,添加“大小”引數來控制線寬會自動向“標簽”引數生成的圖例添加藝術家/句柄。
import seaborn as sns
from matplotlib import pyplot as plt
df = sns.load_dataset('geyser')
fig, ax = plt.subplots()
sns.lineplot(
x=df.waiting,
y=df.duration,
label='Label',
size=3,
ax=ax
)
plt.show()

這種行為的原因是什么,可以采取什么措施來防止它?
uj5u.com熱心網友回復:
使用該linewidth引數設定線條的寬度。size 引數還有其他作用。查看
uj5u.com熱心網友回復:
尺寸用于分組,根據類別會有不同的尺寸線。
例如,您可以根據kind列有不同的大小:
import seaborn as sns
from matplotlib import pyplot as plt
df = sns.load_dataset('geyser')
fig, ax = plt.subplots()
sns.lineplot(
x=df.waiting,
y=df.duration,
label='Label',
size = df['kind'],
ax=ax
)
plt.show()

雖然不確定它作為一個數字在做什么。您linewidth用來設定行大小:
import seaborn as sns
from matplotlib import pyplot as plt
df = sns.load_dataset('geyser')
fig, ax = plt.subplots()
sns.lineplot(
x=df.waiting,
y=df.duration,
label='Label',
linewidth = 3,
ax=ax
)
plt.show()

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/353580.html
標籤:Python matplotlib 阴谋 图形 海生
下一篇:只有三個最好的堆積條形圖
