Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Abdur-rahmaanJ/hooman
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBigKahuna353 committed May 2, 2022
2 parents 4c9792d + 45a528c commit 2f34a03
Show file tree
Hide file tree
Showing 26 changed files with 1,936 additions and 496 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### 0.7.0

- SVG generation support
- Keyword arguments supported in addition to dictionary

### 0.6.0

- Enhanced line chart
- Enhanced scatter plot
- Add scatter plot hist


### 0.5.0


Expand Down
309 changes: 245 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The package for clearer, shorter and cleaner PyGame codebases!

Fun fact: Codementor.io [tweeted about Hooman](https://twitter.com/CodementorIO/status/1306295790441246725?s=20) tagged #LearnPython #100DaysOfCode

NEW: save to svg now supported

# hooman is powerful!

See a snake game by [TheBigKahuna353](https://github.com/TheBigKahuna353)
Expand Down Expand Up @@ -165,6 +167,122 @@ For about the same number of lines for a simple snake game, you get one complete
- [Display most frequent words using PyGame](https://www.pythonkitchen.com/display-most-frequent-words-python-pygame/)
- [Realtime CPU monitor using PyGame](https://www.pythonkitchen.com/realtime-cpu-monitor-using-pygame/)

# (new) save to svg

```python
# https://github.com/mwaskom/seaborn-data/blob/master/penguins.csv

from hooman import Hooman
import pandas as pd
import os

window_width, window_height = 650, 600
hapi = Hooman(window_width, window_height, svg=True)


base_path = os.path.dirname(os.path.abspath(__file__))
df = pd.read_csv(os.path.join(base_path, "data", "penguins.csv"))
df = df.fillna(0)

data = {k:list(df[k]) for k in df.columns.values.tolist()}

hapi.background(255)

colx = "bill_length_mm"
coly = "bill_depth_mm"

hapi.scatterchart(
40,
30,
500,
500,
{
"data": data,
"ticks_y": 12,
"ticks_x": 12,
"range_y": [min(data[coly]), max(data[coly])],
"range_x": [min(data[colx]), max(data[colx])],
"show_axes": True,
"tick_size": 10,
"show_ticks_x": True,
"show_ticks_y": True,
"x": colx,
"y": coly,
"plot_background": False,
"plot_grid": False,
"line_color": 200,
"type": "hist",
"hist_color": "g"
},
)

hapi.save_svg(os.path.join(base_path, 'file.svg'))
```

# (new) keyword argument same as dictionary


```python
hapi.scatterchart(
40,
30,
500,
500,
{
"data": data,
"ticks_x": 5,
"mouse_line": False,
"range_y": [min(data[coly]), max(data[coly])],
"range_x": [min(data[colx]), max(data[colx])],
"tick_size": 10,
"show_ticks_x": True,
"show_ticks_y": True,
"x": colx,
"y": coly,
"hue": "clarity",
"hue_order": clarity_ranking,
"size": "depth",
"plot_background": False,
"plot_background_grid": True,
"plot_background_color": (234,234,242),
"plot_background_grid_color": 200,
"line_color": 200
}
)

# same as

hapi.scatterchart(
40,
30,
500,
500,
{
"data": data,
"ticks_x": 5,
"mouse_line": False,
"range_y": [min(data[coly]), max(data[coly])],
"range_x": [min(data[colx]), max(data[colx])],
"tick_size": 10,
"show_ticks_x": True,
"show_ticks_y": True,
"hue": "clarity",
"hue_order": clarity_ranking,
"size": "depth",
"plot_background": False,
"plot_background_grid": True,
"plot_background_color": (234,234,242),
"plot_background_grid_color": 200,
"line_color": 200
},
x=colx,
y=coly
)

# i.e you can mix both or use one option over the other

```

# demos

![](assets/color_change.gif)
Expand Down Expand Up @@ -676,6 +794,65 @@ while hapi.is_running:
hapi.event_loop()
```

#### scatter plot hist


![](assets/scatter_chart_hist.png)

```python
# https://github.com/mwaskom/seaborn-data/blob/master/penguins.csv

from hooman import Hooman
import pandas as pd
import os

window_width, window_height = 650, 600
hapi = Hooman(window_width, window_height)


base_path = os.path.dirname(os.path.abspath(__file__))
df = pd.read_csv(os.path.join(base_path, "data", "penguins.csv"))
df = df.fillna(0)

data = {k:list(df[k]) for k in df.columns.values.tolist()}

hapi.background(255)

colx = "bill_length_mm"
coly = "bill_depth_mm"

hapi.scatterchart(
40,
30,
500,
500,
{
"data": data,
"ticks_y": 12,
"ticks_x": 12,
"range_y": [min(data[coly]), max(data[coly])],
"range_x": [min(data[colx]), max(data[colx])],
"show_axes": True,
"tick_size": 10,
"show_ticks_x": True,
"show_ticks_y": True,
"x": colx,
"y": coly,
"plot_background": False,
"plot_grid": False,
"line_color": 200,
"type": "hist",
"hist_color": "b"
},
)

while hapi.is_running:
bg_col = (255, 255, 255)

hapi.flip_display()
hapi.event_loop()
```

# All Demos

- [Buttons.py](https://github.com/Abdur-rahmaanJ/hooman/tree/master/hooman/demos/Buttons.py)
Expand Down Expand Up @@ -1266,33 +1443,33 @@ hapi.barchart(x, y, w, h, params)

```python
params = {
"ticks_y": 10,
"ticks_x": 10,
"tick_size": 5,
"range_y": [0, 100],
"range_x": [0, 100],
"lines":[{
"label": "---",
"color": (255, 0, 0),
"data": [[1,1]],
"values_window": 200
}],
"labels": ["apple", "", "", "tree"],
"line_color": (200, 200, 200),
"text_color": (100, 100, 100),
"mouse_line": False,
"mouse_line_color": (255, 0, 0),
"graph_color": (0, 0, 0),
"show_axes": True,
"show_ticks_x": True,
"show_ticks_y": True,
"x_axis_label": "x_axis_label",
"y_axis_label": "y_axis_label",
"plot_background": True,
"plot_background_grid": True,
"plot_background_color": (234,234,242),
"plot_background_grid_color": 255
}
"ticks_y": 10,
"ticks_x": 10,
"tick_size": 5,
"range_y": [0, 100],
"range_x": [0, 100],
"lines":[{
"label": "---",
"color": (255, 0, 0),
"data": [[1,1]],
"values_window": 200
}],
"labels": ["apple", "", "", "tree"],
"line_color": (200, 200, 200),
"text_color": (100, 100, 100),
"mouse_line": False,
"mouse_line_color": (255, 0, 0),
"graph_color": (0, 0, 0),
"show_axes": True,
"show_ticks_x": True,
"show_ticks_y": True,
"x_axis_label": "x_axis_label",
"y_axis_label": "y_axis_label",
"plot_background": True,
"plot_grid": True,
"plot_background_color": (234,234,242),
"plot_grid_color": 255
}
hapi.linechart(x, y, w, h, params)
```

Expand All @@ -1301,43 +1478,47 @@ hapi.linechart(x, y, w, h, params)

```python
params = {
"ticks_y": 10,
"ticks_x": 10,
"tick_size": 5,
"range_y": [0, 100],
"range_x": [0, 100],
"data": { # just add in the format <column name>: values
"carat": [0.23, 0.21, 0.23, 0.29, 0.31, 0.24, 0.24, 0.26, 0.22, 0.23],
"cut": ["Ideal", "Premium", "Good", "Premium", "Good", "Very Good", "Very Good", "Very Good", "Fair"],
"color": ["E", "E", "E", "I", "J", "J", "I", "H", "E", "H"],
"clarity": ["SI2", "SI1", "VS1", "VS2", "SI2", "VVS2", "VVS1", "SI1", "VS2", "VS1"],
"depth": [61.5, 59.8, 56.9, 62.4, 63.3, 62.8, 62.3, 61.9, 65.1, 59.4],
"table": [55, 61, 65, 58, 58, 57, 57, 55, 61, 61],
"price": [326, 326, 327, 334, 335, 336, 336, 337, 337, 338],
"x": [3.95, 3.89, 4.05, 4.2, 4.34, 3.94, 3.95, 4.07, 3.87, 4],
"y": [3.98, 3.84, 4.07, 4.23, 4.35, 3.96, 3.98, 4.11, 3.78, 4.05],
"z": [2.43, 2.31, 2.31, 2.63, 2.75, 2.48, 2.47, 2.53, 2.49, 2.39]
},
"hue": "clarity",
"size": "depth",
"text_color": (100, 100, 100),
"mouse_line": False,
"mouse_line_color": (255, 0, 0),
"graph_color": (0, 0, 0),
"show_axes": True,
"show_ticks_x": True,
"show_ticks_y": True,
"x": "price",
"y": "carat",
"plot_background": True,
"plot_background_grid": True,
"plot_background_color": (234,234,242),
"plot_background_grid_color": 255,
"line_color": 200,
"strong_color": (107, 107, 255),
"light_color": (235, 235, 255)
}
hapi.scatterchart(hapi, x, y, w, h, params)
"ticks_y": 10,
"ticks_x": 10,
"tick_size": 5,
"range_y": [0, 100],
"range_x": [0, 100],
"data": {
"carat": [0.23, 0.21, 0.23, 0.29, 0.31, 0.24, 0.24, 0.26, 0.22, 0.23],
"cut": ["Ideal", "Premium", "Good", "Premium", "Good", "Very Good", "Very Good", "Very Good", "Fair"],
"color": ["E", "E", "E", "I", "J", "J", "I", "H", "E", "H"],
"clarity": ["SI2", "SI1", "VS1", "VS2", "SI2", "VVS2", "VVS1", "SI1", "VS2", "VS1"],
"depth": [61.5, 59.8, 56.9, 62.4, 63.3, 62.8, 62.3, 61.9, 65.1, 59.4],
"table": [55, 61, 65, 58, 58, 57, 57, 55, 61, 61],
"price": [326, 326, 327, 334, 335, 336, 336, 337, 337, 338],
"x": [3.95, 3.89, 4.05, 4.2, 4.34, 3.94, 3.95, 4.07, 3.87, 4],
"y": [3.98, 3.84, 4.07, 4.23, 4.35, 3.96, 3.98, 4.11, 3.78, 4.05],
"z": [2.43, 2.31, 2.31, 2.63, 2.75, 2.48, 2.47, 2.53, 2.49, 2.39]
},
"hue": None,
"hue_order": [],
"size": None,
"text_color": (100, 100, 100),
"mouse_line": False,
"mouse_line_color": (255, 0, 0),
"graph_color": (0, 0, 0),
"show_axes": True,
"show_ticks_x": True,
"show_ticks_y": True,
"x": "price",
"y": "carat",
"plot_background": True,
"plot_grid": True,
"plot_background_color": (234,234,242),
"plot_grid_color": 255,
"line_color": 200,
"strong_color": (107, 107, 255),
"light_color": (235, 235, 255),
"type": "normal",
"kind": "rect",
"hist_color": "b",
"hist_color_invert": False
}

```

Expand Down
Binary file added assets/scatter_chart_hist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hooman/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .hooman import Hooman
from .formula import *

version_info = (0, 5, 0)
version_info = (0, 7, 1)
__version__ = ".".join([str(v) for v in version_info])
Loading

0 comments on commit 2f34a03

Please sign in to comment.