-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
log scale and polar broken #24383
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
@Gerald-Meyers could you possibly trim that data down to the minimal needed to reproduce (or is this not data dependent)? |
This bug doesn't seem data dependent. Here's a small reproduction import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1, figsize=(8, 8),
subplot_kw={'projection': 'polar'})
xvals, yvals = [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]
ax.plot(xvals, yvals)
ax.set_yscale('log')
plt.show() Which gives this error
|
Appears to be related to matplotlib/lib/matplotlib/projections/polar.py Lines 434 to 439 in 9d8fde2
In particular I'm suspicious that the vmin capping at 0 may not be desirable with log scale, but haven't fully worked out the details. |
The 0 cap was added to preserve old behaviour from when it didn't support negative radii. However, I don't think log scales were supported then either. |
I've idependently stumbled upon this investigating something else. An even smaller example: import matplotlib.pyplot as plt
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.set_yscale('log')
plt.show() 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
/Users/dstansby/github/matplotlib/lib/matplotlib/scale.py:253: RuntimeWarning: overflow encountered in power
return np.power(self.base, a) |
At least one issue is the polar limits are not being set to finite values (ie. on a log scale, vmin > 0): import matplotlib.pyplot as plt
for kw in [{}, dict(subplot_kw={'projection': 'polar'})]:
fig, ax = plt.subplots(**kw)
ax.set_yscale('log')
print(ax.get_ylim(), kw) (0.8912509381337456, 11.220184543019636) {} |
I can assure you I tested this on 6 different data sets. The data is not the problem. It it matters, you are more than welcome to slice the data when you np.genfromtxt. The polar plot did function as expected without radial log-scale. However, the circular grid lines for the r values ranged from 0 to 1, not from 0 to 1e7. For example, here is normal plot of one of my data sets without any log-scale over the domain [20,80]=Δ60 degrees. Here is the same data set, but with the extra line of code
It is worth noting that there are no non-positive(=negative,zero) values in this data set. And the same polar plot when I enable the radial log-scale with Here is another data set over a 1 degree domain. And the same data with polar as before. Clearly there are a few more issues than just 'log-scale' broken. |
I found a solution to this problem, just upgrade the package |
Example of working code is:
Plot functions correctly(ish) but when set to a log-plot the plot malfunctions: the error ""posx and posy should be finite values"" and the entire plot is a blank circle. The 'r' labels are still not correct normally.
Originally posted by @Gerald-Meyers in #11202 (comment)
The text was updated successfully, but these errors were encountered: