-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PySmithPlot/Polar Plot update broken in 2.1.2 (works in 2.0.2) #10654
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
@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) ? |
Will do. |
@chrisgmorton Just in case:
|
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. |
I'm getting the following with this release: File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/pysmithplot-0.2.0-py3.6.egg/smithplot/smithaxes.py", line 501, in get_yaxis_text1_transform
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 681, in __get__
instance.majorTicks = [instance._get_tick(major=True)]
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 2161, in _get_tick
return YTick(self.axes, 0, '', major=major, **tick_kw)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 186, in __init__
self.label1 = self._get_text1()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 568, in _get_text1
trans, vert, horiz = self._get_text1_transform()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 545, in _get_text1_transform
return self.axes.get_yaxis_text1_transform(self._pad)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/pysmithplot-0.2.0-py3.6.egg/smithplot/smithaxes.py", line 501, in get_yaxis_text1_transform
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 681, in __get__
instance.majorTicks = [instance._get_tick(major=True)]
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 2161, in _get_tick
return YTick(self.axes, 0, '', major=major, **tick_kw)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 186, in __init__
self.label1 = self._get_text1()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 568, in _get_text1
trans, vert, horiz = self._get_text1_transform()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 545, in _get_text1_transform
return self.axes.get_yaxis_text1_transform(self._pad)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/pysmithplot-0.2.0-py3.6.egg/smithplot/smithaxes.py", line 501, in get_yaxis_text1_transform
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 681, in __get__
instance.majorTicks = [instance._get_tick(major=True)]
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 2161, in _get_tick
return YTick(self.axes, 0, '', major=major, **tick_kw)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 186, in __init__
self.label1 = self._get_text1()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 568, in _get_text1
trans, vert, horiz = self._get_text1_transform()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 545, in _get_text1_transform
return self.axes.get_yaxis_text1_transform(self._pad)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/pysmithplot-0.2.0-py3.6.egg/smithplot/smithaxes.py", line 501, in get_yaxis_text1_transform
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 681, in __get__
instance.majorTicks = [instance._get_tick(major=True)]
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 2161, in _get_tick
return YTick(self.axes, 0, '', major=major, **tick_kw)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 182, in __init__
self.tick1line = self._get_tick1line()
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/axis.py", line 605, in _get_tick1line
zorder=self._zorder)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/lines.py", line 401, in __init__
self._marker = MarkerStyle(marker, fillstyle)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/markers.py", line 188, in __init__
self.set_fillstyle(fillstyle)
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/markers.py", line 235, in set_fillstyle
fillstyle = rcParams['markers.fillstyle']
File "/Users/chrisgmorton/work/fusion/prod/lib/python3.6/site-packages/matplotlib/__init__.py", line 940, in __getitem__
val = dict.__getitem__(self, key)
RecursionError: maximum recursion depth exceeded while calling a Python object |
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. |
I'll try and put something together for you. Will take a little time. |
Attn @QuLogic who fixed a lot of things in polar plots recently :). |
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): |
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)? |
|
😮 turns out this is my fault! Bisects to 4bc50da |
Is your commit fixable first, or should I look at mine first? |
I think I can fix mine working by working on a commit before yours. |
PySmithPlot is doing a lot of wrapping of stuff; I have a feeling that a lot of it is provided in the polar changes in 2.0.0. The RecursionError is possibly related to all this wrapping, but I haven't untangled the backtrace yet. |
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. |
The only time
so I wonder if it's something to do with an |
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. |
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. |
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. |
Here is the second test case: import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma
S=np.array([[0.3+0.1j,0.2+0.3j],[0.4-0.5j,-0.3+0.7j],[3.1+0.9j,-0.9-0.3j]])
Splt=ma.array(S)
Splt[:]=ma.masked
fig=plt.figure()
axis=fig.add_subplot(111,projection='polar')
lines=axis.plot(np.angle(Splt.T), np.absolute(Splt.T), marker='x')
[line.set_xdata(np.angle(S[i])) for i,line in enumerate(lines)]
[line.set_ydata(np.absolute(S[i])) for i,line in enumerate(lines)]
axis.set_rlim(np.max(1.1*np.absolute(S)))
axis.legend(np.arange(len(lines)+1),loc=0)
plt.show() 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 |
It seems to work (apart from the radial limits) if |
If you do |
So that's mostly not a bug then. If you pass a single value to 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 |
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. |
Great, glad to hear it's fixed! |
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
|
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. |
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:
Lines initialized with:
Lines updated with:
Actual outcome
Matplotlib 2.1.2 output, on completion of simulation:
Expected outcome
Matplotlib 2.0.2 output, on completion of simulation:
Matplotlib version
Matplotlib installed using pip. Qt5 and PyQt5 built from source. Python 3.6.4 built from source.
The text was updated successfully, but these errors were encountered: