2

Right now I have this code:

for each in list_of_cols: x = vary_k_df_rmse['k_value'] y = vary_k_df_rmse[each] plt.plot(x,y) plt.xlabel('k Value') plt.ylabel('rmse') plt.legend() 

The above code produces the following graph, with multiple lines in a single plot: graph

I need to enlarge the plot above so the legend isn't sitting on the lines.

Adding the following line doesn't work: plt.figure(figsize=(20,10)). This is what most existing answers suggest to do.

for each in list_of_cols: x = vary_k_df_rmse['k_value'] y = vary_k_df_rmse[each] plt.figure(figsize=(20,10)) plt.plot(x,y) plt.xlabel('k Value') plt.ylabel('rmse') plt.legend() 

result

Adding the above line to the for list that generates the graph made it so that the lines appeared in different subplots, rather than all on the same plot.

1 Answer 1

1

You need to move plt.figure(figsize=(20,10)) in front of the for loop so that only 1 figure is created.

plt.figure(figsize=(20,10)) for each in list_of_cols: x = vary_k_df_rmse['k_value'] y = vary_k_df_rmse[each] plt.plot(x,y) plt.xlabel('k Value') plt.ylabel('rmse') plt.legend() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.