Closed mducle closed 3 years ago
The following would change to using getframe
/ imwrite
but it does not solve the problem which is that set(0, 'DefaultFigureVisible', 'off')
doesn't seem to have the desired effect.
diff --git a/pace_python/IPythonMagics.py b/pace_python/IPythonMagics.py
index 17a2cb3..0040834 100644
--- a/pace_python/IPythonMagics.py
+++ b/pace_python/IPythonMagics.py
@@ -47,8 +47,7 @@ def showPlot(self=None, result=None):
with TemporaryDirectory() as tmpdir:
try:
interface.call('eval',
- ["arrayfun(@(h, i) print(h, sprintf('{}/%i', i), '-d{}', '-r{}'),get(0, 'children'), (1:{})')"
- .format('/'.join(tmpdir.split(os.sep)), format, resolution, nfig)],
+ [f"arrayfun(@(h, i) imwrite(frame2im(getframe(h)), sprintf(\"{'/'.join(tmpdir.split(os.sep))}/%i.{format}\", i), 'XResolution', {resolution}, 'YResolution', {resolution}), get(0, 'children'), (1:{nfig})')"],
nargout=0)
interface.call('eval', ["arrayfun(@(h) close(h), get(0, 'children'))"], nargout=0)
for fname in sorted(os.listdir(tmpdir)):
MatlabProxyObject
has doubled properties and methods! (culprit could be__dir__()
) - sort it out!!! - Uselist(set(...))
?Instead of
print
to get inline images usegetframe
andimwrite
...?Better handling of numeric type conversions:
kk = kk.set_fun(disp2sqwfun, [euobj.horace_disp, [scalefac], intrinsic_fwhm]);
wherescalefac
is integer in Python