![](/img/trans.png)
[英]How can I make my code more readable and DRYer when working with XML namespaces in Python?
[英]How can I make my linechart more readable?
我使用seaborn和一些自定義數據制作了這張圖。 它顯示了根據設備價格的3個不同基准評分的演變情況。 我設法用“ twinx”疊加了所有三個基准,但是現在該圖簡直不可讀。 如何使線圖的線條更平滑以使其更易於使用和可讀?
我嘗試重新調整刻度線,但似乎無法配置twinx的兩個軸。
plt.figure(figsize=(18,8))
pal = ["#073763"]
caractere = 'prix'
sns.lineplot(data = df_plus_cpu, x = caractere, y = 'geekbench_s_core', label = 'Geekbench 4.3 64 Bit Single-Core Score', color = '#71a7d6')
sns.lineplot(data = df_plus_cpu, x = caractere, y = 'geekbench_m_core', label = 'Geekbench 4.3 64 Bit Multi-Core Score', color = '#073763')
ax2 = plt.twinx()
sns.lineplot(data = df_plus_cpu, x = caractere, y = 'passmark', ax=ax2, label = 'PassMark PerformanceTest Mobile V1 CPU Tests', color = '#EA9999')
目前,我的圖形如下所示:
通過一些示例數據展示了兩個選項(當然不是唯一的):
# [1] Plot with rolling average to emphase trend
df = pd.read_csv("https://vincentarelbundock.github.io/Rdatasets/csv/datasets/AirPassengers.csv", index_col=0)
df['value_rolling'] = df['value'].rolling(12).mean()
sns.lineplot(x='time', y='value_rolling', data=df, color='steelblue', linewidth=2.5)
sns.lineplot(x='time', y='value', data=df, color='0.5', alpha=0.5, linewidth=2)
plt.show()
# [2] Use regplot to disconnect 'noisy' points and emphasize trend
sns.regplot(x='time', y='value', ci=None, data=df,
scatter_kws=dict(color='0.5', alpha=0.3),
line_kws=dict(ls='-', color='steelblue'))
plt.xlim(df['time'].min()-0.5, df['time'].max()+0.5)
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.