0

I am writing a code to get a graph:

import pandas as pd
import matplotlib.pyplot as plt
#importing the excel sheet with elements, mass and atomic number
x=pd.read_excel('Elements.xlsx')
#converting atomic number column to a list
Z=x['Z'].tolist()
#converting mass column to another list
A=x['A'].tolist()
#giving the constants some value
a1,a2,a3=14.1,13,0.595
#finding binding energy per nucleon of each element using liquid drop model
bepn=[]
for i in range(0,118):
    y=a1-(a2/(A[i])**(1/3))-(a3*Z[i]*(Z[i]-1)/(A[i])**(4/3))
    bepn.append(y)
#plotting the graph
plt.plot(A,bepn)
plt.xlabel("Atomic mass")
plt.ylabel("Binding energy per nucleon")
plt.show

The obtained graph shows y axis with a range from -50 to 10. But I want the y axis to be from 0 to 9. What should I change in the code to do that?

1
  • It seems to me it's not a problem with matplotlib, it's your methodology for computing the binding energy. I suggest you to close this question and ask a new one, possibly on the physics or chemistry SE. Commented Aug 1, 2020 at 20:24

2 Answers 2

1

You should try this :

plt.ylim(0, 10)
Sign up to request clarification or add additional context in comments.

Comments

0

You can slice y before plotting it on the graph, but you need to do this with x too.

If the y values are all integers, you can do the following:

plt.plot(A[50:],bepn[50:])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.