Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strategy example #372

Merged
merged 1 commit into from
May 19, 2023
Merged

Strategy example #372

merged 1 commit into from
May 19, 2023

Conversation

Casper-Guo
Copy link
Contributor

File running correctly also depends on #368. The following plot is generated:
test

Note that the drivers ideally will appear in descending order by finishing position. This is the behaviour seen in similar functions in the past. Some basic investigation shows that the drivers do not appear in session.laps in sorted finishing order. This may be a bug.

@Casper-Guo
Copy link
Contributor Author

P.S Doc build check failure is fixed by #368

@theOehrly
Copy link
Owner

I merged #368, please rebase onto master again.

@Casper-Guo Casper-Guo force-pushed the strategy-example branch 3 times, most recently from f4b9bc9 to 59ad4ae Compare May 12, 2023 20:58
@MooshuBeef
Copy link

MooshuBeef commented May 14, 2023

I tried running the code and got this. I should have the latest on python, matplotlib, and seaborn

/Users/alexchan/PycharmProjects/pythonProject/venv/bin/python /Users/alexchan/PycharmProjects/pythonProject/plot_driver_laptimes.py 
req         WARNING 	

DEFAULT CACHE ENABLED!
	Cache directory: /Users/alexchan/Library/Caches/fastf1.
	Size: 376.29 MB
core           INFO 	Loading data for Azerbaijan Grand Prix - Race [v3.0.2]
req            INFO 	Using cached data for driver_info
req            INFO 	Using cached data for session_status_data
req            INFO 	Using cached data for lap_count
req            INFO 	Using cached data for track_status_data
req            INFO 	Using cached data for timing_data
req            INFO 	Using cached data for timing_app_data
core           INFO 	Processing timing data...
req            INFO 	Using cached data for car_data
req            INFO 	Using cached data for position_data
req            INFO 	Using cached data for weather_data
req            INFO 	Using cached data for race_control_messages
core           INFO 	Finished loading data for 20 drivers: ['11', '1', '16', '14', '55', '44', '18', '63', '4', '22', '81', '23', '20', '10', '31', '2', '27', '77', '24', '21']
Traceback (most recent call last):
  File "/Users/alexchan/PycharmProjects/pythonProject/plot_driver_laptimes.py", line 38, in <module>
    sns.scatterplot(data=driver_laps,
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/seaborn/relational.py", line 761, in scatterplot
    p.plot(ax, kwargs)
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/seaborn/relational.py", line 578, in plot
    points.set_facecolors(self._hue_map(data["hue"]))
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/_api/__init__.py", line 256, in method
    return getattr(self, name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/collections.py", line 751, in set_facecolor
    self._set_facecolor(c)
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/collections.py", line 733, in _set_facecolor
    self._facecolors = mcolors.to_rgba_array(c, self._alpha)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/colors.py", line 485, in to_rgba_array
    rgba = np.array([to_rgba(cc) for cc in c])
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/colors.py", line 485, in <listcomp>
    rgba = np.array([to_rgba(cc) for cc in c])
                     ^^^^^^^^^^^
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/colors.py", line 299, in to_rgba
    rgba = _to_rgba_no_colorcycle(c, alpha)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexchan/PycharmProjects/pythonProject/venv/lib/python3.11/site-packages/matplotlib/colors.py", line 374, in _to_rgba_no_colorcycle
    raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
ValueError: Invalid RGBA argument: 'ffd12e'

Process finished with exit code 1

@theOehrly
Copy link
Owner

theOehrly commented May 14, 2023

I tried running the code and got this. I should have the latest on python, matplotlib, and seaborn
[...]

This is a bug in FastF1 that was fixed by the PR that we talked above already (#368). It'll work after the next release.

@MooshuBeef
Copy link

Ahhh I see thank you!

Copy link
Owner

@theOehrly theOehrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly the same comments as on the other PR. I made the comments a bit shorter here, no intention to be rude 😅

examples/plot_strategy.py Outdated Show resolved Hide resolved
examples/plot_strategy.py Show resolved Hide resolved
examples/plot_strategy.py Show resolved Hide resolved
@Casper-Guo Casper-Guo marked this pull request as draft May 17, 2023 00:33
@Casper-Guo Casper-Guo force-pushed the strategy-example branch 2 times, most recently from 3bc01ea to 724ee30 Compare May 18, 2023 01:02
@Casper-Guo Casper-Guo marked this pull request as ready for review May 18, 2023 01:02
@Casper-Guo Casper-Guo requested a review from theOehrly May 18, 2023 01:02
@theOehrly
Copy link
Owner

Looks good as well. Thank you for adding these three very helpful examples!

(And I'll get around to your other open PR and discussions soon now.)

@theOehrly theOehrly merged commit 287afe3 into theOehrly:master May 19, 2023
@Casper-Guo
Copy link
Contributor Author

Casper-Guo commented May 19, 2023

You are welcome! Being able to contribute to a project that I use a ton really is a joy.

I will try to work on some of the visuals in #325 in the future; there are several that I want to learn to make. In the meantime, I am more than glad to investigate any other good visualizations you find as well.

@Casper-Guo
Copy link
Contributor Author

For this particular plot, I also make a more complex version to highlight SC and VSC periods and provide additional context. Those code can be used for a track status overview (like the following) if you think that's something people will be interested in:

image

@theOehrly
Copy link
Owner

For this particular plot, I also make a more complex version to highlight SC and VSC periods and provide additional context. Those code can be used for a track status overview (like the following) if you think that's something people will be interested in:

image

I think something like this would be cool as well. There's no example yet, that really utilizes this information. So it's nice to show that this data is available.

@Casper-Guo Casper-Guo deleted the strategy-example branch June 15, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants