2

I have a dataset of traffic flow for different stations. enter image description here

I am trying to plot them only for a limited time like summer. When I plot, I can see there is a line crossing all the plot in each of them.

fig, ax = plt.subplots(nrows=16, figsize=(60,120))

stations = countData19_gdf['address'].unique()
print(len(stations))
summersubset = countData19_gdf.loc['2019-06-01': '2019-08-31']
cnt=0
for station in stations:
    station_data = summersubset[summersubset['address'] == station]
    ax[cnt].plot( station_data['volume'], c='green',  label= 'flow')
    ax[cnt].title.set_text(station)
    ax[cnt].set_xlabel('Study Date')
    ax[cnt].set_ylabel('volume (V/15 minutes)')
    ax[cnt].set_title(station)
    ax[cnt].grid(True)
    ax[cnt].xaxis.set_major_locator(DayLocator())
    ax[cnt].xaxis.set_major_formatter(DateFormatter('%m/%d'))
    ax[cnt].legend(loc='upper left')

    cnt = cnt +1

enter image description here

2
  • I added a snapshot of the data Commented Jun 7, 2021 at 22:30
  • 1
    Thanks, I sorted the index and it worked. Commented Jun 7, 2021 at 22:32

1 Answer 1

1

As John Hennig suggested in the comments, I just ordered the index before the plot, and it worked.

gdf = gdf.sort_index()
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.