title: How can i set the y axis limit in matplotlib
body: <p>I am comparing the training accuracies of two different neural networks. How can I set the scales so that they are comparable. (like setting both y axis to 1 for both so that the graphs are comparable)</p>
  <p>The code I used is below:</p>
  <pre><code> def NeuralNetwork(X_train, Y_train, X_val, Y_val, epochs, nodes, lr):
          hidden_layers = len(nodes) - 1
          weights = InitializeWeights(nodes)
          Training_accuracy=[]
          Validation_accuracy=[]
          for epoch in range(1, epochs+1):
              weights  = Train(X_train, Y_train, lr, weights)
      
              if (epoch % 1 == 0):
                  print(&quot;Epoch {}&quot;.format(epoch))
                  print(&quot;Training Accuracy:{}&quot;.format(Accuracy(X_train, Y_train, weights)))
                  
                  if X_val.any():
                      print(&quot;Validation Accuracy:{}&quot;.format(Accuracy(X_val, Y_val, weights)))
                  Training_accuracy.append(Accuracy(X_train, Y_train, weights))
                  Validation_accuracy.append(Accuracy(X_val, Y_val, weights))
          plt.plot(Training_accuracy) 
          plt.plot((Validation_accuracy),'#008000') 
          plt.legend([&quot;Training_accuracy&quot;, &quot;Validation_accuracy&quot;])    
          plt.xlabel(&quot;Epoch&quot;)
          plt.ylabel(&quot;Accuracy&quot;)  
          return weights , Training_accuracy , Validation_accuracy
  </code></pre>
  <p>and the two graphs are as below :</p>
  <p><a href="https://i.stack.imgur.com/FPNVl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPNVl.png" alt="enter image description here" /></a></p>