question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sgrid() and zgrid() call matplotlib.pyplot.figure()

See original GitHub issue

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 the sgrid() function calls matplotlib.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 (from examples/pvtol-nested.py) not to work as expected:

figure(10); clf();
(P, Z) = pzmap(T, Plot=True)
print("Closed loop poles and zeros: ", P, Z)

# Gang of Four
figure(11); clf();
gangof4(Hi*Po, Co);

Figure 10, which should have the output of pzmap will be blank since pzmap calls figure() (through sgrid) 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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
bnavigatorcommented, Jul 22, 2019

You already mentioned the Pandas way of providing .plot() methods to the data objects. I would consider this together with kwargs such as ax= and grid='s' to be the most pythonic.

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.

0reactions
billtubbscommented, Sep 4, 2019

B.t.w. I haven’t forgotten about this. Had to focus on another project. Hopefully the delay is not impacting the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

matplotlib.pyplot.grid — Matplotlib 3.6.2 documentation
The axis is drawn as a unit, so the effective zorder for drawing the grid is determined by the zorder of each axis,...
Read more >
Arranging multiple Axes in a Figure - Matplotlib
Specifies the geometry of the grid that a subplot will be placed. The number of rows and number of columns of the grid...
Read more >
matplotlib.pyplot.grid — Matplotlib 3.1.2 documentation
The axis is drawn as a unit, so the effective zorder for drawing the grid is determined by the zorder of each axis,...
Read more >
matplotlib.pyplot.figure — Matplotlib 3.6.2 documentation
The layout mechanism for positioning of plot elements to avoid overlapping Axes decorations (labels, ticks, etc). Note that layout managers can measurably slow ......
Read more >
matplotlib.pyplot.subplot2grid — Matplotlib 3.1.2 documentation
matplotlib.pyplot. subplot2grid (shape, loc, rowspan=1, colspan=1, ... Create an axis at specific location inside a regular grid. ... The following call.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found