[Python] How to make circular barplot exactly like picture in python

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I tried to make circular bar plot in python and the result is:

    [​IMG]

    import matplotlib.pyplot as plt
    import numpy as np

    # Data
    N = 7
    theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
    radii = np.array([5, 7, 3, 8, 6, 4, 9])
    width = np.pi / (2 * N) # Adjust width for visual appeal

    # Create polar plot
    fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})

    # Set a custom starting radius for the bars
    custom_radius_start = 2

    # Plot the bars with the custom bottom position
    ax.bar(theta, radii, width=width, bottom=custom_radius_start, color=plt.cm.viridis(radii / 10.))

    # Customize appearance (optional)
    ax.set_theta_zero_location("N") # Start from top (North)
    ax.set_theta_direction(-1) # Clockwise direction
    ax.set_rlabel_position(225) # Move radial labels
    ax.set_title("Circular Bar Plot with Custom Radius Position")

    plt.show()


    How to make circular bar plot exactly like the picture below in python:

    [​IMG]

    Did any one have an idea how to do it?

    Continue reading...

Compartilhe esta Página