Search code examples
pythonpandasline-plot

lineplot not giving the desired results


Scenarios Node-0 Node-1 Node-2 Node-3 Node-4 Node-5
Original System 1 1 1 1 1 1
Leak_Node_1 1 0.043 1 1 1 0.0043
Leak_Node_2 1 1 1 1 1 0.012
Leak_Node_3 1 1 1 1 1 0.0086
Leak_Node_4 1 1 1 1 1 0.0085
Leak_Node_5 1 1 1 1 1 0.0076

How do I get the exact kind of line plot in the link below: https://drive.google.com/file/d/19_RVA9t7YvarTmc4W1Im2DtqevHvvZG0/view?usp=sharing

I tried using the code below:
pi1.plot.line()


Solution

  • Make sure to set 'Scenarios' as index in the dataframe and transpose it before plotting.

    pi1.set_index('Scenarios').transpose().plot.line()
    

    It should give you this results:
    resulting plot with transposed dataframe

    Note: If you need to match the colors too (since you stated exactly), use the color argument of df.plot.line() (see the documentation here)