Search code examples
pythonmatplotlibscatter-plot

Set two colors for a point of a matplotlib-scatter plot


So Realising that this may not possible. What I want to do, looks something like this:

point_x = [1]
point_y = [1]

col1 =    ['blue']
col2 =    ['red']

plt.scatter(point_x,point_y, c=col1,marker='o')
plt.scatter(point_x,point_y, c=col2,marker=donut?)

This would represent one point, where a portion of the (let's say) sphere, is color1, and a portion of (probably) a donut around the center of sphere, is color2.

Has anyone tried this?


Solution

  • maybe specifiying the point size s would help

    from matplotlib import pyplot as plt
    
    point_x = 1
    point_y = 1
    
    col1 = ['blue']
    col2 = ['red']
    
    plt.scatter(point_x, point_y, c=col1, marker='o', s=1000)
    plt.scatter(point_x, point_y, c=col2, marker='o', s=500)
    plt.show()
    

    output

    enter image description here