0

I have python code which gives me a nice plot of data points for daily data that uses the x axis as the index values and the plot looks like this - however, I need the plots to overlap using the "day" column as the x axis exactly once, which is day of the month. I have experimented with forcing python to use the column = "day" but it only plots the first dataset below in color blue and does not overplot anything else. The df is "vardapp" and it looks like this and you can see it repeating the "day" for the new site at the bottom of the data:

   windfarm_name month day  wind_speed  windspeed_var
0    Bii Nee Stipa    01  01   10.216449     -12.817107
1    Bii Nee Stipa    01  02    4.864663     -61.904317
2    Bii Nee Stipa    01  03    8.845685     -38.252045
3    Bii Nee Stipa    01  04   13.556436      -4.797194
4    Bii Nee Stipa    01  05   24.896567      86.372234
5    Bii Nee Stipa    01  06   19.514571      59.931691
6    Bii Nee Stipa    01  07   13.750371      13.368952
7    Bii Nee Stipa    01  08   21.063892      63.505635
8    Bii Nee Stipa    01  09   16.845504      29.590611
9    Bii Nee Stipa    01  10   12.385604      -0.013361
10   Bii Nee Stipa    01  11    6.457759     -48.348978
11   Bii Nee Stipa    01  12   15.470661      28.099458
12   Bii Nee Stipa    01  13   16.196108      31.303636
13   Bii Nee Stipa    01  14   14.808146       4.366317
14   Bii Nee Stipa    01  15   14.587771       6.954249
15   Bii Nee Stipa    01  16   12.916171       3.979865
16   Bii Nee Stipa    01  17   16.414679      26.844546
17   Bii Nee Stipa    01  18   15.130937      16.583364
18   Bii Nee Stipa    01  19   13.664704       3.987023
19   Bii Nee Stipa    01  20   16.773542      22.075303
20   Bii Nee Stipa    01  21   21.771258      83.734407
21   Bii Nee Stipa    01  22   16.830437      59.464314
22   Bii Nee Stipa    01  23    6.297325     -41.112161
23   Bii Nee Stipa    01  24    5.664542     -55.242947
24   Bii Nee Stipa    01  25   10.191253     -25.543095
25   Bii Nee Stipa    01  26    6.021920     -55.125940
26   Bii Nee Stipa    01  27    4.991909     -60.897336
27   Bii Nee Stipa    01  28    4.024492     -65.819717
28   Bii Nee Stipa    01  29    4.447253     -62.337953
29   Bii Nee Stipa    01  30   12.801230      13.478845
30   Bii Nee Stipa    01  31    4.156125     -66.113852
31   Dos Arbolitos    01  01    8.771198      -4.817152
32   Dos Arbolitos    01  02    4.971465     -49.641634

Here is the code I'm using -

 for key, grp in vardapp.groupby(['windfarm_name']):
    plt.plot(grp['windspeed_var'], label=key)
    #plt.xticks(vardapp.day,vardapp["day"].values)
 plt.legend(loc='best')    
 plt.show()

enter image description here

1 Answer 1

1

I think this solve what you are trying to do:

vardapp.set_index(['windfarm_name', 'day']).unstack('windfarm_name')['windspeed_var'].plot()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.