Comments (7)
Discussion is at #218
from fast-f1.
Yes, this is a long-standing issue. But not that easy to solve, as you notice, when reading the other discussion. I hope to get this fixed for next season. But there won't be any noticeable progress before that.
from fast-f1.
Hi, I have read the discussion and tried to generate different colors by changing the lightness, but it was not successful. I am thinking that we can use the TeamColor in the DriverList for the teams.
I have found a list of 20 simple colors that enables easy contrasting. We can assign a color for each driver, however the driver's color will vary in every session, and it might seem strange to see HAM in red and VER in orange...
It solves the year-color problems, prevents similar colors, and eliminates the need to add colors manually when a new driver joins a session
Let me know your thoughts about it
from fast-f1.
I feel that defeats the purpose of providing driver colors. They are given in the plotting module for consistency. Also in this case each driver is strongly associated with their team color, I doubt many user will use the new color mapping if that association is not guarenteed
from fast-f1.
@manpean I agree with @Casper-Guo. That's not a solution most people are interested in.
from fast-f1.
Hi again,
I have been testing a new code.
The team's colors are converted from hex to CIELab. For each team color, the code searches for a color that fulfills three conditions:
The Delta_E between the color and other team colors must be higher than 'diff'.
The Delta_E between the color and the same team color must be lower than 'similar_s'.
The Delta_E between the color and the same team color must be higher than 'similar_i'.
The colors are generated by iterating through RGB values. However, this code has two problems:
It is not efficient; it has three nested 'for' loops, and each loop iterates 256 times, resulting in 16,777,216 possible colors.
As I have simplified the iterations to make it faster, if the conditions are too restrictive, the code may not find a solution.
Attached is a plot generated using this code where: diff=4; similar_s=6; similar_i=3
I attach the code, maybe you can find a better way to do it.
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import colorspacious
from fastf1 import plotting
plt.rcParams.update(plt.rcParamsDefault)
plotting.setup_mpl()
TEAM_COLORS = ["#358C75", "#F91536", "#F58020", "#6CD3BF", "#5E8FAA", "#3671C6",
"#B6BABD", "#2293D1", "#37BEDD", "#C92D4B"]
TEAMS=["Aston Martin", "Ferrari", "Mclaren", "Mercedes", "Alpha Tauri", "Red Bull",
"Haas", "Alpine", "Williams", "Alfa Romeo"]
diff=4 #Minimun difference color with other team colors
similar_s=6 #Maximun difference between the team colors
similar_i=3 #Minimun difference between the team colors
Lab_colors = list()
Results = list()
for color in TEAM_COLORS:
color_rgb = colors.hex2color(color)
color_lab = colorspacious.cspace_convert(color_rgb, "sRGB1", "CAM02-UCS")
Lab_colors.append(color_lab)
for i in range(len(Lab_colors)):
stop_loops=False
for r in range(32):
# print(f"r: {r}")
for g in range(32):
for b in range(32):
color_rgb = colorspacious.cspace_convert(Lab_colors[i], "CAM02-UCS", "sRGB1")
color_lab = colorspacious.cspace_convert(((color_rgb[0]+r*8/256)%1, (color_rgb[1]+g*8/256)%1, (color_rgb[2]+b*8/256)%1), "sRGB1", "CAM02-UCS")
if all(colorspacious.deltaE(color_lab, otro_color) > diff and colorspacious.deltaE(color_lab, Lab_colors[i]) < similar_s and colorspacious.deltaE(color_lab, Lab_colors[i]) > similar_i for index, otro_color in enumerate(Lab_colors) if index != i):
color_rgb = colorspacious.cspace_convert(color_lab, "CAM02-UCS", "sRGB1")
color_hex = colors.to_hex(color_rgb)
TEAM_COLORS.append(color_hex)
Lab_colors.append(color_lab)
Results.append([TEAM_COLORS[i], color_hex])
stop_loops=True
print(f"Color {i+1} found: ({r/256},{g/256},{b/256})\nDiff:{colorspacious.deltaE(color_lab, Lab_colors[i])}\n")
break
if stop_loops:
break
if stop_loops:
break
if stop_loops:
break
fig = plt.figure()
ax = fig.add_subplot()
for i, pair in enumerate(Results):
for j, color in enumerate(pair):
ax.plot([0, 1], [i+j*0.15, i+j*0.15], color=color, linewidth=4, markerfacecolor='black', markeredgecolor='black', marker='o')
ax.set_yticks(range(0, len(Results)))
ax.set_yticklabels(TEAMS)
# plt.savefig("Colors", dpi=300)
plt.show()
# print(Results)
from fast-f1.
@Casper-Guo I have read an article that explains how the difference between colors are measured using Delta E
The code I attached uses Delta E 1976, it means that Delta E is the lenght of the vector that starts in color 1 and ends in color 2 in a 3D space.
from fast-f1.
Related Issues (20)
- [BUG] get_circuit_info() doesn't work with custom TELEMETRY_FREQUENCY HOT 6
- [BUG] Example ``plot_driver_laptimes.py`` no longer working with latest Seaborn release HOT 11
- [BUG] Data for Piastri in the sprint shootout not available HOT 2
- [BUG] The first lap of a race should not have a PitOutTime HOT 3
- [BUG] Incorrect Qatar Sprint results due to not applied penalties HOT 3
- [BUG] All laps from Singapore and Qatar Grand Prix have IsAccurate=False HOT 3
- [ENH] Add Python 3.12 to test HOT 1
- [BUG] USGP Results | Duplicate entry for TSU and LEC missing data HOT 4
- [BUG] Laps.pick_fastest(only_by_time=True) inconsistency HOT 5
- [BUG] Restart lap times after the red flag HOT 10
- Ergast ShuttingDown HOT 1
- [DEPR] ``pick_fastest`` needs to return ``None`` instead of empty ``Lap`` HOT 1
- Rainfall Data wrong in Weather Data for some GPs HOT 2
- install pyproject.toml-based projects HOT 10
- [BUG] Las Vegas FP1, FP3 and Race failing to load HOT 4
- [BUG] Incorrect data Las Vegas Race HOT 3
- [ENH] Telemetry DataFrame should include DriverId HOT 9
- Lap to grid + formation lap part of the data for Sprint Shootout and Race sessions HOT 2
- [BUG] Driver CountryCode is not populated in the SessionResults object HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-f1.