简体   繁体   English

如何使我的线图更具可读性?

[英]How can I make my linechart more readable?

I made this graph using seaborn and some custom data. 我使用seaborn和一些自定义数据制作了这张图。 It shows the evolution of 3 different benchmark scores according to the price of the device. 它显示了根据设备价格的3个不同基准评分的演变情况。 I managed to stack up all 3 benchmarks with "twinx", but the graph is now simply unreadable. 我设法用“ twinx”叠加了所有三个基准,但是现在该图简直不可读。 How can I smoothen down the lines of a linechart to make it more user friendly and readable ? 如何使线图的线条更平滑以使其更易于使用和可读?

I tried rescaling the ticks but it seems like I can't configure both axes of the 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')

For the moment, my graph looks like this : 目前,我的图形如下所示:

在此处输入图片说明

Two options (certainly not the only ones) demonstrated with some sample data: 通过一些示例数据展示了两个选项(当然不是唯一的):

# [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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM