squarify 0.4.2__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- squarify-0.4.4/LICENSE.txt +13 -0
- squarify-0.4.4/PKG-INFO +15 -0
- squarify-0.4.4/README.md +219 -0
- {squarify-0.4.2 → squarify-0.4.4}/setup.py +7 -6
- {squarify-0.4.2 → squarify-0.4.4}/squarify/__init__.py +10 -5
- squarify-0.4.4/squarify.egg-info/PKG-INFO +15 -0
- {squarify-0.4.2 → squarify-0.4.4}/squarify.egg-info/SOURCES.txt +3 -1
- squarify-0.4.4/tests/test_squarify.py +49 -0
- squarify-0.4.2/PKG-INFO +0 -15
- squarify-0.4.2/README.md +0 -124
- squarify-0.4.2/squarify.egg-info/PKG-INFO +0 -15
- {squarify-0.4.2 → squarify-0.4.4}/setup.cfg +0 -0
- {squarify-0.4.2 → squarify-0.4.4}/squarify.egg-info/dependency_links.txt +0 -0
- {squarify-0.4.2 → squarify-0.4.4}/squarify.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2013 Uri Laserson
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
squarify-0.4.4/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: squarify
|
|
3
|
+
Version: 0.4.4
|
|
4
|
+
Summary: Pure Python implementation of the squarify treemap layout algorithm
|
|
5
|
+
Home-page: https://github.com/laserson/squarify
|
|
6
|
+
Author: Uri Laserson
|
|
7
|
+
Author-email: uri.laserson@gmail.com
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Keywords: treemap visualization squarify layout graphics
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
License-File: LICENSE.txt
|
squarify-0.4.4/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
squarify
|
|
2
|
+
========
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
Pure Python implementation of the squarify treemap layout algorithm.
|
|
9
|
+
|
|
10
|
+
Based on algorithm from [Bruls, Huizing, van Wijk, "Squarified Treemaps"](https://doi.org/10.1007/978-3-7091-6783-0_4), but
|
|
11
|
+
implements it differently.
|
|
12
|
+
|
|
13
|
+
## Contents
|
|
14
|
+
|
|
15
|
+
* [Installation](#Installation)
|
|
16
|
+
* [Usage](#Usage)
|
|
17
|
+
* [Example](#Example)
|
|
18
|
+
* [Documentation](#Documentation-for-Squarify)
|
|
19
|
+
|
|
20
|
+
Installation
|
|
21
|
+
------------
|
|
22
|
+
|
|
23
|
+
Compatible with Python 2 and Python 3.
|
|
24
|
+
|
|
25
|
+
pip install squarify
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Usage
|
|
29
|
+
-----
|
|
30
|
+
|
|
31
|
+
The main function is `squarify` and it requires two things:
|
|
32
|
+
|
|
33
|
+
* A coordinate system comprising values for the origin (`x` and `y`) and the
|
|
34
|
+
width/height (`dx` and `dy`).
|
|
35
|
+
* A list of positive values sorted from largest to smallest and normalized to
|
|
36
|
+
the total area, i.e., `dx * dy`).
|
|
37
|
+
|
|
38
|
+
The function returns a list of `dict`s (i.e., JSON objects), each one a
|
|
39
|
+
rectangle with coordinates corresponding to the given coordinate system and area
|
|
40
|
+
proportional to the corresponding value. Here's an example rectangle:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"x": 0.0,
|
|
45
|
+
"y": 0.0,
|
|
46
|
+
"dx": 327.7,
|
|
47
|
+
"dy": 433.0
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The rectangles can be easily plotted using, for example,
|
|
52
|
+
[d3.js](http://d3js.org/).
|
|
53
|
+
|
|
54
|
+
There is also a version of `squarify` called `padded_squarify` that returns
|
|
55
|
+
rectangles that, when laid out, have a bit of padding to show their borders.
|
|
56
|
+
|
|
57
|
+
The helper function `normalize_sizes` will compute the normalized values, and
|
|
58
|
+
the helper function `plot` will generate a Matplotlib-based treemap
|
|
59
|
+
visualization of your data (see [documentation](#Documentation-for-Squarify)).
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
Example
|
|
63
|
+
-------
|
|
64
|
+
```python
|
|
65
|
+
import squarify
|
|
66
|
+
|
|
67
|
+
# these values define the coordinate system for the returned rectangles
|
|
68
|
+
# the values will range from x to x + width and y to y + height
|
|
69
|
+
x = 0.
|
|
70
|
+
y = 0.
|
|
71
|
+
width = 700.
|
|
72
|
+
height = 433.
|
|
73
|
+
|
|
74
|
+
values = [500, 433, 78, 25, 25, 7]
|
|
75
|
+
|
|
76
|
+
# values must be sorted descending (and positive, obviously)
|
|
77
|
+
values.sort(reverse=True)
|
|
78
|
+
|
|
79
|
+
# the sum of the values must equal the total area to be laid out
|
|
80
|
+
# i.e., sum(values) == width * height
|
|
81
|
+
values = squarify.normalize_sizes(values, width, height)
|
|
82
|
+
|
|
83
|
+
# returns a list of rectangles
|
|
84
|
+
rects = squarify.squarify(values, x, y, width, height)
|
|
85
|
+
|
|
86
|
+
# padded rectangles will probably visualize better for certain cases
|
|
87
|
+
padded_rects = squarify.padded_squarify(values, x, y, width, height)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The variable `rects` contains
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
[
|
|
94
|
+
{
|
|
95
|
+
"dy": 433,
|
|
96
|
+
"dx": 327.7153558052434,
|
|
97
|
+
"x": 0,
|
|
98
|
+
"y": 0
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"dy": 330.0862676056338,
|
|
102
|
+
"dx": 372.2846441947566,
|
|
103
|
+
"x": 327.7153558052434,
|
|
104
|
+
"y": 0
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"dy": 102.9137323943662,
|
|
108
|
+
"dx": 215.0977944236371,
|
|
109
|
+
"x": 327.7153558052434,
|
|
110
|
+
"y": 330.0862676056338
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"dy": 102.9137323943662,
|
|
114
|
+
"dx": 68.94160077680677,
|
|
115
|
+
"x": 542.8131502288805,
|
|
116
|
+
"y": 330.0862676056338
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"dy": 80.40135343309854,
|
|
120
|
+
"dx": 88.24524899431273,
|
|
121
|
+
"x": 611.7547510056874,
|
|
122
|
+
"y": 330.0862676056338
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"dy": 22.51237896126767,
|
|
126
|
+
"dx": 88.2452489943124,
|
|
127
|
+
"x": 611.7547510056874,
|
|
128
|
+
"y": 410.4876210387323
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Documentation for [Squarify](squarify/__init__.py)
|
|
134
|
+
---------
|
|
135
|
+
|
|
136
|
+
`normalize_sizes(sizes, dx, dy)`
|
|
137
|
+
: Normalize list of values.
|
|
138
|
+
|
|
139
|
+
Normalizes a list of numeric values so that `sum(sizes) == dx * dy`.
|
|
140
|
+
|
|
141
|
+
**Parameters**
|
|
142
|
+
|
|
143
|
+
sizes : list-like of numeric values
|
|
144
|
+
Input list of numeric values to normalize.
|
|
145
|
+
dx, dy : numeric
|
|
146
|
+
The dimensions of the full rectangle to normalize total values to.
|
|
147
|
+
|
|
148
|
+
Returns
|
|
149
|
+
-------
|
|
150
|
+
list[numeric]
|
|
151
|
+
The normalized values.
|
|
152
|
+
|
|
153
|
+
----------------------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
`padded_squarify(sizes, x, y, dx, dy)`
|
|
156
|
+
: Compute padded treemap rectangles.
|
|
157
|
+
|
|
158
|
+
See `squarify` docstring for details. The only difference is that the
|
|
159
|
+
returned rectangles have been "padded" to allow for a visible border.
|
|
160
|
+
|
|
161
|
+
----------------------------------------------------------------------------------------
|
|
162
|
+
|
|
163
|
+
`plot(sizes, norm_x=100, norm_y=100, color=None, label=None, value=None, ax=None, pad=False, bar_kwargs=None, text_kwargs=None, **kwargs)`
|
|
164
|
+
: Plotting with Matplotlib.
|
|
165
|
+
|
|
166
|
+
**Parameters**
|
|
167
|
+
|
|
168
|
+
sizes
|
|
169
|
+
input for squarify
|
|
170
|
+
norm_x, norm_y
|
|
171
|
+
x and y values for normalization
|
|
172
|
+
color
|
|
173
|
+
color string or list-like (see Matplotlib documentation for details)
|
|
174
|
+
label
|
|
175
|
+
list-like used as label text
|
|
176
|
+
value
|
|
177
|
+
list-like used as value text (in most cases identical with sizes argument)
|
|
178
|
+
ax
|
|
179
|
+
Matplotlib Axes instance
|
|
180
|
+
pad
|
|
181
|
+
draw rectangles with a small gap between them
|
|
182
|
+
bar_kwargs : dict
|
|
183
|
+
keyword arguments passed to matplotlib.Axes.bar
|
|
184
|
+
text_kwargs : dict
|
|
185
|
+
keyword arguments passed to matplotlib.Axes.text
|
|
186
|
+
**kwargs
|
|
187
|
+
Any additional kwargs are merged into `bar_kwargs`. Explicitly provided
|
|
188
|
+
kwargs here will take precedence.
|
|
189
|
+
|
|
190
|
+
**Returns**
|
|
191
|
+
|
|
192
|
+
matplotlib.axes.Axes
|
|
193
|
+
Matplotlib Axes
|
|
194
|
+
|
|
195
|
+
----------------------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
`squarify(sizes, x, y, dx, dy)`
|
|
198
|
+
: Compute treemap rectangles.
|
|
199
|
+
|
|
200
|
+
Given a set of values, computes a treemap layout in the specified geometry
|
|
201
|
+
using an algorithm based on Bruls, Huizing, van Wijk, "Squarified Treemaps".
|
|
202
|
+
See README for example usage.
|
|
203
|
+
|
|
204
|
+
**Parameters**
|
|
205
|
+
|
|
206
|
+
sizes : list-like of numeric values
|
|
207
|
+
The set of values to compute a treemap for. `sizes` must be positive
|
|
208
|
+
values sorted in descending order and they should be normalized to the
|
|
209
|
+
total area (i.e., `dx * dy == sum(sizes)`)
|
|
210
|
+
x, y : numeric
|
|
211
|
+
The coordinates of the "origin".
|
|
212
|
+
dx, dy : numeric
|
|
213
|
+
The full width (`dx`) and height (`dy`) of the treemap.
|
|
214
|
+
|
|
215
|
+
**Returns**
|
|
216
|
+
|
|
217
|
+
list[dict]
|
|
218
|
+
Each dict in the returned list represents a single rectangle in the
|
|
219
|
+
treemap. The order corresponds to the input order.
|
|
@@ -2,18 +2,19 @@ from setuptools import setup
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="squarify",
|
|
5
|
-
version="0.4.
|
|
5
|
+
version="0.4.4",
|
|
6
6
|
packages=["squarify"],
|
|
7
7
|
author="Uri Laserson",
|
|
8
8
|
author_email="uri.laserson@gmail.com",
|
|
9
9
|
description="Pure Python implementation of the squarify treemap layout algorithm",
|
|
10
|
-
license="Apache
|
|
10
|
+
license="Apache License 2.0",
|
|
11
11
|
keywords="treemap visualization squarify layout graphics",
|
|
12
12
|
classifiers=[
|
|
13
|
-
"Programming Language :: Python ::
|
|
14
|
-
"Programming Language :: Python ::
|
|
15
|
-
"Programming Language :: Python :: 3.
|
|
16
|
-
"Programming Language :: Python :: 3.
|
|
13
|
+
"Programming Language :: Python :: 3.8",
|
|
14
|
+
"Programming Language :: Python :: 3.9",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
17
18
|
],
|
|
18
19
|
url="https://github.com/laserson/squarify",
|
|
19
20
|
)
|
|
@@ -182,6 +182,7 @@ def plot(
|
|
|
182
182
|
label=None,
|
|
183
183
|
value=None,
|
|
184
184
|
ax=None,
|
|
185
|
+
pad=False,
|
|
185
186
|
bar_kwargs=None,
|
|
186
187
|
text_kwargs=None,
|
|
187
188
|
**kwargs
|
|
@@ -202,8 +203,8 @@ def plot(
|
|
|
202
203
|
list-like used as value text (in most cases identical with sizes argument)
|
|
203
204
|
ax
|
|
204
205
|
Matplotlib Axes instance
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
pad
|
|
207
|
+
draw rectangles with a small gap between them
|
|
207
208
|
bar_kwargs : dict
|
|
208
209
|
keyword arguments passed to matplotlib.Axes.bar
|
|
209
210
|
text_kwargs : dict
|
|
@@ -238,7 +239,11 @@ def plot(
|
|
|
238
239
|
bar_kwargs.update(kwargs)
|
|
239
240
|
|
|
240
241
|
normed = normalize_sizes(sizes, norm_x, norm_y)
|
|
241
|
-
|
|
242
|
+
|
|
243
|
+
if pad:
|
|
244
|
+
rects = padded_squarify(normed, 0, 0, norm_x, norm_y)
|
|
245
|
+
else:
|
|
246
|
+
rects = squarify(normed, 0, 0, norm_x, norm_y)
|
|
242
247
|
|
|
243
248
|
x = [rect["x"] for rect in rects]
|
|
244
249
|
y = [rect["y"] for rect in rects]
|
|
@@ -249,14 +254,14 @@ def plot(
|
|
|
249
254
|
x, dy, width=dx, bottom=y, color=color, label=label, align="edge", **bar_kwargs
|
|
250
255
|
)
|
|
251
256
|
|
|
252
|
-
if
|
|
257
|
+
if value is not None:
|
|
253
258
|
va = "center" if label is None else "top"
|
|
254
259
|
|
|
255
260
|
for v, r in zip(value, rects):
|
|
256
261
|
x, y, dx, dy = r["x"], r["y"], r["dx"], r["dy"]
|
|
257
262
|
ax.text(x + dx / 2, y + dy / 2, v, va=va, ha="center", **text_kwargs)
|
|
258
263
|
|
|
259
|
-
if
|
|
264
|
+
if label is not None:
|
|
260
265
|
va = "center" if value is None else "bottom"
|
|
261
266
|
for l, r in zip(label, rects):
|
|
262
267
|
x, y, dx, dy = r["x"], r["y"], r["dx"], r["dy"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: squarify
|
|
3
|
+
Version: 0.4.4
|
|
4
|
+
Summary: Pure Python implementation of the squarify treemap layout algorithm
|
|
5
|
+
Home-page: https://github.com/laserson/squarify
|
|
6
|
+
Author: Uri Laserson
|
|
7
|
+
Author-email: uri.laserson@gmail.com
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Keywords: treemap visualization squarify layout graphics
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
License-File: LICENSE.txt
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from squarify import normalize_sizes, squarify
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
expected = [
|
|
5
|
+
{"dy": 433, "dx": 327.7153558052434, "x": 0, "y": 0},
|
|
6
|
+
{"dy": 330.0862676056338, "dx": 372.2846441947566, "x": 327.7153558052434, "y": 0},
|
|
7
|
+
{
|
|
8
|
+
"dy": 102.9137323943662,
|
|
9
|
+
"dx": 215.0977944236371,
|
|
10
|
+
"x": 327.7153558052434,
|
|
11
|
+
"y": 330.0862676056338,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"dy": 102.9137323943662,
|
|
15
|
+
"dx": 68.94160077680677,
|
|
16
|
+
"x": 542.8131502288805,
|
|
17
|
+
"y": 330.0862676056338,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"dy": 80.40135343309854,
|
|
21
|
+
"dx": 88.24524899431273,
|
|
22
|
+
"x": 611.7547510056874,
|
|
23
|
+
"y": 330.0862676056338,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"dy": 22.51237896126767,
|
|
27
|
+
"dx": 88.2452489943124,
|
|
28
|
+
"x": 611.7547510056874,
|
|
29
|
+
"y": 410.4876210387323,
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_squarify():
|
|
35
|
+
x = 0.0
|
|
36
|
+
y = 0.0
|
|
37
|
+
width = 700.0
|
|
38
|
+
height = 433.0
|
|
39
|
+
values = [500, 433, 78, 25, 25, 7]
|
|
40
|
+
values = normalize_sizes(values, width, height)
|
|
41
|
+
observed = squarify(values, x, y, width, height)
|
|
42
|
+
assert len(observed) == len(expected)
|
|
43
|
+
for (o, e) in zip(observed, expected):
|
|
44
|
+
assert len(o) == 4
|
|
45
|
+
assert set(o.keys()) == set(["dx", "dy", "x", "y"])
|
|
46
|
+
assert o["dx"] == e["dx"]
|
|
47
|
+
assert o["dy"] == e["dy"]
|
|
48
|
+
assert o["x"] == e["x"]
|
|
49
|
+
assert o["y"] == e["y"]
|
squarify-0.4.2/PKG-INFO
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 1.1
|
|
2
|
-
Name: squarify
|
|
3
|
-
Version: 0.4.2
|
|
4
|
-
Summary: Pure Python implementation of the squarify treemap layout algorithm
|
|
5
|
-
Home-page: https://github.com/laserson/squarify
|
|
6
|
-
Author: Uri Laserson
|
|
7
|
-
Author-email: uri.laserson@gmail.com
|
|
8
|
-
License: Apache v2
|
|
9
|
-
Description: UNKNOWN
|
|
10
|
-
Keywords: treemap visualization squarify layout graphics
|
|
11
|
-
Platform: UNKNOWN
|
|
12
|
-
Classifier: Programming Language :: Python :: 2.6
|
|
13
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.5
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.6
|
squarify-0.4.2/README.md
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
squarify
|
|
2
|
-
========
|
|
3
|
-

|
|
4
|
-
[](https://travis-ci.org/laserson/squarify)
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
Pure Python implementation of the squarify treemap layout algorithm.
|
|
9
|
-
|
|
10
|
-
Based on algorithm from [Bruls, Huizing, van Wijk, "Squarified Treemaps"](https://doi.org/10.1007/978-3-7091-6783-0_4), but
|
|
11
|
-
implements it differently.
|
|
12
|
-
|
|
13
|
-
Installation
|
|
14
|
-
------------
|
|
15
|
-
|
|
16
|
-
Compatible with Python 2 and Python 3.
|
|
17
|
-
|
|
18
|
-
pip install squarify
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Usage
|
|
22
|
-
-----
|
|
23
|
-
|
|
24
|
-
The main function is `squarify` and it requires two things:
|
|
25
|
-
|
|
26
|
-
* A coordinate system comprising values for the origin (`x` and `y`) and the
|
|
27
|
-
width/height (`dx` and `dy`).
|
|
28
|
-
* A list of positive values sorted from largest to smallest and normalized to
|
|
29
|
-
the total area, i.e., `dx * dy`).
|
|
30
|
-
|
|
31
|
-
The function returns a list of `dict`s (i.e., JSON objects), each one a
|
|
32
|
-
rectangle with coordinates corresponding to the given coordinate system and area
|
|
33
|
-
proportional to the corresponding value. Here's an example rectangle:
|
|
34
|
-
|
|
35
|
-
```json
|
|
36
|
-
{
|
|
37
|
-
"x": 0.0,
|
|
38
|
-
"y": 0.0,
|
|
39
|
-
"dx": 327.7,
|
|
40
|
-
"dy": 433.0
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
The rectangles can be easily plotted using, for example,
|
|
45
|
-
[d3.js](http://d3js.org/).
|
|
46
|
-
|
|
47
|
-
There is also a version of `squarify` called `padded_squarify` that returns
|
|
48
|
-
rectangles that, when laid out, have a bit of padding to show their borders.
|
|
49
|
-
|
|
50
|
-
The helper function `normalize_sizes` will compute the normalized values, and
|
|
51
|
-
the helper function `plot` will generate a Matplotlib-based treemap
|
|
52
|
-
visualization of your data (see docstring).
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Example
|
|
56
|
-
-------
|
|
57
|
-
```python
|
|
58
|
-
import squarify
|
|
59
|
-
|
|
60
|
-
# these values define the coordinate system for the returned rectangles
|
|
61
|
-
# the values will range from x to x + width and y to y + height
|
|
62
|
-
x = 0.
|
|
63
|
-
y = 0.
|
|
64
|
-
width = 700.
|
|
65
|
-
height = 433.
|
|
66
|
-
|
|
67
|
-
values = [500, 433, 78, 25, 25, 7]
|
|
68
|
-
|
|
69
|
-
# values must be sorted descending (and positive, obviously)
|
|
70
|
-
values.sort(reverse=True)
|
|
71
|
-
|
|
72
|
-
# the sum of the values must equal the total area to be laid out
|
|
73
|
-
# i.e., sum(values) == width * height
|
|
74
|
-
values = squarify.normalize_sizes(values, width, height)
|
|
75
|
-
|
|
76
|
-
# returns a list of rectangles
|
|
77
|
-
rects = squarify.squarify(values, x, y, width, height)
|
|
78
|
-
|
|
79
|
-
# padded rectangles will probably visualize better for certain cases
|
|
80
|
-
padded_rects = squarify.padded_squarify(values, x, y, width, height)
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
The variable `rects` contains
|
|
84
|
-
|
|
85
|
-
```json
|
|
86
|
-
[
|
|
87
|
-
{
|
|
88
|
-
"dy": 433,
|
|
89
|
-
"dx": 327.7153558052434,
|
|
90
|
-
"x": 0,
|
|
91
|
-
"y": 0
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"dy": 330.0862676056338,
|
|
95
|
-
"dx": 372.2846441947566,
|
|
96
|
-
"x": 327.7153558052434,
|
|
97
|
-
"y": 0
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"dy": 102.9137323943662,
|
|
101
|
-
"dx": 215.0977944236371,
|
|
102
|
-
"x": 327.7153558052434,
|
|
103
|
-
"y": 330.0862676056338
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"dy": 102.9137323943662,
|
|
107
|
-
"dx": 68.94160077680677,
|
|
108
|
-
"x": 542.8131502288805,
|
|
109
|
-
"y": 330.0862676056338
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"dy": 80.40135343309854,
|
|
113
|
-
"dx": 88.24524899431273,
|
|
114
|
-
"x": 611.7547510056874,
|
|
115
|
-
"y": 330.0862676056338
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"dy": 22.51237896126767,
|
|
119
|
-
"dx": 88.2452489943124,
|
|
120
|
-
"x": 611.7547510056874,
|
|
121
|
-
"y": 410.4876210387323
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
```
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 1.1
|
|
2
|
-
Name: squarify
|
|
3
|
-
Version: 0.4.2
|
|
4
|
-
Summary: Pure Python implementation of the squarify treemap layout algorithm
|
|
5
|
-
Home-page: https://github.com/laserson/squarify
|
|
6
|
-
Author: Uri Laserson
|
|
7
|
-
Author-email: uri.laserson@gmail.com
|
|
8
|
-
License: Apache v2
|
|
9
|
-
Description: UNKNOWN
|
|
10
|
-
Keywords: treemap visualization squarify layout graphics
|
|
11
|
-
Platform: UNKNOWN
|
|
12
|
-
Classifier: Programming Language :: Python :: 2.6
|
|
13
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.5
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
File without changes
|
|
File without changes
|
|
File without changes
|