[Python] Correct Sizing of Markers In Scatter Plot to a Radius R in Matplotlib

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have a plot with limits -1 to 1. I know the scatter plot doesn't plot with size as a radius, it plots with size as a point.

    I need my plot to be scaled correctly with the size of each point, which I have as a radius. Is this possible with modifications to the below code?

    fig, ax = plt.subplots(1)
    ax.set_title("Post Synaptic Neurons")
    sizes = [x.size * 100 for x in post_synaptic_neurons]
    offsets = [(x.origin[0],x.origin[1]) for x in post_synaptic_neurons]
    print(sizes)
    ax.scatter([x.origin[0] for x in post_synaptic_neurons], [x.origin[1] for x in post_synaptic_neurons],
    cmap=plt.cm.hsv, s=sizes, alpha=0.5)
    ax.set_xlim([-1,1])
    ax.set_ylim([-1,1])
    ax.set_aspect(1)
    plt.tight_layout


    If no, can someone explain to me why matplotlib doesn't have a function for plotting a circle with a particular radius on the scale of the plot? I didn't expect this to be an issue, but there must be a good reason behind my difficulties.

    Continue reading...

Compartilhe esta Página