简体   繁体   中英

How can I make my linechart more readable?

I made this graph using seaborn and some custom data. It shows the evolution of 3 different benchmark scores according to the price of the device. I managed to stack up all 3 benchmarks with "twinx", but the graph is now simply unreadable. 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.

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()

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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