Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

polar rgb imshow xticks issue #2827

Closed as not planned
Closed as not planned
@rubenvb

Description

@rubenvb

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 onstackoverflow 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 Aimport numpy as npfrom matplotlib.pyplot import figureN = 1024x = 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

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp