piano_keys_coordinates | R Documentation |
A table containing the piano keys coordinates. Each piano key is centered at the midi note value it represents.
piano_keys_coordinates
A data frame with 127 rows and 6 variables:
integer from 0 - 127 containing the midi pitches
integer 1 or 2 depending on whether key is white (1) or black (2)
xmin coordinate of the key
ymin coordinate of the key
xmax coordinate of the key
ymax coordinate of the key
library(ggplot2)
# Print dataframe:
piano_keys_coordinates
# Plot the keyboard:
piano_keys_coordinates %>%
# plot white keys first that they don't cover half of the black keys:
dplyr::arrange(layer) %>%
ggplot(aes(ymin = ymin, ymax = ymax, xmin = xmin, xmax = xmax, fill = factor(layer))) +
geom_rect(color = "black", show.legend = FALSE) +
scale_fill_manual(values = c("#ffffdd", "#113300")) +
coord_fixed(ratio = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.