Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to plot floating figures #101

Closed
ImmanuelSamuel opened this issue Dec 5, 2014 · 11 comments · Fixed by #150
Closed

How to plot floating figures #101

ImmanuelSamuel opened this issue Dec 5, 2014 · 11 comments · Fixed by #150

Comments

@ImmanuelSamuel
Copy link

Hi, How can I run "figure" in a ipython cell and get the figure on a floating window? Right now I get a blank space inline. I would like to plot an image and use matlab figure properties. I also have some custom tools on an interactive figure window. Is this possible?
Thanks

@arokem
Copy link
Owner

arokem commented Dec 6, 2014

Try running it after starting the Matlab object with:

Matlab(startup_options='-nodesktop')

The default is to also have a '-nodisplay' in there, so it doesn't pop up.

On Fri, Dec 5, 2014 at 1:54 PM, ImmanuelSamuel notifications@github.com
wrote:

Hi, How can I plot run "figure" in a ipython cell and get the figure on a
floating window? Right now I get a blank space inline. I would like to plot
an image and use matlab figure properties. I also have some custom tools on
an interactive figure window. Is this possible?
Thanks


Reply to this email directly or view it on GitHub
#101.

@ImmanuelSamuel
Copy link
Author

Ok I got that. One more question.
If I run the following code

%%matlab
a = 1
workspace

I dont get my variable a in the workspace window that pops up. I am assuming that the matlab instance is same so it should have the variable correct?

@arokem
Copy link
Owner

arokem commented Dec 8, 2014

Yes - it is the same matlab instance. Do you get the same thing if you call
workspace in the following cell?

On Mon, Dec 8, 2014 at 6:41 AM, ImmanuelSamuel notifications@github.com
wrote:

Ok I got that. One more question.
If I run the following code

%%matlab
a = 1
workspace

I dont get my variable a in the workspace window that pops up. I am
assuming that the matlab instance is same so it should have the variable
correct?


Reply to this email directly or view it on GitHub
#101 (comment)
.

@ImmanuelSamuel
Copy link
Author

Yup the same thing.

Running the following also results in the same
Code:
results = mlab.run_code('a=1;')
mlab.run_code('workspace')
print(results)
mlab.get_variable('a')

Output:

{'content': {'figures': [], 'code': 'a=1;', 'datadir': '/tmp/MatlabData/', 'stdout': ''}, 'success': 'true'}

Out:
1

@arokem
Copy link
Owner

arokem commented Dec 8, 2014

Yeah - I get that too. I am not sure what to make of it. When I run
'who'/'whos' the variable is clearly there, but not when I run 'workspace'.
No such issue when I run this in a terminal with '-nodesktop'.

On Mon, Dec 8, 2014 at 8:31 AM, ImmanuelSamuel notifications@github.com
wrote:

Yup the same thing.

Running the following results in the same
Code:
results = mlab.run_code('a=1;')
mlab.run_code('workspace')
print(results)
mlab.get_variable('a')

Output:

{'content': {'figures': [], 'code': 'a=1;', 'datadir': '/tmp/MatlabData/',
'stdout': ''}, 'success': 'true'}

Out:
1


Reply to this email directly or view it on GitHub
#101 (comment)
.

@ImmanuelSamuel
Copy link
Author

Huh interesting! Would be neat to find out exactly whats happening. Also in the workspace window that opens the right click -> new option to add a variable doesn't work. Maybe this might help with figuring out whats happening.

@ImmanuelSamuel
Copy link
Author

Also is there a way to issue the 'startup_options='-nodesktop'' when using load_ext pymatbridge?

@arokem
Copy link
Owner

arokem commented Dec 9, 2014

Unfortunatly not, and see also:
ipython/ipython#6888

On Tue, Dec 9, 2014 at 7:12 AM, ImmanuelSamuel notifications@github.com
wrote:

Also is there a way to issue the 'startup_options='-nodesktop'' when using
load_ext pymatbridge?


Reply to this email directly or view it on GitHub
#101 (comment)
.

@blink1073
Copy link
Collaborator

I think I traced the issue (at least on Linux). Since we are always running the matlabserver function, the GUI event loop is not able to run. You can test it with the following snippet:

function loop()
  plot([1,2,3])
  while 1
  end
end

If you run this function, the plot is not shown until you hit Ctrl+C. If you remove the infinite while, the plot is shown after the function ends.

@blink1073
Copy link
Collaborator

But this works:

function loop()
  plot([1,2,3])
  while 1
      pause(0.001)
  end
end

@blink1073
Copy link
Collaborator

Hmm, the actual inner loop appears to be here, which means we'd have to go to a non-blocking zmq_read to support a GUI event loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants