Home>

I am trying to visualize the following data frame [df_event] that stores events from Hokkaido to Okinawa (about 1800) with Matplotlib.
I tried to graph and compare the TOP10 of the event area and the TOP10 cost, but I can't write well. .
I will ask you questions in order.
The questions are in bold, so please read through the professors.

【df_event】

Event name Prefecture name Prefectural No. Cost (10,000 yen) Event area (ha) Date
00 festival Hokkaido 0 780 197500 1985
00 party Tokyo 11 428 94300 2007
OO Birthday Festival Osaka Prefecture 26 227 33700 1895
00 event Okinawa 47 356 129300 1830
# Extract TOP10 of event area
df_event_area_sort = df_event ['Event area (ha)']. sort_values ​​(ascending = False)
df_event_area_sort_10 = df_event_area_sort [: 10]
print (df_event_area_sort_10)


When the above code is entered, the following output results.
Is it possible to link the output result row number to any column name (event name)?

591 210000
1323 137800
494 120800
1325 116500
601 108 150
1068 102000
596 98000
1322 95400
1808 77300
595 73000


If i type the following code based on the output result above, the following line graph will be displayed.

plt.plot (df_event_area_sort_10);

How can I make this line chart stretch horizontally?
(I think you can fix it by changing the line number to the event name)
Thanks for your help.

Supplemental information (FW/tool version etc.)

windows
google colaboratory

  • Answer # 1

    dd = df_event.sort_values ​​(['Event area (ha)'], ascending = False) [: 10]
    dd.set_index ('event name') ['event surface area (ha)']. plot (kind = 'barh')

  • Answer # 2

    A method of making a line graph anyway.

    plt.plot (df_gesui_area_sort_10.values)
    plt.show ()


    How to create a line graph with a name.

    df_gesui_area_sort_10 = df_gesui_area_sort_10.set_index ('event_name')
    plt.plot (df_gesui_area_sort_10)
    plt.show ()