I would like to plot a line showing the ranking of each of these roller coasters as a function of the year that they were ranked. For example for the second row (Boulder Dash, I would like a line graph showing the value 1 for 2013-2016, and then 3 and 4 for 2017 and 2018, respectively.
Since the years will be constant for each different coaster, I tried setting the x-axis with: x = range(6) then I would like to plot: plot(x, ranking) for each different roller coaster. What I am confused about is how to get those y values (rating) in a format that could be plotted. Roller Coaster DataFrame
Based on the dataframe from the image, I would use seaborn
line plot that already implements a hue
parameter, but first, reset the Name
index and melt
the dataframe:
import seaborn as sns
df_melted = df.reset_index().melt(id_vars=['Name'])
sns.lineplot(data = df_melted, x='Year of Rank', y ='value', hue='Name')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.