Repository navigation
Closed as not planned
Labels
status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: confirmed bugstatus: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Actiontopic: polar
Milestone
Description
I'm currently trying to plot an HSV legend, i.e. a circle of color that becomes white as the radius goes to 0. I also posted this question on stackoverflow in the hope of getting a clever workaround.
Code:
def complex_to_rgb(complex_data, invert=False):
from numpy import angle, max, pi, sin, zeros
phase = angle(complex_data)
amplitude = abs(complex_data)
amplitude = amplitude/max(max(amplitude))
A = zeros((complex_data.shape[0], complex_data.shape[1], 3))
A[:,:,0] = .5*(sin(phase)+1)*amplitude
A[:,:,1] = .5*(sin(phase+pi/2)+1)*amplitude
A[:,:,2] = .5*(-sin(phase)+1)*amplitude
if(invert):
return 1-A
else:
return A
import numpy as np
from matplotlib.pyplot import figure
N = 1024
x = np.linspace(-1, 1, N)
y = np.linspace(-1, 1, N)
X,Y = np.meshgrid(x,y)
R = np.sqrt(X*X + Y*Y)
PHI = np.arctan2(Y, X)
fig = figure()
ax = fig.add_subplot(111, polar=True)
ax.imshow(complex_to_rgb(R*np.exp(1j*PHI) * (R<1), invert=True))
ax.set_xticks([-.5, 0, np.pi/2, np.pi, 3*np.pi/2])#-.5)
ax.set_yticks([0, N/3, 2*N/3, N])
ax.set_xticklabels(['', '$0$', r'$\pi/2$', r'$\pi$', r'$3\pi/2$'])
ax.set_yticklabels([])
fig.show()
Problem is, if I change the -.5 xtick (e.g. to +.5), the plot gets messed up and I get division by zero warnings:
....\lib\site-packages\matplotlib\image.py:161: RuntimeWarning: divide by zero encountered in double_scalars
sy = dyintv/viewlim.height
....\lib\site-packages\matplotlib\image.py:190: RuntimeWarning: divide by zero encountered in double_scalars
sy = dyintv/viewlim.height
I don't want the -.5 arbitrary tick mark. Why does a tick mark influence the drawing of an image?
Metadata
Metadata
Assignees
Labels
status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: confirmed bugstatus: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Actiontopic: polar
Activity
tacaswell commentedon Mar 20, 2014
That is odd.....
However I am not sure we claim to support polar axes + imshow. It looks like it does not warp the the image to polar coordinates and it is just happening to do the right thing.
tacaswell commentedon Jul 17, 2015
@QuLogic As long as you are touching polar axes could you have a look at this bug as well?
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
QuLogic commentedon Jul 21, 2015
As you say, it seems this bug has to do with how
imshowdoes not work on polar axes. As theimshowappears to be ignored, the view limits are empty. Setting additional ticks triggers something that makes the view nonsingular.Setting radial limits will fix the division issues, as will my PR at this time, but it doesn't yet fix the problem with
imshow.14 remaining items
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
BUG: Ensure polar radial limits are nonsingular.
tacaswell commentedon Aug 11, 2020
I can no longer get this do do anything sensible on the current master..
github-actions commentedon Mar 4, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!