-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbarplot_remote.mo.py
More file actions
151 lines (122 loc) · 3.42 KB
/
Copy pathbarplot_remote.mo.py
File metadata and controls
151 lines (122 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import marimo
__generated_with = "0.18.4"
app = marimo.App(width="medium")
@app.cell
def _():
from pluot import render_to_image, render_to_svg, render_to_script
import numpy as np
import marimo as mo
import json
import zarr
return mo, render_to_image, render_to_script, render_to_svg, zarr
@app.cell
def _():
from obstore.store import HTTPStore
return (HTTPStore,)
@app.cell
def _(HTTPStore, zarr):
obs_store = HTTPStore.from_url("https://pub-adb3658c8ed642caa534fdc612cd1c0c.r2.dev/wheat.zarr")
store = zarr.storage.ObjectStore(obs_store, read_only=True)
return (store,)
@app.cell
def _():
camera_view = [
0.15, 0.0, 0.0, 0.0,
0.0, 0.01, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, -1.0, 0.0, 1.0,
]
return (camera_view,)
@app.cell
async def _(camera_view, render_to_image, store):
await render_to_image(
camera_view=camera_view, width=800, height=600, plot_id="test_barplot_layer", plot_type="LayeredPlot",
margin_left=100,
margin_bottom=100,
margin_top=10,
margin_right=10,
store=store,
plot_params=dict(
layers=[
dict(
layer_type = "ZarrBarPlotLayer",
layer_params = dict(
layer_id= "barplot_layer",
bounds= None,
orientation= "Vertical",
identifier_key= "/year",
quantity_key= "/wheat",
fill_color_mode="Categorical",
)
),
]
),
)
return
@app.cell
async def _(camera_view, render_to_svg, store):
svg_string = await render_to_svg(
camera_view=camera_view, width=800, height=600, plot_id="test_barplot_layer", plot_type="LayeredPlot",
margin_left=100,
margin_bottom=100,
margin_top=10,
margin_right=10,
store=store,
plot_params=dict(
layers=[
dict(
layer_type = "ZarrBarPlotLayer",
layer_params = dict(
layer_id= "barplot_layer",
bounds= None,
orientation= "Vertical",
identifier_key= "/year",
quantity_key= "/wheat",
fill_color_mode="Categorical",
)
),
]
),
)
return (svg_string,)
@app.cell
def _(mo, svg_string):
mo.Html(svg_string)
return
@app.cell
def _(svg_string):
with open("../pluot-figures/barplot.svg", "w") as f:
f.write(svg_string)
return
@app.cell
def _(camera_view, render_to_script, store):
render_to_script(
camera_view=camera_view, width=800, height=600, plot_id="test_barplot_layer", plot_type="LayeredPlot",
margin_left=100,
margin_bottom=100,
margin_top=10,
margin_right=10,
store=store,
plot_params=dict(
layers=[
dict(
layer_type = "ZarrBarPlotLayer",
layer_params = dict(
layer_id= "barplot_layer",
bounds= None,
orientation= "Vertical",
identifier_key= "/year",
quantity_key= "/wheat",
fill_color_mode="Categorical",
)
),
]
),
code_format="ScriptBash"
)
return
@app.cell
def _():
return
if __name__ == "__main__":
app.run()