0

I am creating shot plots for NHL games and I have succeeded in making the plot, but I would like to draw the lines that you see on a hockey rink on it. I basically just want to draw two circles and two lines on the plot like this.

Basically I am looking to get two circles and two lines in the plot

Let me know if this is possible/how I could do it

  • Does this answer your question? [Adding a background image to a plot with known corner coordinates](https://stackoverflow.com/questions/15160123/adding-a-background-image-to-a-plot-with-known-corner-coordinates) – Bill Huang Nov 28 '20 at 20:22

1 Answers1

0

Pandas plot is in fact matplotlib plot, you can assign it to variable and modify it according to your needs ( add horizontal and vertical lines or shapes, text, etc)

# plot your data, but instead diplaying it assing Figure and Axis to variables
fig, ax = df.plot() 
ax.vlines(x, ymin, ymax, colors='k', linestyles='solid') # adjust to your needs
plt.show()

working code sample

import pandas as pd 
import matplotlib.pyplot as plt
import seaborn
from matplotlib.patches import Circle
from matplotlib.collections import PatchCollection

df = seaborn.load_dataset('tips')

ax = df.plot.scatter(x='total_bill', y='tip')
ax.vlines(x=40, ymin=0, ymax=20, colors='red')

patches = [Circle((50,10), radius=3)]
collection = PatchCollection(patches, alpha=0.4)
ax.add_collection(collection)

plt.show()