0

I am plotting coordinates in order to have same result of this pitch (plotting only green X)enter image description here

But my result is not exact, points are shifted up and right:enter image description here

This is my code

import matplotlib.pyplot as plt
import matplotlib
import numpy as np

im = plt.imread('statszone_football_pitch.png')
implot = plt.imshow(im, aspect='auto')
xlim, ylim = plt.xlim(), plt.ylim()

dpi=90


fig = plt.figure(figsize=(620/dpi, 579/dpi), dpi=dpi)
ax = fig.add_axes([0, 0, 1, 1], frame_on=False)
#ax.xaxis.set_visible(False)
#ax.yaxis.set_visible(False)
ax.imshow(im, interpolation='none')

y, x = np.genfromtxt('coordinate_tackle_success.csv', delimiter=',', unpack=True)
plt.plot(x,y, "o")
plt.xlim(xlim)
plt.ylim(ylim)

plt.savefig('tackles.png')

1 Answer 1

1

In ax.imshow, you could add the extent argument to influence the placement of the image.

Sign up to request clarification or add additional context in comments.

3 Comments

How do i set extent in this case?
You add it as a named argument to the imshow call. See the documentation that I linked to.
Well using the size of the pitch as extent ([0,760,0,520]) I have bad positioning as before

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.