Skip to content
Advertisement

Plotting multiple dataframes in one chart

In the following code, in each iteration a dataframe is read from a dictionary and is plotted. My intention is see all plots in one chart, but I see multiple charts in separate windows.

JavaScript

I see some tutorials about that, e.g. here, but it seems that they work when I want to call df.plot() with different columns. Here in my code, I am plotting different dataframes. Any idea on how to fix the code?

P.S: I am running the command from Linux terminal.

enter image description here

Advertisement

Answer

Consider concatenating all data together to plot data frame once. Specifically, horizontally merge with pandas.concat on the c (i.e., shared x-axis variable), renaming i (i.e., y-axis and legend series) for each dict key, and then call DataFrame.plot only once:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement