Skip to content

Commit

Permalink
bump: 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdur-rahmaanJ committed Apr 26, 2022
1 parent bff0ac4 commit 5aed1f6
Show file tree
Hide file tree
Showing 9 changed files with 526 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.7.0

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

### 0.6.0

Expand Down
118 changes: 118 additions & 0 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
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, 6, 0)
version_info = (0, 7, 0)
__version__ = ".".join([str(v) for v in version_info])
205 changes: 205 additions & 0 deletions hooman/demos/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions hooman/demos/scatter_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
500,
{
"data": data,
"ticks_y": 8,
"ticks_x": 5,
"mouse_line": False,
"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,
Expand All @@ -45,7 +43,7 @@
"plot_background_color": (234,234,242),
"plot_background_grid_color": 200,
"line_color": 200
},
}
)

while hapi.is_running:
Expand Down
65 changes: 47 additions & 18 deletions hooman/demos/test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")

# Load the example diamonds dataset
diamonds = sns.load_dataset("diamonds")

# Draw a scatter plot while assigning point colors and sizes to different
# variables in the dataset
f, ax = plt.subplots(figsize=(6.5, 6.5))
sns.despine(f, left=True, bottom=True)
clarity_ranking = ["I1", "SI2", "SI1", "VS2", "VS1", "VVS2", "VVS1", "IF"]
sns.scatterplot(x="carat", y="price",
hue="clarity", size="depth",
palette="ch:r=-.2,d=.3_r",
hue_order=clarity_ranking,
sizes=(1, 8), linewidth=0,
data=diamonds, ax=ax)
# 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'))
Loading

0 comments on commit 5aed1f6

Please sign in to comment.