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
Graph title does not appear with geom_basketball #32
Comments
Hi @AndrewUr, can you please include example code so I can try to recreate the issue? |
Here's a quarto doc:
|
Here's the sessionInfo():
|
The package is awesome @rossdrucker !! |
Thanks for calling this out @AndrewUr and @rtelmore, and hope you guys had a happy holiday! I've looked into it, and I think I've figured out what's going on. It has to do with the underlying mechanics of creating the plot and the way that I've got certain theme elements set. Specifically, I have the axis labels set to be blanks ( The missing plot title, on the other hand, is a result of the margins I've got set. These were initially set to reduce some of the additional white-space around the plot. I'm looking at updating these and will likely release a patch here, but before doing so I want to make sure that the change is appropriate and doesn't cause any issues with any other sports. To resolve your problem with the example code above, the following should do the trick: library(sportyR)
library(ggplot2)
set.seed(1982)
df <- data.frame(
locationX = runif(100, -25, 25),
locationY = runif(100, 40, 400)
)
p <- geom_basketball(
league = "NBA",
display_range = "defense",
color_updates = list(
defensive_half_court = "white",
offensive_half_court = "white",
court_apron = "white",
center_circle_fill = "white",
two_point_range = "white",
painted_area = "white",
free_throw_circle_fill = "white",
basket_ring = "black")
) +
ggplot2::theme(
axis.title = ggplot2::element_text(),
plot.title = ggplot2::element_text(),
plot.margin = ggplot2::margin(
t = 0,
b = 0
)
)
p + geom_point(
data = df,
aes(
y = locationX,
x = (locationY - 420)/10),
alpha = .25
) +
labs(
title = "Rajon Rando's Shots",
x = "shot one",
y = "shot two"
) |
Thanks @rossdrucker! You're right that we don't need the x and y axes, but we do need the title. We just put the x and y axis labels in the reprex for completeness sake and perhaps to aid you in debugging. |
Writing in Quarto/Bookdown and the title in the labs() does not appear in the chart. Apologize if I'm just doing something stupid that I can't see and neither can my co-authors.
sportyrissue.pdf
The text was updated successfully, but these errors were encountered: