Skip to main content

Plotly: all 32 teams' 2024 offensive and defensive EPA per play, as logos over hover points (the figure for Plotly.newPlot)

With JavaScript on, plotly.js draws this figure here.

{
  "data": [
    {
      "type": "scatter",
      "mode": "markers",
      "x": [
        0.06790171573137074,
        0.04094521739130435,
        0.1973075142071494,
        0.18687425633802818,
        -0.04087427192982456,
        -0.07460389633601429,
        0.10641586262265834,
        -0.17549994982993197,
        -0.08977916753022452,
        0.009665256694367498,
        0.15521151466666666,
        0.08039756022408964,
        -0.039517823421774935,
        -0.047262845581395346,
        -0.021526078048780487,
        0.06882989234875446,
        0.03389467877094972,
        0.045015692528735635,
        -0.1314928203971119,
        -0.04019005496453901,
        0.03697167798165138,
        -0.07891574768946395,
        -0.058756264814814815,
        -0.09175358839528558,
        0.00079420884289746,
        0.11059268379096546,
        -0.028511586486486485,
        -0.015515602954755311,
        0.060653246240601505,
        0.13204109929078015,
        -0.10142502022058823,
        0.13941898861646235
      ],
      "y": [
        0.05063307196261683,
        0.04434347766636281,
        -0.01809329170383586,
        -0.0031065497716894976,
        0.1544453020920502,
        -0.0011727630331753555,
        0.05469574553571428,
        0.01726238725023787,
        0.06770862234533703,
        -0.09817395888013998,
        -0.045118736890524376,
        -0.06768193482309125,
        -0.054001859245630175,
        0.006128741000877963,
        0.1270993804255319,
        0.005753912231559291,
        0.0496864036199095,
        -0.055508027726432534,
        0.014218293738489872,
        -0.021265579198473283,
        -0.08892758666666667,
        0.08302175858951175,
        0.035566412629757786,
        0.07050022532588454,
        0.04588688751107175,
        -0.08551938246628131,
        -0.02094945614035088,
        -0.01821089964157706,
        0.051679759276879164,
        0.016552372282608696,
        0.04975268552253116,
        0.04316543802423113
      ],
      "text": [
        "ARI",
        "ATL",
        "BAL",
        "BUF",
        "CAR",
        "CHI",
        "CIN",
        "CLE",
        "DAL",
        "DEN",
        "DET",
        "GB",
        "HOU",
        "IND",
        "JAX",
        "KC",
        "LA",
        "LAC",
        "LV",
        "MIA",
        "MIN",
        "NE",
        "NO",
        "NYG",
        "NYJ",
        "PHI",
        "PIT",
        "SEA",
        "SF",
        "TB",
        "TEN",
        "WAS"
      ],
      "hovertemplate": "%{text}<br>offence %{x:.3f}<br>defence %{y:.3f}<extra></extra>",
      "marker": {
        "size": 24,
        "opacity": 0
      }
    }
  ],
  "layout": {
    "width": 600,
    "height": 480,
    "xaxis": {
      "title": {
        "text": "Offensive EPA per play"
      },
      "range": [
        -0.25,
        0.25
      ]
    },
    "yaxis": {
      "title": {
        "text": "Defensive EPA per play allowed"
      },
      "range": [
        0.18,
        -0.12
      ]
    },
    "images": [
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/f8/f870b58b43585a5b7717d578dd433b0b1e0c462d64ef4bea2aeb8c03f4ae7854.png",
        "x": 0.06790171573137074,
        "y": 0.05063307196261683,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:22"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/fe/fe566e9da6f7986b2bac321571bd751247ff93af15c51ae555486fb1bee90c91.png",
        "x": 0.04094521739130435,
        "y": 0.04434347766636281,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:1"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/67/67796023c172c9aeab5bcdac9204823d3590097246ad1cb92971134b5f26dcc0.png",
        "x": 0.1973075142071494,
        "y": -0.01809329170383586,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:33"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/79/79b71e2f536ee29f9d23834e89828883af2d95bf6968cbd07a505444229cdd20.png",
        "x": 0.18687425633802818,
        "y": -0.0031065497716894976,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:2"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/2c/2cebc1bbdcfd89f28c1578b397f440d229d93fa9a30bfa1193cc286482c82298.png",
        "x": -0.04087427192982456,
        "y": 0.1544453020920502,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:29"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/fd/fd7b5a207b9ad443f950b384d43dba6cb367c5737ad50a51a15e3893fa31753b.png",
        "x": -0.07460389633601429,
        "y": -0.0011727630331753555,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:3"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/8e/8e549c0ecac92453140370b2aef3e4a140139b50d16e92507532e8ee49930d4e.png",
        "x": 0.10641586262265834,
        "y": 0.05469574553571428,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:4"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/9b/9b286fc4286dc39b1b5a6a08aab042b456ba5fdce99e45e49a4d1e2672411fa2.png",
        "x": -0.17549994982993197,
        "y": 0.01726238725023787,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:5"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/f4/f4ea9a2ec7d7d500f08db94c8c6f1b23f75361ffe39c4d4b480a684a511ce61e.png",
        "x": -0.08977916753022452,
        "y": 0.06770862234533703,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:6"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/c9/c98bec2be32e27b19f79f5da86ac6ef133c78d75ab78aadb28ef36696c3213e8.png",
        "x": 0.009665256694367498,
        "y": -0.09817395888013998,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:7"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/97/9776b567ebab0bd3640165e915d948d8e736e35967dfc19ce62b967cfe7b4eb1.png",
        "x": 0.15521151466666666,
        "y": -0.045118736890524376,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:8"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/7e/7ea8154cdbff5db84d248f235c1f1c78a1a8b4cb8c14335b5886ec10ee20b00e.png",
        "x": 0.08039756022408964,
        "y": -0.06768193482309125,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:9"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/54/54b0fe559761860e4953851c197d995b2f9c0c4e278164edda7b608ffd64f39b.png",
        "x": -0.039517823421774935,
        "y": -0.054001859245630175,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:34"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/f1/f1f5222a876f810956aa8d4e75d4e6b47bcb3a6d11f876642b674010233c8a97.png",
        "x": -0.047262845581395346,
        "y": 0.006128741000877963,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:11"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/15/15cb9a1c77ebfaea885d0d3a34f33dabc4e6a00eb7d5462148fceed641d49397.png",
        "x": -0.021526078048780487,
        "y": 0.1270993804255319,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:30"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/3d/3d77958dc6373768919bb2681cbe1b143f56c07a1f013460def665a5026a7f3d.png",
        "x": 0.06882989234875446,
        "y": 0.005753912231559291,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:12"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/e2/e289b738a5e1259cccea921bee02eec881d35b4241761a8c4e12fe5964cab75c.png",
        "x": 0.03389467877094972,
        "y": 0.0496864036199095,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:14"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/54/5400f85bd93129c056717a771da57a97225e15f39c0022107ce89ef993f15bb0.png",
        "x": 0.045015692528735635,
        "y": -0.055508027726432534,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:24"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/25/25fbb03e972ae872fa024026b73c7b63ef9f23c2f2c51f87d1614d800dcee6e7.png",
        "x": -0.1314928203971119,
        "y": 0.014218293738489872,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:13"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/b9/b9631269a82abda39bd748afc82390679ca67bfc167bc3581665e237407de8e0.png",
        "x": -0.04019005496453901,
        "y": -0.021265579198473283,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:15"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/72/72759956b149bc1c9496ea6ebb9a6ae34093dfed371cc6abb425c13f14f53448.png",
        "x": 0.03697167798165138,
        "y": -0.08892758666666667,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:16"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/da/dac19aa9a573dcf9075e2422bee3e35a4955b9ab494bb3191ab3bacfd3609729.png",
        "x": -0.07891574768946395,
        "y": 0.08302175858951175,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:17"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/68/68ddfdf1d7ee8317f1af083a0c6d59142a11e8af4dad73c3c50bbafc338e0a94.png",
        "x": -0.058756264814814815,
        "y": 0.035566412629757786,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:18"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/62/62e361850e7ba3a50dfd09cbb38429e994d1c23b0f999c74421f10e37c7067e7.png",
        "x": -0.09175358839528558,
        "y": 0.07050022532588454,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:19"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/5d/5de8d029f3602c97ffe02bd636eb2630e55d019d1a37cf819d3b9e39a219487b.png",
        "x": 0.00079420884289746,
        "y": 0.04588688751107175,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:20"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/28/2875f50f8b756ed5ea3866105b4683f5c603aa542e2c7f7870287e1d3d006100.png",
        "x": 0.11059268379096546,
        "y": -0.08551938246628131,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:21"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/80/806bcb72e75ed184a99bea34df458e6cd87145fc9a863945f3356b01122aeb6f.png",
        "x": -0.028511586486486485,
        "y": -0.02094945614035088,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:23"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/25/2546b1d4fe5cf6c2d75cda53d3fb56bbc4dd43c6b00200586dab5a85df8fa492.png",
        "x": -0.015515602954755311,
        "y": -0.01821089964157706,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:26"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/82/82ae812f6c15718ce5abdd402863e8b4553fa9971e4baa5d45ff585c52948a45.png",
        "x": 0.060653246240601505,
        "y": 0.051679759276879164,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:25"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/bc/bcc5d267024650938c9f35558077fe00a31913b89c61768d4ebb63d1ea31fbfd.png",
        "x": 0.13204109929078015,
        "y": 0.016552372282608696,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:27"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/27/27cf283fca5b2e9e1c5e995a465a54223424c157d2013b603a6491f99333cf45.png",
        "x": -0.10142502022058823,
        "y": 0.04975268552253116,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:10"
      },
      {
        "source": "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/sha256/2f/2f67805ef9e385a4c67adb0a9320706bd481a52e3aa0e0faea995dad2b501112.png",
        "x": 0.13941898861646235,
        "y": 0.04316543802423113,
        "xref": "x",
        "yref": "y",
        "sizex": 1,
        "sizey": 0.021,
        "sizing": "contain",
        "xanchor": "center",
        "yanchor": "middle",
        "opacity": 1,
        "layer": "above",
        "name": "sdvplot:logo:28"
      }
    ]
  }
}
import { NFL_TEAM_EPA_2024 } from "@sportsdataverse/examples/data";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { withLogos } from "@sportsdataverse/sdvplot/plotly";

await loadLeague("nfl");
const rows = NFL_TEAM_EPA_2024.map((t) => ({
team: t.team,
off: t.off_epa / t.off_plays,
def: t.def_epa / t.def_plays,
}));
const figure = {
data: [
{
type: "scatter",
mode: "markers",
x: rows.map((r) => r.off),
y: rows.map((r) => r.def),
text: rows.map((r) => r.team),
hovertemplate: "%{text}<br>offence %{x:.3f}<br>defence %{y:.3f}<extra></extra>",
// invisible markers under the logos: layout images take no hover, the trace does
marker: { size: 24, opacity: 0 },
},
],
layout: {
width: 600,
height: 480,
xaxis: { title: { text: "Offensive EPA per play" }, range: [-0.25, 0.25] },
// a descending range reverses the axis: a good defence allows negative EPA, so the best teams sit top right
yaxis: { title: { text: "Defensive EPA per play allowed" }, range: [0.18, -0.12] },
},
};

// The images follow the axes as Plotly draws them, the reversed y axis included.
const logos = withLogos(figure, rows, { league: "nfl", x: "off", y: "def", team: "team", height: 0.07 });
// In the browser: Plotly.newPlot(div, data, layout), as this page does. Without JavaScript the page shows the figure.
export const browser = {
lib: "plotly",
figure: logos,
label:
"Every NFL team's 2024 offensive EPA per play against defensive EPA per play allowed, each team drawn as its logo, the best teams top right",
} as const;

logos;

Tags: plotly · withLogos · epa · nfl. All sdvplot examples.