0

I am trying to make a graph with this:

import matplotlib.pyplot as plt
from numpy import *
from scipy.interpolate import *


x= array([13, 15,18,20,25,30])
y= array([2.29E+60, 3.87E+60, 7.12E+60, 1.07E+61, 1.90E+61, 3.34E+61])


y2= 7.0867E+56 * x**3.177

plt.xlabel('M/Msun')
plt.ylabel('Average Rate of Nucleosynthesis')


plt.xscale('log')
plt.yscale('log')

plt.yticks((min(y),max(y), 1))

plt.plot(x,y, 'o', color='black')
plt.plot((x),y2,'black')

plt.show()

And then I get this type of graph:

example graph

The tickmarks on the y-axis do not show up. Any idea of how to fix this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Travis
  • 3
  • 1

1 Answers1

0

You can do something like this:

import matplotlib.pyplot as plt

from numpy import *
from scipy.interpolate import *


x= array([13, 15,18,20,25,30])
y= array([2.29E+60, 3.87E+60, 7.12E+60, 1.07E+61, 1.90E+61, 3.34E+61])


y2= 7.0867E+56 * x**3.177

fig, ax = plt.subplots()

plt.xlabel('M/Msun')
plt.ylabel('Average Rate of Nucleosynthesis')

ax.plot(x,y, 'o', color='black')
ax.plot((x),y2,'black')

ax.set_xscale('log')
ax.set_yscale('log')


ax.set_yticks([1.00E+60, 1.00E+61, 1.00E+62])

plt.show()

graph1

or

import matplotlib
import matplotlib.pyplot as plt
from numpy import *
from scipy.interpolate import *


x= array([13, 15,18,20,25,30])
y= array([2.29E+60, 3.87E+60, 7.12E+60, 1.07E+61, 1.90E+61, 3.34E+61])


y2= 7.0867E+56 * x**3.177

fig, ax = plt.subplots()

plt.xlabel('M/Msun')
plt.ylabel('Average Rate of Nucleosynthesis')

ax.plot(x,y, 'o', color='black')
ax.plot((x),y2,'black')

ax.set_xscale('log')
ax.set_yscale('log')


ax.set_yticks([1.00E+60, 5.00E+60, 1.00E+61, 5.00E+61])
ax.get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())

plt.show()

to give you something like this:

graph2

You might want to read through this stack overflow answer for more/better information.

Eric Zhou
  • 81
  • 1
  • 5