How do I force scatter points real pixel values when plotting in pyplot/python?
Question: I've taken an image and extracted some features from it using OpenCv. I'd like
to replot those points and their respective areas (which are real pixel
values) into a scatter window and then save it. Unfortunately, when I plot the
points, they resize to stay more visible. If I zoom in they resize. I'd like
to save the whole figure retaining the actual ratio of pixel (x,y) coordinates
to size of points plotted.

For instance:

    
    
    import matplotlib.pyplot as plt   
    x=[5000,10000,20000]
    y=[20000,10000,5000]
    area_in_pixels=[100,200,100]
    scatter(x,y,s=area_in_pixels)
    

I would like this to produce tiny dots on the image. They should span like 10
xy units. However, the dots it produces are large, and appear to span 1000 xy
units.

I've tried resizing the image with:

    
    
    plt.figure(figsize=(10,10))
    

Which seems to resize the points relative to their position a little. But I'm
not sure what scale I would select to make this accurate. DPI settings on
plt.figsave seem to make the saved image larger but don't appear to alter
relative spot sizes.

Asked another way, is there another way to relate the s which is in points^2
to a real number or to the units of the x-y axis?


Answer: You can use [patches](http://matplotlib.org/api/artist_api.html#module-
matplotlib.patches) to create markers sized relative to the data coordinates.

    
    
    import matplotlib.pyplot as plt   
    from matplotlib.patches import Circle
    
    
    xData=[5000,10000,20000, 15000]
    yData=[20000,10000,5000, 15000]
    radius_in_pixels=[100,200,100, 1000] # Circle takes radius as an argument. You could convert from area. 
    
    
    fig = plt.figure()
    ax = fig.add_subplot(111, aspect='equal')
    
    for x, y, r in zip(xData, yData, radius_in_pixels):
        ax.add_artist(Circle(xy=(x, y), radius = r))      
    
    plt.xlim(0, max(xData) + 200)
    plt.ylim(0, max(yData) + 200)
    plt.show()
    

![scatter plot using circle patches](http://i.stack.imgur.com/MThfK.png)

