Closed andersonfrailey closed 4 years ago
This is really nice! Is it possible to handle the aspect ratio here differently?
Added include_package_data=True
to setup.py, so it'll actually install the CSV file.
I don't see any reason why not Altair, at least right now. Can we get that plot to be not squishy? And another maybe convenience mechanism -- can we make a simple flag to color by result?
Yeah I've been working on the aspect ratio. Just need to play with the width and height of the plot. Gonna push some changes up soon.
can we make a simple flag to color by result?
As in like single, double, out, etc., right? Yep, there is. I'll include that in the changes.
Also -- not pinning this on you in any way, but more making a note to self -- since we have this (and statcast data) -- we should make a similar thing for pitch location charts
Here's the new look
we should make a similar thing for pitch location charts
Agreed here. A lot of great features we could add.
I think I found an improvement for aspect ratio
I think it's better with this -- feel free to rollback the commit if you disagree
@andersonfrailey ? What do you think?
Your change looks good to me! Any other feature/functionality you want me to add on?
I think we're good in here -- I definitely want to use this as the basis for some more stuff that's related, like pitcher sprays, but that'll come separately I assume. Oh, and if you have a new name suggestion, it may be worthwhile if we want to put the fork up on the PyPI.
Oh, actually maybe one thing -- can we parametrize what the color is? I think outcome is the correct one for the default, but if, say, I wanted to plot Altuve's vs someone else's (assuming I concatted the DFs with their IDs / names etc). Maybe have that line in there creating the label
column unconditionally (cheap enough, no need to add an if check), but just have color_by='label', legend='Outcome'
in the parameters?
This is already loads of fun
Latest batch of commits added the ability to color by player and I added a subtitle to say which ballpark you're plotting on. Here's the new looks
I need to make a couple of tweaks to the subtile on the generic field. Will push those shortly.
Fixes are up.
I liked it better with CIN but sure. And if someone really needs a generic stadium, there's always Kauffman. Great job, Imma merge. And a side note: for now I'm leaving the CSV where it is. If we start having other data files come with this thing, we'll move them to a separate folder.
I stumbled on the MLBAM stadium coordinates in this repo and wrote a couple functions for plotting. I used altair, but I'd be happy to switch to matplotlib or bokeh if that's preferable.
The first,
plot_stadium
, just returns a plot with the stadium outline.spraychart
makes a spraychart using statcast data. Example: