Skip to content

Plot real time the Data in same graph #1

@SanujaRupasinghe

Description

@SanujaRupasinghe

def update_graph(x, y, refresh_time):
plt.plot(x, y)
plt.pause(refresh_time)
plt.show()

maybe used refresh time (1/sampling frequency) this may work

def update_graph(x, y, refresh_time):
plt.ion() # Turn on interactive mode (important for updating plot)
fig, ax = plt.subplots() # Create figure and axis objects

while True:
    # example data generation
    x_new = np.linspace(0, 10, 100) 
    y_new = np.random.rand(100)       

    # Update existing plot with new data
    ax.clear()  # Clear previous plot
    ax.plot(x_new, y_new)  # Plot new data
    # set axis limits
    ax.set_xlim(0, 10)  
    ax.set_ylim(0, 1)  
    plt.pause(refresh_time)  # Pause to update plot
    fig.canvas.flush_events()  # Flush events to update plot

update_graph(None, None, 0.1)

WhatsApp.Video.2024-04-18.at.10.22.14_07eb096a.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions