Repository navigation
Description
Bug report
Bug summary
The smith chart grid is distorted in 2.1.2, correct in 2.0.2.
Updating the polar plot data blanks the plot in 2.1.2, updates properly in 2.0.2.
In both versions when I create the plots/lines I see:
/Users/chrisgmorton/usr/tcad/fusion/prod/lib/python3.6/site-packages/pysmithplot-0.2.0-py3.6.egg/smithplot/smithhelper.py:46: RuntimeWarning: divide by zero encountered in true_divide
/Users/chrisgmorton/usr/tcad/fusion/prod/lib/python3.6/site-packages/pysmithplot-0.2.0-py3.6.egg/smithplot/smithhelper.py:46: RuntimeWarning: invalid value encountered in true_divide
/Users/chrisgmorton/usr/tcad/fusion/prod/lib/python3.6/site-packages/matplotlib/projections/polar.py:58: RuntimeWarning: invalid value encountered in less
mask = r < 0
On the first update of the plots I see:
Users/chrisgmorton/usr/tcad/fusion/prod/lib/python3.6/site-packages/matplotlib/projections/polar.py:58: RuntimeWarning: invalid value encountered in less
mask = r < 0
and the polar plots are then blanked out (not so with 2.0.2).
Code for reproduction
Plots are built with:
self.axes=[]
n = self.numberOfPorts
for i,j in self.indices:
if i==j: self.axes.append(self.fig.add_subplot(n,n,1+i*2+j, projection='smith'))
else: self.axes.append(self.fig.add_subplot(n,n,1+i*2+j, projection='polar'))
for k,(i,j) in enumerate(self.indices):
self.axes[k].tick_params(which='major', labelsize=10)
self.fig.subplots_adjust(top=0.9)Lines initialized with:
self.lines=[]
for m,(i,j) in enumerate(self.indices):
if i==j: # Smith Chart
S=self.Splt.T[j,i].T
Z = (1+S)/(1-S) # normalized impedance on Smith Chart
self.lines.append(self.axes[m].plot(Z.T, color='b', marker='', markerfacecolor='b', markeredgecolor='b'))
else: # Polar Plot
S = self.Splt.T[j,i].T
self.lines.append(self.axes[m].plot(np.angle(S.T), np.absolute(S.T), color='r', marker='', markerfacecolor='r', markeredgecolor='r'))Lines updated with:
for k,(i,j) in enumerate(self.indices):
if i==j: # Smith Chart
S=self.Splt.T[j,i].T
Z = (1+S)/(1-S) # normalized impedance on Smith Chart
[line.set_xdata(np.real(Z[idx])) for idx, line in enumerate(self.lines[k])]
[line.set_ydata(np.imag(Z[idx])) for idx, line in enumerate(self.lines[k])]
else: # Polar Plot
S = self.Splt.T[j,i].T
[line.set_xdata(np.angle(S[idx])) for idx, line in enumerate(self.lines[k])]
[line.set_ydata(np.absolute(S[idx])) for idx, line in enumerate(self.lines[k])]Actual outcome
Matplotlib 2.1.2 output, on completion of simulation:
Expected outcome
Matplotlib 2.0.2 output, on completion of simulation:
Matplotlib version
- Operating system: Ubuntu 16.04 and OSX 10.13.3
- Matplotlib version: 2.1.2
- Matplotlib backend: Qt5Agg (Qt5.10)
- Python version: 3.6.4
- PySmithPlot version: 0.2
Matplotlib installed using pip. Qt5 and PyQt5 built from source. Python 3.6.4 built from source.


Activity
afvincent commentedon Mar 3, 2018
@chrisgmorton Would you have the possibility to test it with the current release candidate (2.2.0rc1), which is available on pip or conda(-forge) ?
chrisgmorton commentedon Mar 3, 2018
Will do.
afvincent commentedon Mar 3, 2018
@chrisgmorton Just in case:
chrisgmorton commentedon Mar 3, 2018
I used pip3 install matplotlilb==2.2.0rc1 which seemed to work fine.
I'm getting an error with 2.2.0rc1:
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'
I will try and work around to complete the test.
chrisgmorton commentedon Mar 3, 2018
I'm getting the following with this release:
afvincent commentedon Mar 3, 2018
The issue with the
spectralcolor scale is likely to occur because it was deprecated in favor ofnipy_spectral. See for example #7315 or #7416afvincent commentedon Mar 3, 2018
Would it be possible to have a stand-alone working example that triggers the issue? Without it, it may be hard to track down the source of the problem.
chrisgmorton commentedon Mar 3, 2018
I'll try and put something together for you. Will take a little time.
afvincent commentedon Mar 3, 2018
Attn @QuLogic who fixed a lot of things in polar plots recently :).
chrisgmorton commentedon Mar 5, 2018
There are likely two separate issues here. Here's a reproducible case for the first which is specifically that the gridlines for the smith chart produced by pySmithPlot are messed up in matplotlib 2.1.2 vs 2.0.2. To reproduce:
Install pySmithPlot 0.2 from GitHub: https://github.com/vMeijin/pySmithPlot
In the pySmithPlot-master/testbenches directory, run the script smith_short_test.py.
I am using Qt5 so you first will need to set matplotlib's backend to Qt5Agg (I'm not sure that matters for reproducing the issue).
In matplotlib 2.0.2 you see (correct grid):
In matplotlib 2.1.2 you see (incorrect grid):
dstansby commentedon Mar 5, 2018
I bet this is an interpolation steps issue... Can you post a self contained example that just plots the gridlines, and doesn't plot any of the data (it can include importing pysmithplot as a dependency)?
chrisgmorton commentedon Mar 5, 2018
dstansby commentedon Mar 5, 2018
😮 turns out this is my fault! Bisects to 4bc50da
dstansby commentedon Mar 5, 2018
@anntzer running the example above also results in a RecursionError on the master branch, which bisects to c935965
4 remaining items
jklymak commentedon Mar 5, 2018
Yes would be preferable to have a non-downstream breaking example a)so we can tell what’s going on and b) so we can add a test.
dstansby commentedon Mar 5, 2018
The only time
pySmitPlotcallsArcisso I wonder if it's something to do with an
Arcwith a custom transform set.dstansby commentedon Mar 5, 2018
Okay @chrisgmorton , some digging has revealed that the problem comes from this line: https://github.com/vMeijin/pySmithPlot/blob/master/smithplot/smithaxes.py#L1254. I suspect you are doing something slightly wrong when manually reversing the order vertices in the path you are manually creating.
Matplotlib handles angles that are the wrong way round okay, so you can just get rid of the 'reverse' case in your code and everything works fine as far as I can tell.
chrisgmorton commentedon Mar 5, 2018
I'm not the author of pySmithPlot but I can try removing the reverse cases in the package to see if this resolves my issue. More on the other polar issue shortly.
chrisgmorton commentedon Mar 5, 2018
Well, this seems to have solved some of the grid line plotting problems but we still do not have the result shown with matplotlib 2.0.2. This is what the plot looks like with the reverse cases removed:
We probably need to get the author to respond. I've opened an issue in the pySmithPlot project. I'll reference this issue there.
chrisgmorton commentedon Mar 6, 2018
Here is the second test case:
In matplotlib 2.0.2 this works correctly and displays three lines on the polar plot. In Matplotlib 2.1.2 it displays a blank polar plot with no gridlines and no lines. In Matplotlib 2.2 the result is erroneous, the same as with 2.1.2, but also the following messages are displayed in the terminal window:
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
dstansby commentedon Mar 6, 2018
It seems to work (apart from the radial limits) if
set_rlimis commented out, so the problem must be in there somewhere.dstansby commentedon Mar 6, 2018
If you do
set_rlim(0, upper_lim), it works fine. That needs documenting and testing on our side though...QuLogic commentedon Mar 6, 2018
So that's mostly not a bug then. If you pass a single value to
set_ylim, then it's used for the bottom limit. Previously,set_rlimwould only allow passing the top limit and force the bottom to 0. This is no longer the case as negative limits are allowed, and is generally documented in the polar what's new section.What ends up happening in the end is the bottom limit is greater than the top; I would guess that this should maybe be supported, but as that would invert the axis (as it does in Cartesian coordinates), I suspect that's not what you'd want anyway. @dstansby's fix is the better option for you. You could also do
.set_rlim(top=....).chrisgmorton commentedon Mar 6, 2018
Using .set_rlim(top=...) resolves the problem with the polar plots for me. I've made those changes on my side already. I will still need to stick with 2.0.2 until @vMeijin can update pySmithPlot. Thanks.
dstansby commentedon Mar 7, 2018
Great, glad to hear it's fixed!
vMeijin commentedon Apr 11, 2018
I found the error with the broken Smithchart. It seems that the 'Arc' class I use to create the grid lines was changed. This line was remove
matplotlib/lib/matplotlib/patches.py
Line 1557 in 9212e59
QuLogic commentedon Apr 12, 2018
@vMeijin a better fix is to remove the reversal, as noted here. It does not appear to be necessary.
vMeijin commentedon Apr 12, 2018
Removing the reversal does not work. The previous plot already shows that the diagram is still broken with it. The problems seems to be, that the arcs are actually circles due to the removal of the mentioned line of code.