Replies: 6 comments 3 replies
-
Yes, this would obviously be nice. It's not difficult to add, I'd say. But the list would need to be maintained manually, I guess. I'd don't know of any API endpoint that provides driver colors. Pull requests are welcome. |
Beta Was this translation helpful? Give feedback.
-
How about something like this, mostly copied after your already existing I've tested these colors in a variety of graphs and they seemed decently different that you could put them all on the same graph and still tell them apart, aside from the madness of having 20 lines in it. DRIVER_COLORS = {
"valtteri bottas": "#900000",
"zhou guanyu": "#500000",
"pierre gasly": "#2b4562",
"yuki tsunoda": "#356cac",
"fernando alonso": "#0090ff",
"esteban ocon": "#70c2ff",
"sebastian vettel": "#006f62",
"lance stroll": "#25a617",
"nico hulkenberg": "#2f9b90",
"charles leclerc": "#dc0000",
"carlos sainz": "#ff8181",
"kevin magnussen": "#ffffff",
"mick schumacher": "#cacaca",
"daniel ricciardo": "#ff8700",
"lando norris": "#eeb370",
"lewis hamilton": "#00d2be",
"george russell": "#24ffff",
"max verstappen": "#0600ef",
"sergio perez": "#716de2",
"alexander albon": "#005aff",
"nicholas latifi": "#012564",
}
DRIVER_TRANSLATE = {'LEC': 'charles leclerc', 'SAI': 'carlos sainz',
'VER': 'max verstappen', 'SER': 'sergio perez',
'RIC': 'daniel ricciardo', 'NOR': 'lando norris',
'ALO': 'fernando alonso', 'OCO': 'esteban ocon',
'BOT': 'valtteri bottas', 'ZHO': 'zhou guanyu',
'GAS': 'pierre gasly', 'TSU': 'yuki tsunoda',
'MAG': 'kevin magnussen', 'MSC': 'mick schumacher',
'VET': 'sebastian vettel', 'HUL': 'nico hulkenberg',
'STR': 'lance stroll',
'HAM': 'lewis hamilton', 'RUS': 'george russell',
'ALB': 'alexander albon', 'LAT': 'nicholas latifi'}
def driver_color(identifier):
if identifier.upper() in DRIVER_TRANSLATE:
# try short team abbreviations first
return DRIVER_COLORS[DRIVER_TRANSLATE[identifier.upper()]]
else:
identifier = identifier.lower()
# check for an exact team name match
if identifier in DRIVER_COLORS:
return DRIVER_COLORS[identifier]
# check for exact partial string match
for team_name, color in DRIVER_COLORS.items():
if identifier in team_name:
return color
# do fuzzy string matching
key_ratios = list()
for existing_key in DRIVER_COLORS.keys():
ratio = fuzz.ratio(identifier, existing_key)
key_ratios.append((ratio, existing_key))
key_ratios.sort(reverse=True)
if (key_ratios[0][0] < 35) or (key_ratios[0][0]/key_ratios[1][0] < 1.2):
# ensure that the best match has a minimum accuracy (35 out of
# 100) and that it has a minimum confidence (at least 20% better
# than second best)
raise KeyError
best_matched_key = key_ratios[0][1]
return DRIVER_COLORS[best_matched_key] |
Beta Was this translation helpful? Give feedback.
-
I faced a similar issue and think a dotted line for the other driver of same would mostly solve differentiating the drivers |
Beta Was this translation helpful? Give feedback.
-
I would prefer no dotted line because the data is already sampled and removing points might make it harder to read the graph, also in |
Beta Was this translation helpful? Give feedback.
-
@dialtone Just took a look at it now. Colors look good in my opinion. And yes, this is how we'd have to implement it. I haven't properly tested it but at a first glance seems fine. |
Beta Was this translation helpful? Give feedback.
-
PR created #159 |
Beta Was this translation helpful? Give feedback.
-
Few things that are nice to do are to compare drivers from the same team and what are their differences in telemetry, however in these cases you need to explicitly pick a different color for the second driver, if you were using team colors before, because obviously both lines would end up being the same color.
Beta Was this translation helpful? Give feedback.
All reactions