From 92378ff191a2c6aad68d38be31aac108a28663e0 Mon Sep 17 00:00:00 2001 From: Lasse Edfast <8794658+lasseedfast@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:59:09 +0100 Subject: [PATCH] Made it easier to set colors. --- dotplot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dotplot.py b/dotplot.py index 5e02a83..0b1abab 100644 --- a/dotplot.py +++ b/dotplot.py @@ -11,8 +11,10 @@ df['hour']=df.index df['y']=df['hour'].apply(lambda x: int(x/120)) df['x']=df['hour'].apply(lambda x: int(x%120)) -# Set export to orange and import to grey. -df['color'] = df['balance'].apply(lambda x: 'orange' if x < 0 else 'grey') +# Set colors for export and import +export_color = 'orange' +import_color = 'grey' +df['color'] = df['balance'].apply(lambda x: export_color if x < 0 else import_color) # Plot the data. ax = df.plot(kind='scatter', x='x', y='y', c='color')