Skip to content

Commit f17e952

Browse files
committed
added title some rearrangement of elements
1 parent efd5e0e commit f17e952

File tree

3 files changed

+69
-81
lines changed

3 files changed

+69
-81
lines changed

layouts/tiling-explorer-2.grid.json

+23-19
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
"columns": 24,
55
"rowHeight": 20,
66
"maxWidth": 1400,
7-
"bordered": false,
7+
"bordered": true,
88
"cells": [
99
{
1010
"position": null
1111
},
1212
{
13-
"position": null
13+
"position": [
14+
3,
15+
0,
16+
18,
17+
3
18+
]
1419
},
1520
{
1621
"position": null
@@ -41,16 +46,16 @@
4146
"position": [
4247
0,
4348
0,
44-
24,
45-
2
49+
3,
50+
3
4651
]
4752
},
4853
{
4954
"position": [
5055
0,
51-
2,
56+
3,
5257
17,
53-
35
58+
34
5459
]
5560
},
5661
{
@@ -73,26 +78,25 @@
7378
{
7479
"position": [
7580
17,
76-
2,
81+
3,
7782
7,
7883
4
7984
]
8085
},
8186
{
82-
"position": null
83-
},
84-
{
85-
"position": null
86-
},
87-
{
88-
"position": null
87+
"position": [
88+
17,
89+
7,
90+
7,
91+
2
92+
]
8993
},
9094
{
9195
"position": [
9296
17,
93-
6,
97+
9,
9498
7,
95-
4
99+
2
96100
]
97101
},
98102
{
@@ -101,7 +105,7 @@
101105
{
102106
"position": [
103107
17,
104-
10,
108+
11,
105109
7,
106110
4
107111
]
@@ -115,9 +119,9 @@
115119
{
116120
"position": [
117121
17,
118-
14,
122+
15,
119123
7,
120-
23
124+
22
121125
]
122126
},
123127
{

tiling-explorer-2.py

+43-59
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ def _():
1313
return (mo,)
1414

1515

16+
@app.cell
17+
def _(mo):
18+
mo.md(f"# Tiled and woven maps of multivariate data")
19+
return
20+
21+
1622
@app.cell(hide_code=True)
1723
def _():
1824
import matplotlib as mpl
1925
import geopandas as gpd
20-
from weavingspace import TileUnit
21-
from weavingspace import WeaveUnit
22-
from weavingspace import Tiling
23-
return TileUnit, Tiling, WeaveUnit, gpd, mpl
26+
import weavingspace as wsp
27+
return gpd, mpl, wsp
2428

2529

2630
@app.cell(hide_code=True)
@@ -29,12 +33,6 @@ def _(gpd):
2933
return (gdf,)
3034

3135

32-
@app.cell
33-
def _():
34-
# tiled_map = Tiling(final_tile, gdf).get_tiled_map()
35-
return
36-
37-
3836
@app.cell(hide_code=True)
3937
def _(gdf, mo, tile):
4038
_tile_ids = sorted(list(set(tile.tiles.tile_id)))
@@ -73,12 +71,12 @@ def _(mpl, pals):
7371
@app.cell(hide_code=True)
7472
def _(mo):
7573
tile_map_button = mo.ui.run_button(label="Tile map!")
76-
tile_map_button
74+
tile_map_button.center()
7775
return (tile_map_button,)
7876

7977

8078
@app.cell(hide_code=True)
81-
def _(Tiling, final_tile, gdf, mo, pals, tile, tile_map_button, vars):
79+
def _(final_tile, gdf, mo, pals, tile, tile_map_button, vars, wsp):
8280
_centred = {"display": "flex", "height": "500px",
8381
"justify-content": "center", "align-items": "center",
8482
"text-align": "center"}
@@ -98,7 +96,7 @@ def _(Tiling, final_tile, gdf, mo, pals, tile, tile_map_button, vars):
9896
])
9997
mo.stop(not tile_map_button.value, mo.md(_msg).style(_centred))
10098
_tile_ids = sorted(list(set((tile.tiles.tile_id))))
101-
tiled_map = Tiling(final_tile, gdf).get_tiled_map()
99+
tiled_map = wsp.Tiling(final_tile, gdf).get_tiled_map()
102100
tiled_map.variables = {k: v for k, v in zip(_tile_ids, vars.value)}
103101
tiled_map.colourmaps = {k: v for k, v in zip(vars.value, pals.value)}
104102
tiled_map.render(legend=False)
@@ -122,8 +120,9 @@ def _(mo, tile):
122120
@app.cell
123121
def _(mo, p_inset, tile, tile_or_weave):
124122
_max_t_inset = p_inset.value // 3 if tile_or_weave.value == "tiles" else tile.spacing // 10
123+
_value_t_inset = _max_t_inset if tile_or_weave.value == "tiles" else 0
125124
t_inset = mo.ui.slider(start=0, stop=_max_t_inset, step = 1,
126-
value=0, show_value=True, debounce=True)
125+
value=_value_t_inset, show_value=True, debounce=True)
127126
return (t_inset,)
128127

129128

@@ -142,17 +141,17 @@ def _(mo, p_inset, t_inset, tile_or_weave, tile_rotate):
142141
return
143142

144143

145-
@app.cell(hide_code=True)
144+
@app.cell
146145
def _(mo):
147-
tile_or_weave = mo.ui.dropdown(options=["tiles", "weave"], value="tiles")
146+
tile_or_weave = mo.ui.dropdown(options=["tiles", "weave"], value="tiles", label="#### Pick tile or weave")
148147
mo.md("\n".join([
149148
f"### General specification",
150-
f"#### Pick tile or weave {tile_or_weave}"
149+
f"{tile_or_weave}",
151150
]))
152151
return (tile_or_weave,)
153152

154153

155-
@app.cell(hide_code=True)
154+
@app.cell
156155
def _(mo, tile_or_weave):
157156
if tile_or_weave.value == "tiles":
158157
family = mo.ui.dropdown(
@@ -164,6 +163,7 @@ def _(mo, tile_or_weave):
164163
options = ["plain", "twill", "basket"], #, "cube"],
165164
value = "plain", label = "#### Weave type")
166165

166+
mo.md(f"{family}")
167167
return (family,)
168168

169169

@@ -175,56 +175,40 @@ def _(mo, tile_or_weave):
175175
else:
176176
spacing = mo.ui.slider(start=100, stop=1000, step=10, value=250,
177177
show_value=True, debounce=True)
178-
return (spacing,)
179-
180-
181-
@app.cell
182-
def _(family, mo, spacing):
183-
tile_general = mo.ui.dictionary({
184-
"family": family,
185-
"spacing": spacing
186-
})
187-
return (tile_general,)
188178

189-
190-
@app.cell(hide_code=True)
191-
def _(mo, tile_general):
192-
mo.md("\n".join([
193-
f"#### Family {tile_general['family']}",
194-
f"#### Spacing {tile_general['spacing']}"
195-
]))
196-
return
179+
mo.md(f"#### Spacing {spacing}")
180+
return (spacing,)
197181

198182

199183
@app.cell(hide_code=True)
200-
def _(mo, tile_general, tile_or_weave):
201-
if "slice" in tile_general['family'].value:
184+
def _(family, mo, tile_or_weave):
185+
if "slice" in family.value:
202186
_n_parts = mo.ui.slider(
203187
steps = [x for x in range(2, 13)], value = 6,
204188
label=f"#### Number of slices",
205189
show_value=True, debounce=True)
206-
elif tile_general['family'].value == "hex-dissection":
190+
elif family.value == "hex-dissection":
207191
_n_parts = mo.ui.slider(
208192
steps = [4, 7, 9], value = 7,
209193
label=f"#### Number of pieces",
210194
show_value=True, debounce=True)
211-
elif tile_general['family'].value == "cross":
195+
elif family.value == "cross":
212196
_n_parts = mo.ui.slider(
213197
steps = [x for x in range(2, 8)], value = 5,
214198
label=f"#### Number of crosses",
215199
show_value=True, debounce=True)
216-
elif "colour" in tile_general['family'].value:
200+
elif "colour" in family.value:
217201
_n_parts = mo.ui.slider(
218202
steps = [x for x in range(2, 10)], value = 7,
219203
label=f"#### Number of colours",
220204
show_value=True, debounce=True)
221205

222-
if "slice" in tile_general['family'].value:
206+
if "slice" in family.value:
223207
_offset = mo.ui.slider(
224208
steps=[x / 100 for x in range(101)], value=0,
225209
label="#### Offset",
226210
show_value=True, debounce=True)
227-
elif tile_general['family'].value == "hex-dissection":
211+
elif family.value == "hex-dissection":
228212
_offset = mo.ui.number(
229213
start=0, stop=1,
230214
label="#### Offset", debounce=True)
@@ -236,9 +220,9 @@ def _(mo, tile_general, tile_or_weave):
236220
label = "Code"
237221
)
238222

239-
if tile_general['family'].value == "twill" or tile_general['family'].value == "basket":
223+
if family.value == "twill" or family.value == "basket":
240224
_strands = mo.ui.text(value="ab|cd", label="#### Strands spec")
241-
elif tile_general['family'].value == "plain":
225+
elif family.value == "plain":
242226
_strands = mo.ui.text(value="a|b", label="#### Strands spec")
243227
else:
244228
_strands = mo.ui.text(value="abc|def|ghi", label="#### Strands spec")
@@ -247,11 +231,11 @@ def _(mo, tile_general, tile_or_weave):
247231
show_value=True, debounce=True)
248232

249233
if tile_or_weave.value == "tiles":
250-
if tile_general['family'].value in ["laves", "archimedean"]:
234+
if family.value in ["laves", "archimedean"]:
251235
tile_spec = mo.ui.dictionary({
252236
"code": _code,
253237
})
254-
elif "slice" in tile_general['family'].value or tile_general['family'].value == "hex-dissection":
238+
elif "slice" in family.value or family.value == "hex-dissection":
255239
tile_spec = mo.ui.dictionary({
256240
"n": _n_parts,
257241
"offset": _offset,
@@ -275,20 +259,20 @@ def _(mo, tile_spec):
275259

276260

277261
@app.cell(hide_code=True)
278-
def _(TileUnit, WeaveUnit, gdf, tile_general, tile_or_weave, tile_spec):
262+
def _(family, gdf, spacing, tile_or_weave, tile_spec, wsp):
279263
if tile_or_weave.value == "tiles":
280-
tile = TileUnit(tiling_type=tile_general['family'].value,
281-
spacing=tile_general["spacing"].value,
282-
n=tile_spec["n"].value if "n" in tile_spec else None,
283-
code=tile_spec["code"].value if "code" in tile_spec else None,
284-
offset=tile_spec["offset"].value if "offset" in tile_spec else None,
285-
crs=gdf.crs)
264+
tile = wsp.TileUnit(tiling_type=family.value,
265+
spacing=spacing.value,
266+
n=tile_spec["n"].value if "n" in tile_spec else None,
267+
code=tile_spec["code"].value if "code" in tile_spec else None,
268+
offset=tile_spec["offset"].value if "offset" in tile_spec else None,
269+
crs=3857 if gdf is None else gdf.crs)
286270
else:
287-
tile = WeaveUnit(weave_type=tile_general['family'].value,
288-
spacing=tile_general["spacing"].value,
289-
strands=tile_spec["strands"].value,
290-
aspect=tile_spec["aspect"].value,
291-
crs=gdf.crs)
271+
tile = wsp.WeaveUnit(weave_type=family.value,
272+
spacing=spacing.value,
273+
strands=tile_spec["strands"].value,
274+
aspect=tile_spec["aspect"].value,
275+
crs=3857 if gdf is None else gdf.crs)
292276
return (tile,)
293277

294278

0 commit comments

Comments
 (0)