FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

polar rgb imshow xticks issue · Issue #2827 · matplotlib/matplotlib · GitHub

Repository navigation

polar rgb imshow xticks issue #2827

Closed as not planned
Closed as not planned

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?

Activity

  1. added this to the v1.4.0 milestone on Mar 20, 2014
  2. tacaswell commented on Mar 20, 2014

    Member

    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.

  3. modified the milestones: v1.4.x, v1.4.0 on Mar 24, 2014
  4. modified the milestones: v1.4.x, on Feb 7, 2015
  5. modified the milestones: , on Jul 17, 2015
  6. tacaswell commented on Jul 17, 2015

    Member

    @QuLogic As long as you are touching polar axes could you have a look at this bug as well?

  7. QuLogic commented on Jul 21, 2015

    Member

    As you say, it seems this bug has to do with how imshow does not work on polar axes. As the imshow appears 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.

  8. 14 remaining items

  9. modified the milestones: , on Oct 3, 2017
  10. tacaswell commented on Aug 11, 2020

    Member

    I can no longer get this do do anything sensible on the current master..

  11. github-actions commented on 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!

  12. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL