Reputation: 3327
I am looping through my dataframe and plotting the top 5 most active user's scores over time. Here is the code I have to plot. It plots successfully but I want to create a subplot (not sure if that is the correct term, perhaps subset plot) that will essentially zoom into 90% to 100%. To clarify it will zoom in on 90 to 100% for the y-axis (which is in this case is score
), which normally ranges from 0 to 1. How can I do this simply using matplotlib without changing much of what I have thus far?
user_id_list = df.groupby('user_id').count( ['post'].sort_values(ascending = False).index[:5]
for uid in user_id_list:
df_sub = df.query(f'user_id=="{uid}"')
df_sub.set_index('date')['score'].plot('-', label=uid)
Code we be appreciated since I am not too familiar! Thank you!
Upvotes: 1
Views: 738
Reputation: 294218
use xlim
user_id_list = df.groupby('user_id').count( ['post'].sort_values(ascending = False).index[:5]
for uid in user_id_list:
df_sub = df.query(f'user_id=="{uid}"')
df_sub.set_index('date')['score'].plot('-', label=uid)
plt.xlim([.9, 1]) # <--- I added this
Upvotes: 2