Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adhaamehab committed Jan 6, 2019
0 parents commit 82231c6
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 0 deletions.
117 changes: 117 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

.vscode/
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Socplot

Socplot is a python 3 package that helps you visualize football data. __[WIP]__


## Why Socplot?

- Made by [football enthusiast](www.arqamfc.com).
- Fully configurable in terms of dimensions, colors and types.
- Lightweight and Flexibility: Socplot is built on top of matplotlib. You have full control.
- Straightforward: Socplot has many built in figures that gets you directly to the point.

## Installation

pip installtion coming soon

## Dev Installation

```shell
# fork the repo
cd socplot
virtualenv -p python3 env
source env/bin/activate
pip install -r requirements.txt
```
4 changes: 4 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Contributing
----

All contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
48 changes: 48 additions & 0 deletions docs/code-of-conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Code of Conduct v2.0

This code of conduct outlines our expectations for participants within the [@ArqamFC](https://github.com/arqamfc) community, as well as steps to reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community.

Our open source community strives to:

* **Be friendly and patient.**
* **Be welcoming**: We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
* **Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language.
* **Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one.
* **Be careful in the words that you choose**: we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren't acceptable. This includes, but is not limited to:
* Violent threats or language directed against another person.
* Discriminatory jokes and language.
* Posting sexually explicit or violent material.
* Posting (or threatening to post) other people's personally identifying information ("doxing").
* Personal insults, especially those using racist or sexist terms.
* Unwelcome sexual attention.
* Advocating for, or encouraging, any of the above behavior.
* Repeated harassment of others. In general, if someone asks you to stop, then stop.
* **When we disagree, try to understand why**: Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.

This code is not exhaustive or complete. It serves to distill our common understanding of a collaborative, shared environment, and goals. We expect it to be followed in spirit as much as in the letter.

### Diversity Statement

We encourage everyone to participate and are committed to building a community for all. Although we may not be able to satisfy everyone, we all agree that everyone is equal. Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do our best to right the wrong.

Although this list cannot be exhaustive, we explicitly honor diversity in age, gender, gender identity or expression, culture, ethnicity, language, national origin, political beliefs, profession, race, religion, sexual orientation, socioeconomic status, and technical ability. We will not tolerate discrimination based on any of the protected
characteristics above, including participants with disabilities.

### Reporting Issues

If you experience or witness unacceptable behavior—or have any other concerns—please report it by contacting us via [[email protected]](mailto:[email protected]). All reports will be handled with discretion. In your report please include:

- Your contact information.
- Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional witnesses, please
include them as well. Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public IRC logger), please include a link.
- Any additional information that may be helpful.

After filing a report, a representative will contact you personally. If the person who is harassing you is part of the response team, they will recuse themselves from handling your incident. A representative will then review the incident, follow up with any additional questions, and make a decision as to how to respond. We will respect confidentiality requests for the purpose of protecting victims of abuse.

Anyone asked to stop unacceptable behavior is expected to comply immediately. If an individual engages in unacceptable behavior, the representative may take any action they deem appropriate, up to and including a permanent ban from our community without warning.

## Thanks

This code of conduct is based on the [Open Code of Conduct](https://github.com/todogroup/opencodeofconduct) from the [TODOGroup](http:https://todogroup.org).

We are thankful for their work and all the communities who have paved the way with code of conducts.
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cycler==0.10.0
kiwisolver==1.0.1
matplotlib==3.0.2
numpy==1.15.4
pyparsing==2.3.0
python-dateutil==2.7.5
six==1.12.0
Empty file added socplot/__init__.py
Empty file.
75 changes: 75 additions & 0 deletions socplot/pitch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Arc, Circle, ConnectionPatch, Rectangle


class Pitch:

# default dims to match ArqamFc data
__width = 120
__hight = 80
__fig_size = (12, 8)

def __init__(self):
fig, ax = plt.subplots(figsize=self.__fig_size)
ax.axis('off') # this hides the x and y ticks
plt.ylim(-2, 82)
plt.xlim(-2, 122)
pitch_components = self.__build_pitch(ax)
for c in pitch_components:
ax.add_artist(c)

self._plt = plt
self._ax = ax

def show(self):
self._plt.show()

def draw_player(self, x, y, number=False, color=''):
if not color:
color = 'red'
p = Circle((x, y), 1.5, color=color)
self._ax.add_artist(p)
if number:
self._ax.annotate(number, xy=(x-0.9, y-0.3), fontsize=7) # align the text with the circle

def draw_pass(self, start, end, pass_type='low',color=''):
if not color:
color = ''

if pass_type == 'low':
line = '-'
elif pass_type == 'ground':
line = '-^'
elif pass_type == 'high':
line = '-*'
if self.__valid_position(start) or self.__valid_position(end):
raise TypeError('Location should be in range (0~120)(0~80)')
self._plt.plot(
[start[0], end[0]],
[start[1], end[1]], line, color=color)
self._plt.plot(start[0], start[1], "o", color='green')

def __valid_position(self, loc):
return loc[0] < 0 or loc[1] < 0 or loc[0] > self.__width or loc[1] > self.__hight
def __build_pitch(self, ax):

return [
Rectangle((0, 0), width=self.__width, height=self.__hight,
fill=False, color='grey'), # pitch
Rectangle([0, 22.3], width=14.6, height=35.3,
fill=False), # left penalty area
Rectangle([105.4, 22.3], width=14.6, height=35.3,
fill=False), # right penalty area
ConnectionPatch([60, 0], [60, 80], "data", "data"),
Rectangle([0, 32], width=4.9, height=16, fill=False),
Rectangle([115.1, 32], width=4.9, height=16, fill=False),
plt.Circle((60, 40), 9.1, color="black", fill=False),
plt.Circle((60, 40), 0.33, color="black"),
plt.Circle((9.7, 40), 0.33, color="black"),
plt.Circle((110.3, 40), 0.33, color="black"),
Arc((9.7, 40), height=16.2, width=16.2, angle=0,
theta1=310, theta2=50, color="black"),
Arc((110.3, 40), height=16.2, width=16.2, angle=0,
theta1=130, theta2=230, color="black")
]

0 comments on commit 82231c6

Please sign in to comment.