Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pymatbridge/examples/matlab_magic.ipynb

Large diffs are not rendered by default.

37 changes: 12 additions & 25 deletions pymatbridge/examples/pymatbridge.ipynb

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions pymatbridge/matlab_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ def set_matlab_var(self, name, value):
help='Do not display text output of MATLAB command'
)

@argument(
'-S', '--size', action='store', default='512,384',
help='Pixel size of plots, "width,height.'
)

@argument(
'code',
nargs='*',
Expand All @@ -169,6 +174,9 @@ def matlab(self, line, cell=None, local_ns=None):
if local_ns is None:
local_ns = {}

width, height = args.size.split(',')
self.Matlab.set_default_plot_size(width, height)

if args.input:
if has_io:
for input in ','.join(args.input).split(','):
Expand Down
8 changes: 8 additions & 0 deletions pymatbridge/pymatbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def start(self):
# Test if connection is established
if self.is_connected():
print("%s started and connected!" % self._program_name())
self.set_default_plot_size()
return True
else:
print("%s failed to start" % self._program_name())
Expand Down Expand Up @@ -282,6 +283,13 @@ def set_variable(self, varname, value):
return self.run_func('pymat_set_variable.m',
{'name': varname, 'value': value})

def set_default_plot_size(self, width=512, height=384):
code = "set(0, 'defaultfigurepaperunits', 'inches');\n"
code += "set(0, 'defaultfigureunits', 'inches');\n"
size = "set(0, 'defaultfigurepaperposition', [0 0 %s %s])\n;"
code += size % (int(width) / 150., int(height) / 150.)
self.run_code(code)

def _set_sparse_variable(self, varname, value):
value = value.todok()
prefix = 'pymatbridge_temp_sparse_%s_' % uuid4().hex
Expand Down