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

Using ylim() with subplots does not properly redraw #7

Open
Modiug opened this issue Aug 2, 2019 · 2 comments
Open

Using ylim() with subplots does not properly redraw #7

Modiug opened this issue Aug 2, 2019 · 2 comments

Comments

@Modiug
Copy link

Modiug commented Aug 2, 2019

Versions:
Runtime: 0.41.0
Python: 1.11.0

The following script illustrates the issue. You will see double drawings in the second subplot.

import gr
from gr.pygr import mlab

import numpy as np

x = np.linspace(-4, 4, 100)

mlab.figure()

mlab.subplot(2,1,1)
mlab.plot(x, np.sin(x))
mlab.ylim(-2, 2)

mlab.subplot(2,1,2)
mlab.plot(x, np.cos(x) + 1)
mlab.ylim(-4, 4)

The example is using the Python wrapper, but I guess this is more an issue of the underlying framework.

Well, by looking at the Python wrapper code I got aware that I could also pass ylim=(...) to the plot command directly. That solves my issue, so no high urgency on this one.

Regards
Guido

@FlorianRhiem
Copy link
Member

This is an issue with the subplot implementation in the Python-Wrapper. The subplot logic works by not clearing the workstation except for the first subplot. As methods like ylim cause a redraw of the current (sub)plot, this can lead to the problem you are describing.

The subplot logic needs to be reworked in general, due to other problems as well.

@FlorianRhiem FlorianRhiem transferred this issue from sciapp/gr Aug 2, 2019
@Modiug
Copy link
Author

Modiug commented Aug 2, 2019

Indeed, I see more issues when trying to use things like hold(), ylabel() and legend(). OK, best to stay away from subplot() for now.

Background: I wanted to use some live plotting of measured signals in a GUI application. Matplotlib is rather slow, therefore GR. I was using the mlab wrapper for convenience. I should better use the GR API directly.

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

No branches or pull requests

2 participants