Drawing rectangles with ggplot2

hello
am curious if you know much ggplot?
I have the following values:
OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.6
inKzone <- -0.95
outKzone <- 0.95
OShdwTop <- 3.83
IShdwtop <- 3.38
IShdBot <- 1.8
OShdBot <- 1.17

outerShadow <- data.frame(
x1 = c(OShdwIn , OShdwIn , OShdwOut , OShdwOut , OShdwIn) ,
y1 = c(OShdBot , OShdwTop , OShdwTop , OShdBot , OShdBot)
)
innerShadow <- data.frame(
x2 = c(IShdwIn , IShdwIn , IShdwOut , IShdwOut , IShdwIn) ,
y2 = c(IShdBot , IShdwtop , IShdwtop , IShdBot , IShdBot)
)

kZone <- data.frame(
x3=c(inKzone , inKzone , outKzone , outKzone , inKzone),
y3 =c(botKzone , topKzone , topKzone , botKzone , botKzone)
)
and I am looking to create one strike_zone that incorporates all three df: inner and outer zone and the kzone as well. I have been trying to add them. add one at time. I can only get them to draw each box solo

is <- ggplot(alfaro , aes(plate_x , plate_z)) +
geom_point() +
coord_equal() +
geom_path(aes(x , y) , data = innerShadow , lwd = .25)

thru thiscodethanks for time

Merge your data into a single dataframe so you can do something like this

library(tidyverse)

names(outerShadow) <- c("x", "y")
names(innerShadow) <- c("x", "y")
names(kZone) <- c("x", "y")

list(outerShadow, innerShadow, kZone) %>%
    setNames(nm = c("outerShadow", "innerShadow", "kZone")) %>%
    map_dfr(~.x, .id = "zone") %>% 
    ggplot() +
    coord_equal() +
    geom_path(aes(x, y, color = zone), lwd = .25)

2 Likes

wow. thanks
I tried adding into one data frame as well, but not this way.
I have 2 questions from this point:
as this is set up if I want to graph points, do I call it?
is there a way I can have the inner and out zone lines be the same color:
and the kzone line lwd = .5 , linetype = 2

From your comment I understand that you are trying to annotate your plot with those boxes instead of actually plotting data, if that is the case then this approach would be more natural.

Note: Please make your questions providing a self-contained REPRoducible EXample (reprex) like the one shown bellow.

OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.6
inKzone <- -0.95
outKzone <- 0.95
OShdwTop <- 3.83
IShdwtop <- 3.38
IShdBot <- 1.8
OShdBot <- 1.17

library(tidyverse)

set.seed(1)

sample_data <- data.frame(
    x = runif(10, -1.2, 1.2),
    y = runif(10, 1, 4)
)

sample_data %>% 
    ggplot(aes(x, y)) +
    annotate("rect", xmin = OShdwIn, xmax = OShdwOut, ymin = OShdBot, ymax = OShdwTop,
             alpha = 0,
             color = "blue",
             lwd = .25) +
    annotate("rect", xmin = IShdwIn, xmax = IShdwOut, ymin = IShdBot, ymax = IShdwtop,
             alpha = 0,
             color = "blue",
             lwd = .25) +
    annotate("rect", xmin = inKzone, xmax = outKzone, ymin = botKzone, ymax = topKzone,
             alpha = 0,
             color = "green",
             lwd = .5,
             linetype = 2) +
    geom_point() +
    coord_equal()

Created on 2019-08-11 by the reprex package (v0.3.0.9000)

2 Likes

ok, I was sloppy.
how is this for a rerun:

I have this data:
41%20PM
and these values:
OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.5
inKzone <- -0.83
outKzone <- 0.83
OShdwTop <- 3.83
IShdwtop <- 3.18
IShdBot <- 1.8
OShdBot <- 1.17

I have created and separately graphed the zones, but I am looking to combine all into one zone, where the inner and outer zone are the same linetype and color and the kzone is linetype 2 and a different color. I am going to use the data to graph the pitch results along plate_x and plate_z coordinates in scatterplot.

just in general how is that as presentation as far as reprex?

thanks for help
stephen

also, if you don't mind, I am trying to id the handful of pitches that fall in zones between blue and green lines that get called opposite what they should be: for example, in your graph there are pitches that land in the outer shadow. how can they be identified? I tried
adding
geom_text(data = alfaro_k, aes(plate_x ,plate_z, label = sv_id), hjust = 5) +

and
with(identify(alfaro_b , plate_x , plate_z , n = 5))
and neither worked

A reprex has to be reproducible, your text description it is not, I can't copy what you have posted paste it on my R session and work with it.

If you need specific help, please read the link I gave you before and try to make a proper reproducible example, so we can all work on the same code and data.

21%20PM

OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.5
inKzone <- -0.83
outKzone <- 0.83
OShdwTop <- 3.83
IShdwtop <- 3.18
IShdBot <- 1.8
OShdBot <- 1.17

outerShadow <- data.frame(
x1 = c(OShdwIn , OShdwIn , OShdwOut , OShdwOut , OShdwIn) ,
y1 = c(OShdBot , OShdwTop , OShdwTop , OShdBot , OShdBot)
)
innerShadow <- data.frame(
x = c(IShdwIn , IShdwIn , IShdwOut , IShdwOut , IShdwIn) ,
y = c(IShdBot , IShdwtop , IShdwtop , IShdBot , IShdBot)
)

kZone <- data.frame(
x =c(inKzone , inKzone , outKzone , outKzone , inKzone),
y =c(botKzone , topKzone , topKzone , botKzone , botKzone)
)

I am trying to ID pitches deemed stolenk (in the outer shadow Called_Strike)

as well as lostk (pitches in the inner shadow zone called a Ball) on the ggplot graph

my ggplot ability is limited and not fresh

gary_530191_samp %>%
ggplot(aes(plate_x, plate_z)) +
annotate("rect", xmin = OShdwIn, xmax = OShdwOut, ymin = OShdBot, ymax = OShdwTop,
alpha = 0,
color = "blue",
lwd = .25) +
annotate("rect", xmin = IShdwIn, xmax = IShdwOut, ymin = IShdBot, ymax = IShdwtop,
alpha = 0,
color = "blue",
lwd = .25) +
annotate("rect", xmin = inKzone, xmax = outKzone, ymin = botKzone, ymax = topKzone,
alpha = 0,
color = "green",
lwd = .5,
linetype = 2) +
geom_point() +
geom_text(data = alfaro_k, aes(plate_x ,plate_z, label = description), hjust = 5) +
coord_equal()

this creates a graph where just the Balls are labeled, not the called_strikes.

gary_530191_samp.pdf (150.9 KB)

is this better as reprex? I believe I am following directions
thanks

Not really, you are not providing sample data, you are posting a screenshot, we explicitly ask people to avoid posting screenshots because they are not reproducible.

If you read the guide I gave you about reprex you will see in the first section, a couple of ways to properly post sample data on a copy/paste friendly format, it is not that hard, basically you just have to run dput(gary_530191_samp) and post the output.

it seems like so much stuff though. this is the data set?
sorry I am a struggle here. I am in over my head on two things. I really appreciate it. I actually have a bit of brain damage too. I am beginning to see how that impacts my learning. I need to read, let it sit and later things pop up. I am on a delay for things.

dput(gary_530191_samp)
structure(list(catcher_name = structure(c(1063L, 1063L, 1063L,
1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L,
1063L, 1063L), .Label = c("A.J. Achter", "A.J. Cole", "A.J. Ellis",
"A.J. Griffin", "A.J. Jimenez", "A.J. Minter", "A.J. Morris",
"A.J. Pollock", "A.J. Ramos", "A.J. Reed", "A.J. Schugel", "Aaron Altherr",
"Aaron Barrett", "Aaron Blair", "Aaron Brooks", "Aaron Bummer",
"Aaron Crow", "Aaron Cunningham", "Aaron Harang", "Aaron Hicks",
"Aaron Hill", "Aaron Judge", "Aaron Laffey", "Aaron Loup", "Aaron Nola",
"Aaron Poreda", "Aaron Sanchez", "Aaron Slegers", "Aaron Thompson",
"Aaron Wilkerson", "Abel De Los Santos", "Abiatal Avelino", "Abraham Almonte",
"Adalberto Mejia", "Adam Cimber", "Adam Conley", "Adam Duvall",
"Adam Eaton", "Adam Engel", "Adam Frazier", "Adam Jones", "Adam Kolarek",
"Adam LaRoche", "Adam Liberatore", "Adam Lind", "Adam Loewen",
"Adam McCreery", "Adam Moore", "Adam Morgan", "Adam Ottavino",
"Adam Plutko", "Adam Rosales", "Adam Wainwright", "Adam Walker",
"Adam Warren", "Adam Wilk", "Adbert Alzolay", "Addison Reed",
"Addison Russell", "Adeiny Hechavarria", "Adolis Garcia", "Adonis Garcia",
"Adonis Medina", "Adrian Beltre", "Adrian Gonzalez", "Adrian Houser",
"Adrian Nieto", "Adrian Sampson", "Adrian Sanchez", "Adron Chambers",
"Akeel Morris", "Al Alburquerque", "Alan Busenitz", "Albert Abreu",
"Albert Almora Jr.", "Albert Pujols", "Albert Suarez", "Alberto Cabrera",
"Alberto Callaspo", "Alberto Gonzalez", "Alberto Rosario", "Alberto Tirado",
"Alcides Escobar", "Alec Asher", "Alec Mills", "Aledmys Diaz",
"Alejandro Chacin", "Alejandro De Aza", "Alen Hanson", "Alex Avila",
"Alex Blandino", "Alex Bregman", "Alex Burnett", "Alex Castellanos",
"Alex Claudio", "Alex Cobb", "Alex Colome", "Alex Dickerson",
"Alex Gordon", "Alex Guerrero", "Alex Hassan", "Alex Jackson",
"Alex Katz", "Alex Liddi", "Alex McRae", "Alex Mejia", "Alex Meyer",
"Alex Presley", "Alex Reyes", "Alex Rios", "Alex Sanabia", "Alex Torres",
"Alex Verdugo", "Alex White", "Alex Wilson", "Alex Wimmers",
"Alex Wood", "Alexei Ramirez", "Alexi Amarista", "Alexi Casilla",
"Alexi Ogando", "Alfredo Aceves", "Alfredo Figaro", "Alfredo Gonzalez",
"Alfredo Marte", "Alfredo Simon", "Ali Solis", "Allan Dykstra",
"Allen Cordoba", "Allen Craig", "Allen Webster", "Amed Rosario",
"Amir Garrett", "Anderson Espinoza", "Andre Ethier", "Andre Rienzo",
"Andrelton Simmons", "Andres Blanco", "Andres Machado", "Andres Torres",
"Andrew Albers", "Andrew Aplin", "Andrew Bailey", "Andrew Bellatti",
"Andrew Benintendi", "Andrew Brown", "Andrew Carignan", "Andrew Case",
"Andrew Cashner", "Andrew Chafin", "Andrew Edwards", "Andrew Faulkner",
"Andrew Heaney", "Andrew Kittredge", "Andrew Knapp", "Andrew Lambo",
"Andrew McCutchen", "Andrew McKirahan", "Andrew Miller", "Andrew Moore",
.....................edited out cause that was too long data set

"Zac Curtis", "Zac Reininger", "Zac Rosscup", "Zach Borenstein",
"Zach Britton", "Zach Clark", "Zach Davies", "Zach Duke", "Zach Eflin",
"Zach Granite", "Zach Jemiola", "Zach Lee", "Zach Lovvorn", "Zach Lutz",
"Zach McAllister", "Zach Miner", "Zach Neal", "Zach Phillips",
"Zach Putnam", "Zach Stewart", "Zach Vincej", "Zach Walters",
"Zack Cozart", "Zack Godley", "Zack Greinke", "Zack Jones", "Zack Littell",
"Zack Weiss", "Zack Wheeler", "Zeke Spruill", "Zelous Wheeler",
"Zoilo Almonte"), class = "factor"), pitch_type = structure(c(7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L), .Label = c("",
"CH", "CU", "EP", "FA", "FC", "FF", "FO", "FS", "FT", "IN", "KC",
"KN", "null", "PO", "SC", "SI", "SL", "UN"), class = "factor"),
plate_x = c(-0.811, 0.4122, -0.8755, 0.5118, 1.8249, -0.9254,
0.6108, 1.0743, 0.8679, -0.1156, 0.1902, 0.5776, -0.3345,
0.93), plate_z = c(3.5851, 1.5006, 1.7496, 2.9315, 0.962,
1.5818, 1.7514, 1.5292, 1.7016, 1.3489, 4.5356, 2.6537, 4.1402,
1.717), Called_Strike = c(0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L,
1L, 0L, 0L, 1L, 0L, 1L), Ball = c(1L, 1L, 0L, 0L, 1L, 1L,
0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L), description = structure(c(1L,
1L, 3L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 3L), .Label = c("ball",
"blocked_ball", "called_strike", "foul", "foul_bunt", "foul_pitchout",
"foul_tip", "hit_by_pitch", "hit_into_play", "hit_into_play_no_out",
"hit_into_play_score", "intent_ball", "missed_bunt", "pitchout",
"pitchout_hit_into_play", "pitchout_hit_into_play_no_out",
"pitchout_hit_into_play_score", "swinging_pitchout", "swinging_strike",
"swinging_strike_blocked", "unknown_strike"), class = "factor")), row.names = c(5L,
6L, 8L, 9L, 11L, 15L, 16L, 21L, 23L, 26L, 28L, 30L, 36L, 38L), class = "data.frame")

Ok, now we can work seen at the same data, is this what you mean?

gary_530191_samp <- structure(list(catcher_name = structure(c(1063L, 1063L, 1063L, 
                                                              1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 
                                                              1063L, 1063L), .Label = c("A.J. Achter", "A.J. Cole", "A.J. Ellis", 
                                                                                        "A.J. Griffin", "A.J. Jimenez", "A.J. Minter", "A.J. Morris", 
                                                                                        "A.J. Pollock", "A.J. Ramos", "A.J. Reed", "A.J. Schugel", "Aaron Altherr", 
                                                                                        "Aaron Barrett", "Aaron Blair", "Aaron Brooks", "Aaron Bummer", 
                                                                                        "Aaron Crow", "Aaron Cunningham", "Aaron Harang", "Aaron Hicks", 
                                                                                        "Aaron Hill", "Aaron Judge", "Aaron Laffey", "Aaron Loup", "Aaron Nola", 
                                                                                        "Aaron Poreda", "Aaron Sanchez", "Aaron Slegers", "Aaron Thompson", 
                                                                                        "Aaron Wilkerson", "Abel De Los Santos", "Abiatal Avelino", "Abraham Almonte", 
                                                                                        "Adalberto Mejia", "Adam Cimber", "Adam Conley", "Adam Duvall", 
                                                                                        "Adam Eaton", "Adam Engel", "Adam Frazier", "Adam Jones", "Adam Kolarek", 
                                                                                        "Adam LaRoche", "Adam Liberatore", "Adam Lind", "Adam Loewen", 
                                                                                        "Adam McCreery", "Adam Moore", "Adam Morgan", "Adam Ottavino", 
                                                                                        "Adam Plutko", "Adam Rosales", "Adam Wainwright", "Adam Walker", 
                                                                                        "Adam Warren", "Adam Wilk", "Adbert Alzolay", "Addison Reed", 
                                                                                        "Addison Russell", "Adeiny Hechavarria", "Adolis Garcia", "Adonis Garcia", 
                                                                                        "Adonis Medina", "Adrian Beltre", "Adrian Gonzalez", "Adrian Houser", 
                                                                                        "Adrian Nieto", "Adrian Sampson", "Adrian Sanchez", "Adron Chambers", 
                                                                                        "Akeel Morris", "Al Alburquerque", "Alan Busenitz", "Albert Abreu", 
                                                                                        "Albert Almora Jr.", "Albert Pujols", "Albert Suarez", "Alberto Cabrera", 
                                                                                        "Alberto Callaspo", "Alberto Gonzalez", "Alberto Rosario", "Alberto Tirado", 
                                                                                        "Alcides Escobar", "Alec Asher", "Alec Mills", "Aledmys Diaz", 
                                                                                        "Alejandro Chacin", "Alejandro De Aza", "Alen Hanson", "Alex Avila", 
                                                                                        "Alex Blandino", "Alex Bregman", "Alex Burnett", "Alex Castellanos", 
                                                                                        "Alex Claudio", "Alex Cobb", "Alex Colome", "Alex Dickerson", 
                                                                                        "Alex Gordon", "Alex Guerrero", "Alex Hassan", "Alex Jackson", 
                                                                                        "Alex Katz", "Alex Liddi", "Alex McRae", "Alex Mejia", "Alex Meyer", 
                                                                                        "Alex Presley", "Alex Reyes", "Alex Rios", "Alex Sanabia", "Alex Torres", 
                                                                                        "Alex Verdugo", "Alex White", "Alex Wilson", "Alex Wimmers", 
                                                                                        "Alex Wood", "Alexei Ramirez", "Alexi Amarista", "Alexi Casilla", 
                                                                                        "Alexi Ogando", "Alfredo Aceves", "Alfredo Figaro", "Alfredo Gonzalez", 
                                                                                        "Alfredo Marte", "Alfredo Simon", "Ali Solis", "Allan Dykstra", 
                                                                                        "Allen Cordoba", "Allen Craig", "Allen Webster", "Amed Rosario", 
                                                                                        "Amir Garrett", "Anderson Espinoza", "Andre Ethier", "Andre Rienzo", 
                                                                                        "Andrelton Simmons", "Andres Blanco", "Andres Machado", "Andres Torres", 
                                                                                        "Andrew Albers", "Andrew Aplin", "Andrew Bailey", "Andrew Bellatti", 
                                                                                        "Andrew Benintendi", "Andrew Brown", "Andrew Carignan", "Andrew Case", 
                                                                                        "Andrew Cashner", "Andrew Chafin", "Andrew Edwards", "Andrew Faulkner", 
                                                                                        "Andrew Heaney", "Andrew Kittredge", "Andrew Knapp", "Andrew Lambo", 
                                                                                        "Andrew McCutchen", "Andrew McKirahan", "Andrew Miller", "Andrew Moore", 
                                                                                        "Zac Curtis", "Zac Reininger", "Zac Rosscup", "Zach Borenstein", 
                                                                                        "Zach Britton", "Zach Clark", "Zach Davies", "Zach Duke", "Zach Eflin", 
                                                                                        "Zach Granite", "Zach Jemiola", "Zach Lee", "Zach Lovvorn", "Zach Lutz", 
                                                                                        "Zach McAllister", "Zach Miner", "Zach Neal", "Zach Phillips", 
                                                                                        "Zach Putnam", "Zach Stewart", "Zach Vincej", "Zach Walters", 
                                                                                        "Zack Cozart", "Zack Godley", "Zack Greinke", "Zack Jones", "Zack Littell", 
                                                                                        "Zack Weiss", "Zack Wheeler", "Zeke Spruill", "Zelous Wheeler", 
                                                                                        "Zoilo Almonte"), class = "factor"), pitch_type = structure(c(7L, 
                                                                                                                                                      7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L), .Label = c("", 
                                                                                                                                                                                                                      "CH", "CU", "EP", "FA", "FC", "FF", "FO", "FS", "FT", "IN", "KC", 
                                                                                                                                                                                                                      "KN", "null", "PO", "SC", "SI", "SL", "UN"), class = "factor"), 
                                   plate_x = c(-0.811, 0.4122, -0.8755, 0.5118, 1.8249, -0.9254, 
                                               0.6108, 1.0743, 0.8679, -0.1156, 0.1902, 0.5776, -0.3345, 
                                               0.93), plate_z = c(3.5851, 1.5006, 1.7496, 2.9315, 0.962, 
                                                                  1.5818, 1.7514, 1.5292, 1.7016, 1.3489, 4.5356, 2.6537, 4.1402, 
                                                                  1.717), Called_Strike = c(0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 
                                                                                            1L, 0L, 0L, 1L, 0L, 1L), Ball = c(1L, 1L, 0L, 0L, 1L, 1L, 
                                                                                                                              0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L), description = structure(c(1L, 
                                                                                                                                                                                         1L, 3L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 3L), .Label = c("ball", 
                                                                                                                                                                                                                                                         "blocked_ball", "called_strike", "foul", "foul_bunt", "foul_pitchout", 
                                                                                                                                                                                                                                                         "foul_tip", "hit_by_pitch", "hit_into_play", "hit_into_play_no_out", 
                                                                                                                                                                                                                                                         "hit_into_play_score", "intent_ball", "missed_bunt", "pitchout", 
                                                                                                                                                                                                                                                         "pitchout_hit_into_play", "pitchout_hit_into_play_no_out", 
                                                                                                                                                                                                                                                         "pitchout_hit_into_play_score", "swinging_pitchout", "swinging_strike", 
                                                                                                                                                                                                                                                         "swinging_strike_blocked", "unknown_strike"), class = "factor")), row.names = c(5L, 
                                                                                                                                                                                                                                                                                                                                         6L, 8L, 9L, 11L, 15L, 16L, 21L, 23L, 26L, 28L, 30L, 36L, 38L), class = "data.frame")

OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.6
inKzone <- -0.95
outKzone <- 0.95
OShdwTop <- 3.83
IShdwtop <- 3.38
IShdBot <- 1.8
OShdBot <- 1.17

library(tidyverse)
library(ggrepel)

gary_530191_samp %>% 
    ggplot(aes(plate_x, plate_z)) +
    annotate("rect", xmin = OShdwIn, xmax = OShdwOut, ymin = OShdBot, ymax = OShdwTop,
             alpha = 0,
             color = "blue",
             lwd = .25) +
    annotate("rect", xmin = IShdwIn, xmax = IShdwOut, ymin = IShdBot, ymax = IShdwtop,
             alpha = 0,
             color = "blue",
             lwd = .25) +
    annotate("rect", xmin = inKzone, xmax = outKzone, ymin = botKzone, ymax = topKzone,
             alpha = 0,
             color = "green",
             lwd = .5,
             linetype = 2) +
    geom_point(aes(color = description)) +
    geom_text_repel(aes(label = description)) +
    coord_equal()

#  yes, that is exactly it.  thank you.
# curious as to your thoughts.  I am attempting to create the inner and out shadow zone in # the dataframe.  so I can isolate pitches that land in those zones.
# my initial approach is slow and tedious, but:
# I have started with simple ifelse statements that I intend or hope to join later:

gary_530191_samp$a <- ifelse((gary_530191_samp$plate_x <= 1.1) , 1 , 0)
gary_530191_samp$b <- ifelse((gary_530191_samp$plate_x >= 0.83) , 1 , 0)


### far left outer shadow
gary_530191_samp$d <- ifelse((gary_530191_samp$plate_x >= -1.1) , 1 , 0)
gary_530191_samp$e <- ifelse((gary_530191_samp$plate_x < -0.83) , 1 , 0)



### for upper outer shadow
gary_530191_samp$g <- ifelse((gary_530191_samp$plate_z <= 3.83) , 1 , 0)
gary_530191_samp$h <- ifelse((gary_530191_samp$plate_z > 3.5) , 1 , 0)



##### for bottom shadow 
gary_530191$j <- ifelse((gary_530191$plate_z < 1.5) , 1 , 0)
gary_530191$k <- ifelse((gary_530191$plate_z >= 1.17) , 1 , 0)

# so I figure now I need to build something like for no2
gary_530191_samp %>%
  mutate(shadow_outer = ifelse(
           c(a = 1 | g = 1) ,
           c(a = 1 | h = 1) ,
           c(a = 1 | j = 1) ,
           c(a = 1 | k = 1), 1 , 0)) -> gary_samp_530191

# but I believe there must be 1: a much easier way
# 2) something missing in the statement I have yet to try and enter(no2)

## I am curious of your thoughts to this approach

# also in my heart I believe these should have some value to make things easier

outerShadow <- data.frame(
x1 = c(OShdwIn , OShdwIn , OShdwOut , OShdwOut , OShdwIn) ,
y1 = c(OShdBot , OShdwTop , OShdwTop , OShdBot , OShdBot)
)
innerShadow <- data.frame(
x = c(IShdwIn , IShdwIn , IShdwOut , IShdwOut , IShdwIn) ,
y = c(IShdBot , IShdwtop , IShdwtop , IShdBot , IShdBot)
)

kZone <- data.frame(
x =c(inKzone , inKzone , outKzone , outKzone , inKzone),
y =c(botKzone , topKzone , topKzone , botKzone , botKzone)
)

 ## also . and thanks so much.  I need to study the codes and the differences for the 
## ggplots you sent later tonight.  

## same data:

gary_530191_samp <- structure(list(catcher_name = structure(c(1063L, 1063L, 1063L, 
                                                              1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 
                                                              1063L, 1063L), .Label = c("A.J. Achter", "A.J. Cole", "A.J. Ellis", 
                                                                                        "A.J. Griffin", "A.J. Jimenez", "A.J. Minter", "A.J. Morris", 
                                                                                        "A.J. Pollock", "A.J. Ramos", "A.J. Reed", "A.J. Schugel", "Aaron Altherr", 
                                                                                        "Aaron Barrett", "Aaron Blair", "Aaron Brooks", "Aaron Bummer", 
                                                                                        "Aaron Crow", "Aaron Cunningham", "Aaron Harang", "Aaron Hicks", 
                                                                                        "Aaron Hill", "Aaron Judge", "Aaron Laffey", "Aaron Loup", "Aaron Nola", 
                                                                                        "Aaron Poreda", "Aaron Sanchez", "Aaron Slegers", "Aaron Thompson", 
                                                                                        "Aaron Wilkerson", "Abel De Los Santos", "Abiatal Avelino", "Abraham Almonte", 
                                                                                        "Adalberto Mejia", "Adam Cimber", "Adam Conley", "Adam Duvall", 
                                                                                        "Adam Eaton", "Adam Engel", "Adam Frazier", "Adam Jones", "Adam Kolarek", 
                                                                                        "Adam LaRoche", "Adam Liberatore", "Adam Lind", "Adam Loewen", 
                                                                                        "Adam McCreery", "Adam Moore", "Adam Morgan", "Adam Ottavino", 
                                                                                        "Adam Plutko", "Adam Rosales", "Adam Wainwright", "Adam Walker", 
                                                                                        "Adam Warren", "Adam Wilk", "Adbert Alzolay", "Addison Reed", 
                                                                                        "Addison Russell", "Adeiny Hechavarria", "Adolis Garcia", "Adonis Garcia", 
                                                                                        "Adonis Medina", "Adrian Beltre", "Adrian Gonzalez", "Adrian Houser", 
                                                                                        "Adrian Nieto", "Adrian Sampson", "Adrian Sanchez", "Adron Chambers", 
                                                                                        "Akeel Morris", "Al Alburquerque", "Alan Busenitz", "Albert Abreu", 
                                                                                        "Albert Almora Jr.", "Albert Pujols", "Albert Suarez", "Alberto Cabrera", 
                                                                                        "Alberto Callaspo", "Alberto Gonzalez", "Alberto Rosario", "Alberto Tirado", 
                                                                                        "Alcides Escobar", "Alec Asher", "Alec Mills", "Aledmys Diaz", 
                                                                                        "Alejandro Chacin", "Alejandro De Aza", "Alen Hanson", "Alex Avila", 
                                                                                        "Alex Blandino", "Alex Bregman", "Alex Burnett", "Alex Castellanos", 
                                                                                        "Alex Claudio", "Alex Cobb", "Alex Colome", "Alex Dickerson", 
                                                                                        "Alex Gordon", "Alex Guerrero", "Alex Hassan", "Alex Jackson", 
                                                                                        "Alex Katz", "Alex Liddi", "Alex McRae", "Alex Mejia", "Alex Meyer", 
                                                                                        "Alex Presley", "Alex Reyes", "Alex Rios", "Alex Sanabia", "Alex Torres", 
                                                                                        "Alex Verdugo", "Alex White", "Alex Wilson", "Alex Wimmers", 
                                                                                        "Alex Wood", "Alexei Ramirez", "Alexi Amarista", "Alexi Casilla", 
                                                                                        "Alexi Ogando", "Alfredo Aceves", "Alfredo Figaro", "Alfredo Gonzalez", 
                                                                                        "Alfredo Marte", "Alfredo Simon", "Ali Solis", "Allan Dykstra", 
                                                                                        "Allen Cordoba", "Allen Craig", "Allen Webster", "Amed Rosario", 
                                                                                        "Amir Garrett", "Anderson Espinoza", "Andre Ethier", "Andre Rienzo", 
                                                                                        "Andrelton Simmons", "Andres Blanco", "Andres Machado", "Andres Torres", 
                                                                                        "Andrew Albers", "Andrew Aplin", "Andrew Bailey", "Andrew Bellatti", 
                                                                                        "Andrew Benintendi", "Andrew Brown", "Andrew Carignan", "Andrew Case", 
                                                                                        "Andrew Cashner", "Andrew Chafin", "Andrew Edwards", "Andrew Faulkner", 
                                                                                        "Andrew Heaney", "Andrew Kittredge", "Andrew Knapp", "Andrew Lambo", 
                                                                                        "Andrew McCutchen", "Andrew McKirahan", "Andrew Miller", "Andrew Moore", 
                                                                                        "Zac Curtis", "Zac Reininger", "Zac Rosscup", "Zach Borenstein", 
                                                                                        "Zach Britton", "Zach Clark", "Zach Davies", "Zach Duke", "Zach Eflin", 
                                                                                        "Zach Granite", "Zach Jemiola", "Zach Lee", "Zach Lovvorn", "Zach Lutz", 
                                                                                        "Zach McAllister", "Zach Miner", "Zach Neal", "Zach Phillips", 
                                                                                        "Zach Putnam", "Zach Stewart", "Zach Vincej", "Zach Walters", 
                                                                                        "Zack Cozart", "Zack Godley", "Zack Greinke", "Zack Jones", "Zack Littell", 
                                                                                        "Zack Weiss", "Zack Wheeler", "Zeke Spruill", "Zelous Wheeler", 
                                                                                        "Zoilo Almonte"), class = "factor"), pitch_type = structure(c(7L, 
                                                                                                                                                      7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L), .Label = c("", 
                                                                                                                                                                                                                      "CH", "CU", "EP", "FA", "FC", "FF", "FO", "FS", "FT", "IN", "KC", 
                                                                                                                                                                                                                      "KN", "null", "PO", "SC", "SI", "SL", "UN"), class = "factor"), 
                                   plate_x = c(-0.811, 0.4122, -0.8755, 0.5118, 1.8249, -0.9254, 
                                               0.6108, 1.0743, 0.8679, -0.1156, 0.1902, 0.5776, -0.3345, 
                                               0.93), plate_z = c(3.5851, 1.5006, 1.7496, 2.9315, 0.962, 
                                                                  1.5818, 1.7514, 1.5292, 1.7016, 1.3489, 4.5356, 2.6537, 4.1402, 
                                                                  1.717), Called_Strike = c(0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 
                                                                                            1L, 0L, 0L, 1L, 0L, 1L), Ball = c(1L, 1L, 0L, 0L, 1L, 1L, 
                                                                                                                              0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L), description = structure(c(1L, 
                                                                                                                                                                                         1L, 3L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 3L), .Label = c("ball", 
                                                                                                                                                                                                                                                         "blocked_ball", "called_strike", "foul", "foul_bunt", "foul_pitchout", 
                                                                                                                                                                                                                                                         "foul_tip", "hit_by_pitch", "hit_into_play", "hit_into_play_no_out", 
                                                                                                                                                                                                                                                         "hit_into_play_score", "intent_ball", "missed_bunt", "pitchout", 
                                                                                                                                                                                                                                                         "pitchout_hit_into_play", "pitchout_hit_into_play_no_out", 
                                                                                                                                                                                                                                                         "pitchout_hit_into_play_score", "swinging_pitchout", "swinging_strike", 
                                                                                                                                                                                                                                                         "swinging_strike_blocked", "unknown_strike"), class = "factor")), row.names = c(5L, 
                                                                                                                                                                                                                                                                                                                                         6L, 8L, 9L, 11L, 15L, 16L, 21L, 23L, 26L, 28L, 30L, 36L, 38L), class = "data.frame")

OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.6
inKzone <- -0.95
outKzone <- 0.95
OShdwTop <- 3.83
IShdwtop <- 3.38
IShdBot <- 1.8
OShdBot <- 1.17