Let's say I wish to compare the performance of bubble sort and selection sort and I have the time taken for the code to run for different number of inputs. The graph for each came out as follows.
The Bubble sort:
n=[]
for i in range(13):
n.append(i*1000)
t=[0,1,5,12,21,31,45,61,81,102,125,160,191]
plt.plot(n,t,'s')
plt.plot(n,t)
plt.title('Time Complexity Analysis of Bubble Sort')
plt.xlabel('Number of Inputs')
plt.ylabel('Time Taken')
The Selection Sort:
n=[]
for i in range(13):
n.append(i*1000)
t=[0,1,3,6,11,17,24,33,43,54,66,80,94]
plt.plot(n,t,'s')
plt.plot(n,t)
plt.title('Time Complexity Analysis of Selection Sort')
plt.xlabel('Number of Inputs')
plt.ylabel('Time Taken')
The Graph look pretty similar because the y upper bound for selection sort is 100 while that for Bubble sort is 200. I wish the graph for the selection sort to have the y-upperbound be 200 as well.
I googled and found the following method:
ax.set_ylim(top=200)
But this only works within the data entered extremes. If the data has the highest value less than 200 then it will show until the highest value of the data.
I wish to show the yaxis ticks until the 200 mark.