-
Notifications
You must be signed in to change notification settings - Fork 438
sgrid() and zgrid() call matplotlib.pyplot.figure() #291
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
Comments
I'm wondering whether functions should be calling How about we have an optional keyword argument, If there are other ways to do this please suggest them. I can have a go at implementing this with |
This is how Pandas plot functions work I think. See
Should we follow this approach? |
I agree that we should not be calling This fix might be a bit more complicated because some functions (like |
It will get a bit tricky with functions that make plots with multiple axes but Pandas handles this with a Right now, how about I just implement this concept for a one-axis plot like Is now a good time to make a branch or shall I wait for the merge of your matrix/array PR? |
I'm working on merging a bunch of pending PRs right now. This takes a while since I need to let Travis CI run for each one to make sure there are no interactions in the unit tests that cause it to fail. Should be done in another 30 min or so. |
Also, down the road we could make some of these plot functions into object methods. Like this:
|
I'm working on this now (sorry for the delay...). I've solved the problem for As I have it now, the following example (borrowed from MATLAB documentation) works as follows:
In this case, a new figure is generated very similar to MATLAB when plt.show() is called. The second use case is as follows:
In this case, rlocus and zgrid add things to the current axis of the existing figure. A third option is something like this:
Is this the functionality we want? Are these good examples of use cases? Note: This is a slight departure from MATLAB here because functions like rlocus and pzmap rename the window name of the figure in MATLAB (e.g. to "Root Locus"). Here, I will only change the axis title to "Root Locus" instead, leaving the window title alone. |
I just noticed some other functionality that this is going to conflict with. The current rlocus function gets a list of all existing figures and makes the name of the new figure |
So, I think I have a working version. Except one test failed:
Not sure what unittest.runner.TextTestResult is. |
It's a generic class from the unittest module Do you have the full output of the test command, or a traceback? |
The functionality that you outlined above sounds good to me. In terms of the figure title: my recollection is that this is updated to show the current gains => we probably don't want to get rid of that functionality completely. We also need to check to make sure that the new functionality works within Finally, note that there are some changes to |
Okay thanks for the feedback.
|
@bnavigator thanks, I'm struggling to figure out how to share the Travis CI build log - if that's what you're looking for. Doesn't seem to be an obvious copy or share button. Can you see it at this link? |
I am not sure if I selected the correct branch and CI job, but I think this link shows the actual problem:
... which then fails with the mentioned
I guess your edits produce unexpected behavior with the rlocus plot zoom test. Given you actually change the behaviour, this means the unittest also needs to be adjusted. |
That's it! How on earth do you find that in 3000 lines of log output? Actually that's not it. It's build 11.4 that I was looking at. |
Same failure: Just search for FAIL, that string only occurs 11 times. |
My browser won't show me the search results.... But I just discovered the 'show raw log as text file' button. Thanks! (First time I've used Travis). |
Okay, sorry for the delay @murrayrm I got the Background: The problem with sgrid is that the curvilinear axis can't be super-imposed on an existing axis. You have to delete any existing axis and re-create a new one using the special
The example's is a bit complicated but it produces two root-locus plots side-by-side, one with the standard grid and the second with an sgrid. See image 1 here. The Matlab way to make an sgrid is as follows:
This produces one plot like image 2 here. The main differences are:
I should add. You can still do a simple one-axis plot in python like this:
If this all looks okay, I'll move on to checking sisotool works with this (should be easier as sisotool will now have more control over the root locus plot). |
I only noticed now that Matlab has separate functions for handling plot manipulation - very similar to what we are trying to do here with Example:
For
I wasn't aware of these at the start so went down the route of allowing passing of an existing axis to Does this change that decision? I'll have a think about this but maybe I should revert to having |
Will respond in more detail in a bit, but as a general principle we want to by "pythonic" versus MATLAB centric. We can use the Perhaps worth looking at how other packages that build on |
Thats good direction to give, thanks. That means we can think out of the box a bit more in terms of a holistic solution to all these methods working effectively:
Are there other methods that make plots that I need to add to this list? |
I can't find any plotting functions in
I'm looking for an example that illustrates the use of this Oh, I see we have already implemented |
You already mentioned the Pandas way of providing If you want to retain the MATLAB way of calling sgrid() after creating the plot, I have added a comment at StackOverflow with another idea to add the grid axis. Using the pylab API in matplotlib has been deprecated for a reason, though. Likewise python-control should not try to stick to that coding paradigm either. |
B.t.w. I haven't forgotten about this. Had to focus on another project. Hopefully the delay is not impacting the project. |
While debugging some code I noticed that
examples/pvtol-nested.py
was producing a blank figure instead of a pole-zero map that was expected. I chased this down tto the fact that thesgrid()
function callsmatplotlib.pyplot.figure()
. This is in contrast to all other plotting routines and the consequence is that you get a new set of axes. This causes the following code (fromexamples/pvtol-nested.py
) not to work as expected:Figure 10, which should have the output of
pzmap
will be blank sincepzmap
callsfigure()
(throughsgrid
) and creates a new set of axis (figure #11). Figure #11 will then get erased (away goes the pole/zero map) and be replace by the Gang of 4.The text was updated successfully, but these errors were encountered: