Skip to content

Commit b82a07b

Browse files
committed
fix add graphic methods
1 parent 2da635f commit b82a07b

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

fastplotlib/layouts/graphic_methods_mixin.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import *
2+
23
import numpy
3-
from ..graphics import *
44
import weakref
55

6+
from ..graphics import *
7+
68

79
class GraphicMethodsMixin:
810
def __init__(self):
@@ -70,7 +72,7 @@ def add_heatmap(self, data: Any, vmin: int = None, vmax: int = None, cmap: str =
7072
plot.show()
7173
7274
"""
73-
g = HeatmapGraphic(*args, **kwargs)
75+
g = HeatmapGraphic(data=data, *args, **kwargs)
7476
self.add_graphic(g)
7577

7678
return weakref.proxy(g)
@@ -103,7 +105,7 @@ def add_histogram(self, data: numpy.ndarray = None, bins: Union[int, str] = 'aut
103105
passed to Graphic
104106
105107
"""
106-
g = HistogramGraphic(*args, **kwargs)
108+
g = HistogramGraphic(data=data, *args, **kwargs)
107109
self.add_graphic(g)
108110

109111
return weakref.proxy(g)
@@ -165,9 +167,7 @@ def add_image(self, data: Any, vmin: int = None, vmax: int = None, cmap: str = '
165167
plot.show()
166168
167169
"""
168-
print(args)
169-
print(kwargs)
170-
g = ImageGraphic(*args, **kwargs)
170+
g = ImageGraphic(data=data, *args, **kwargs)
171171
self.add_graphic(g)
172172

173173
return weakref.proxy(g)
@@ -286,7 +286,7 @@ def add_line_collection(self, data: List[numpy.ndarray], z_position: Union[List[
286286
287287
288288
"""
289-
g = LineCollection(*args, **kwargs)
289+
g = LineCollection(data=data, *args, **kwargs)
290290
self.add_graphic(g)
291291

292292
return weakref.proxy(g)
@@ -340,7 +340,7 @@ def add_line(self, data: Any, thickness: float = 2.0, colors: Union[str, numpy.n
340340
341341
342342
"""
343-
g = LineGraphic(*args, **kwargs)
343+
g = LineGraphic(data=data, *args, **kwargs)
344344
self.add_graphic(g)
345345

346346
return weakref.proxy(g)
@@ -451,7 +451,7 @@ def add_line_stack(self, data: List[numpy.ndarray], z_position: Union[List[float
451451
452452
453453
"""
454-
g = LineStack(*args, **kwargs)
454+
g = LineStack(data=data, *args, **kwargs)
455455
self.add_graphic(g)
456456

457457
return weakref.proxy(g)
@@ -505,7 +505,7 @@ def add_scatter(self, data: numpy.ndarray, sizes: Union[int, numpy.ndarray, list
505505
506506
507507
"""
508-
g = ScatterGraphic(*args, **kwargs)
508+
g = ScatterGraphic(data=data, *args, **kwargs)
509509
self.add_graphic(g)
510510

511511
return weakref.proxy(g)
@@ -533,7 +533,7 @@ def add_text(self, text: str, position: Tuple[int] = (0, 0, 0), size: int = 10,
533533
name of graphic, passed to Graphic
534534
535535
"""
536-
g = TextGraphic(*args, **kwargs)
536+
g = TextGraphic(text=text, *args, **kwargs)
537537
self.add_graphic(g)
538538

539539
return weakref.proxy(g)

fastplotlib/utils/generate_add_methods.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import inspect
22
import sys
3-
from fastplotlib.graphics import *
43
import pathlib
4+
5+
from fastplotlib.graphics import *
6+
7+
58
modules = list()
69

710
for name, obj in inspect.getmembers(sys.modules[__name__]):
@@ -16,10 +19,10 @@ def generate_add_graphics_methods():
1619

1720
f = open(current_module.joinpath('layouts/graphic_methods_mixin.py'), 'w')
1821

19-
f.write('from typing import *\n')
22+
f.write('from typing import *\n\n')
2023
f.write('import numpy\n')
21-
f.write('from ..graphics import *\n')
2224
f.write('import weakref\n\n')
25+
f.write('from ..graphics import *\n\n')
2326

2427
f.write("\nclass GraphicMethodsMixin:\n")
2528
f.write(" def __init__(self):\n")
@@ -33,7 +36,7 @@ def generate_add_graphics_methods():
3336
f.write(' """\n')
3437
f.write(f' {class_name.__init__.__doc__}\n')
3538
f.write(' """\n')
36-
f.write(f" g = {class_name.__name__}(*args, **kwargs)\n")
39+
f.write(f" g = {class_name.__name__}(data=data, *args, **kwargs)\n")
3740
f.write(f' self.add_graphic(g)\n\n')
3841

3942
f.write(f' return weakref.proxy(g)\n\n')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy