Skip to content

Instantly share code, notes, and snippets.

@kolibril13
Last active October 9, 2024 16:20
Show Gist options
  • Select an option

  • Save kolibril13/d8033ba85f5203a3a7f67cc1241aebf9 to your computer and use it in GitHub Desktop.

Select an option

Save kolibril13/d8033ba85f5203a3a7f67cc1241aebf9 to your computer and use it in GitHub Desktop.
ipydrop asset
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "ipydrop==0.0.1",
# "marimo",
# "matplotlib==3.9.2",
# "numpy==2.1.2",
# ]
# ///
import marimo
__generated_with = "0.9.4"
app = marimo.App(width="medium")
@app.cell
def __():
import marimo as mo
import numpy as np
return mo, np
@app.cell
def __(mo):
from ipydrop import Widget
w = mo.ui.anywidget(Widget())
w
return Widget, w
@app.cell
def __(np, w):
import matplotlib.pyplot as plt
content = w.file_content
xy_tuples = [(float(x), float(y)) for x, y in (line.split(',') for line in content.strip().split('\n')[1:]) if x and y]
if not xy_tuples:
# Use dummy data if xy_tuples is empty
x = np.linspace(0, 10, 40)
y = np.sin(x)
else:
x, y = zip(*xy_tuples)
# Set the matplotlib style
plt.style.use('_mpl-gallery')
fig, ax = plt.subplots()
ax.scatter(x, y, c="#ffa726")
# Set figure size and axes properties
fig.set_size_inches(3, 3)
# Add grid and customize it
ax.grid(True, which='both', linestyle='--', linewidth=0.5)
ax.minorticks_on()
# Remove ticks
ax.set_xticks([])
ax.set_yticks([])
# Optionally, set axis visibility
ax.axis("on")
# Change the color of the border (spines)
for spine in ax.spines.values():
spine.set_edgecolor("#ffa726") # Set the color to #ffa726
spine.set_linewidth(2)
plt.gca()
return ax, content, fig, plt, spine, x, xy_tuples, y
@app.cell
def __(w):
w.file_name , w.file_content
return
if __name__ == "__main__":
app.run()
x y
55.3846 97.1795
51.5385 96.0256
46.1538 94.4872
42.8205 91.4103
40.7692 88.3333
38.7179 84.8718
35.641 79.8718
33.0769 77.5641
28.9744 74.4872
26.1538 71.4103
23.0769 66.4103
22.3077 61.7949
22.3077 57.1795
23.3333 52.9487
25.8974 51.0256
29.4872 51.0256
32.8205 51.0256
35.3846 51.4103
40.2564 51.4103
44.1026 52.9487
46.6667 54.1026
50.0 55.2564
53.0769 55.641
56.6667 56.0256
59.2308 57.9487
61.2821 62.1795
61.5385 66.4103
61.7949 69.1026
57.4359 55.2564
54.8718 49.8718
52.5641 46.0256
48.2051 38.3333
49.4872 42.1795
51.0256 44.1026
45.3846 36.4103
42.8205 32.5641
38.7179 31.4103
35.1282 30.2564
32.5641 32.1795
30.0 36.7949
33.5897 41.4103
36.6667 45.641
38.2051 49.1026
29.7436 36.0256
29.7436 32.1795
30.0 29.1026
32.0513 26.7949
35.8974 25.2564
41.0256 25.2564
44.1026 25.641
47.1795 28.718
49.4872 31.4103
51.5385 34.8718
53.5897 37.5641
55.1282 40.641
56.6667 42.1795
59.2308 44.4872
62.3077 46.0256
64.8718 46.7949
67.9487 47.9487
70.5128 53.718
71.5385 60.641
71.5385 64.4872
69.4872 69.4872
46.9231 79.8718
48.2051 84.1026
50.0 85.2564
53.0769 85.2564
55.3846 86.0256
56.6667 86.0256
56.1538 82.9487
53.8462 80.641
51.2821 78.718
50.0 78.718
47.9487 77.5641
29.7436 59.8718
29.7436 62.1795
31.2821 62.5641
57.9487 99.4872
61.7949 99.1026
64.8718 97.5641
68.4615 94.1026
70.7692 91.0256
72.0513 86.4103
73.8462 83.3333
75.1282 79.1026
76.6667 75.2564
77.6923 71.4103
79.7436 66.7949
81.7949 60.2564
83.3333 55.2564
85.1282 51.4103
86.4103 47.5641
87.9487 46.0256
89.4872 42.5641
93.3333 39.8718
95.3846 36.7949
98.2051 33.718
56.6667 40.641
59.2308 38.3333
60.7692 33.718
63.0769 29.1026
64.1026 25.2564
64.359 24.1026
74.359 22.9487
71.2821 22.9487
67.9487 22.1795
65.8974 20.2564
63.0769 19.1026
61.2821 19.1026
58.7179 18.3333
55.1282 18.3333
52.3077 18.3333
49.7436 17.5641
47.4359 16.0256
44.8718 13.718
48.7179 14.8718
51.2821 14.8718
54.1026 14.8718
56.1538 14.1026
52.0513 12.5641
48.7179 11.0256
47.1795 9.8718
46.1538 6.0256
50.5128 9.4872
53.8462 10.2564
57.4359 10.2564
60.0 10.641
64.1026 10.641
66.9231 10.641
71.2821 10.641
74.359 10.641
78.2051 10.641
67.9487 8.718
68.4615 5.2564
68.2051 2.9487
37.6923 25.7692
39.4872 25.3846
91.2821 41.5385
50.0 95.7692
47.9487 95.0
44.1026 92.6923
x y
58.21360826 91.88189151
58.19605369 92.21498865
58.71823072 90.31053209
57.27837287 89.90760672
58.08202049 92.00814501
57.48944777 88.08528556
28.08874132 63.51079443
28.08546821 63.59019695
28.08727305 63.12328281
27.57802522 62.82103866
27.77991911 63.51814752
28.58899981 63.02408057
28.7391415 62.72086389
27.02460324 62.90185886
28.8013367 63.38904039
27.18646384 63.55872965
29.2851466 63.38360583
39.4029453 51.1508572
28.81132844 61.35785406
34.30395791 56.54212591
29.60276098 60.15734672
49.11615686 63.66000062
39.61754583 62.92518796
43.23308466 63.16521872
64.89278794 65.81417676
62.49014932 74.58428961
68.98808443 63.23214731
62.10561863 75.99087076
32.46184674 62.88190292
41.32720065 49.07025127
44.00714993 46.44967378
44.07406069 34.55320389
44.00131524 33.90420735
45.00630045 38.29901955
44.44384061 36.0190833
42.1787134 26.49211948
44.04456562 35.66223828
41.64045402 27.09309542
41.93833001 24.99152298
44.05392751 33.55639249
39.20671933 51.5337157
28.70444923 61.7775254
31.7086629 58.83775437
42.81171147 30.02044842
43.30061489 31.5264262
40.39863291 16.34700838
40.43569158 20.23267068
40.93654667 16.91300484
39.66157367 15.60935558
40.89925918 20.79852895
41.96861683 26.4970726
40.38340582 21.39122552
56.53812645 32.44424547
52.97069128 29.04019669
54.62095259 30.34452445
65.09904439 27.24155756
63.05599091 29.70909567
70.96013623 41.25950129
69.89581924 43.45375927
70.59589286 41.96474387
69.64702143 44.04444502
77.39298249 63.37145906
64.40078719 67.44871845
63.86895983 70.21373883
56.59442132 86.92700622
56.53133729 87.49981107
59.65215837 87.80946159
56.6365087 85.63749556
58.672288 90.07716031
58.22161273 90.41101877
57.91466448 89.95380277
55.31550906 80.25186069
54.57572859 77.53628847
54.41309365 78.22908659
55.0745059 79.81754642
29.43296052 60.80177654
29.42268607 63.06846482
29.00561416 63.39075133
58.46183859 90.26532639
57.99780474 92.15990861
57.54947408 90.74890656
59.52992846 88.32727415
58.24939106 92.12968148
58.02451401 91.69442117
58.38212449 90.55347607
62.56675904 77.74393476
72.17582431 63.12892942
79.47276157 63.40868612
80.35770088 63.29543754
78.75723614 53.33262001
82.54023959 56.54105229
86.43589719 59.79276181
79.48868442 53.65167426
81.53042032 56.02536457
79.18678857 53.23479185
77.89905795 51.82245833
75.13071421 23.37244197
76.05801375 16.38374969
57.61467439 33.82244765
56.17139753 32.11798877
66.2878906 26.11710975
67.88171962 24.23601841
64.0280813 27.67268551
77.49665175 14.94852356
77.63465176 14.46185393
77.86372643 14.61067765
77.33815817 15.89005466
76.18041653 15.91257375
77.25265109 15.15151702
77.41337528 15.22192798
76.7318494 16.21684614
49.47110541 25.06301931
42.47653994 18.33847356
43.59511586 19.99420098
50.33996967 26.47139661
40.74898026 16.18214166
38.38652558 14.58021515
38.40401521 14.45194845
38.76427889 14.36559047
41.47014233 17.27803344
47.15540481 22.37793253
39.58256675 17.64845284
41.74024382 17.82932431
39.31187189 15.64071697
41.67984769 17.74591901
39.08746445 15.12230394
41.48150286 18.04743744
77.60608655 15.16287254
75.98266152 16.30692238
76.94575724 15.85847833
77.54372007 15.25394915
77.58473984 15.83003939
76.82230426 15.59516532
77.34857166 15.77452924
77.57315269 14.78064583
77.97261068 14.95569875
41.52891976 24.91642519
43.7225508 19.0773278
79.32607818 52.90039129
56.66397408 87.94012501
57.82178923 90.69316655
58.2431719 92.10432787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment