title: How to extract RGB from an image and plot only RG as a graph? R for X and G for Y
body: <p>I am trying to extract the RGB components from an image and plot the 3D RGB histogrma using matplotlib. But I dont know how can I do it.</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>import cv2
  import numpy as np
  from scipy import ndimage
  from matplotlib import pyplot as plt
  
  img_file = 'Paw03.png'
  img = cv2.imread(img_file, cv2.IMREAD_COLOR)           # rgb
  #hsv_img = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)         # hsv
  
  rows, cols, ch = img.shape
  
  for x in range(rows):
      for y in range(cols):
          if (img[x, y, 1] == img[0, 255, 0]):
              break;
          else:
              print "Pixel:", x, y
              print  "R:", R 
              print  "G:", g
              print  "B:", b
              print "\n"
  
  plt.plot(r, 'ro', b, 'b^')
  plt.xlim([0, 255])
  plt.xlabel('Pixel')
  plt.ylabel('Quantity')
  plt.title('Distribution of RGB in the image')
  plt.show()
  </code></pre>
  
  <p>But it doesn't work!</p>
  
  <p>So, I tried with three for:</p>
  
  <pre><code>import cv2
  import numpy as np
  from scipy import ndimage
  from matplotlib import pyplot as plt
  
  img_file = 'Paw03.png'
  img = cv2.imread(img_file, cv2.IMREAD_COLOR)           # rgb
  #hsv_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)        # hsv
  
  rows, cols, ch = img.shape
  
  for x in range(rows):
      for y in range(cols):
          for z in range(ch)
              if (img[x, y, z] == img[0, 255, 0]):
                  break;
              else:
                  print "Pixel:", x, y
                  print  "R:", R 
                  print  "G:", g
                  print  "B:", b
                  print "\n"
  
  plt.plot(r, 'ro', b, 'b^')
  plt.xlim([0, 255])
  plt.xlabel('Pixel')
  plt.ylabel('Quantity')
  plt.title('Distribution of RGB in the image')
  plt.show()
  </code></pre>
  
  <p>It works only for the print into the for and also save three times for each pixel, and for matplotlib it doesn't work.</p>
  
  <p>Anyone can help me?</p>