Saturday 21 November 2020

Plotting two dataframes obtained from a loop in the same graph Python

I would like to plot two dfs with two different colors. For each df, I would need to add two markers. Here is what I have tried:

for stats_file in stats_files:
    data = Graph(stats_file)
    Graph.compute(data)
    data.servers_df.plot(x="time", y="percentage", linewidth=1, kind='line')
    plt.plot(data.first_measurement['time'], data.first_measurement['percentage'], 'o-', color='orange')
    plt.plot(data.second_measurement['time'], data.second_measurement['percentage'], 'o-', color='green')
plt.show()

Using this piece of code, I get the servers_df plotted with markers, but on separate graphs. How I can have both graphs in a single one to compare them better?

Thanks.



from Plotting two dataframes obtained from a loop in the same graph Python

No comments:

Post a Comment