Home > Back-end >  How do I plot the equation for a line with x and y in log such as log y = 0.84*(log x/10^45) 46?
How do I plot the equation for a line with x and y in log such as log y = 0.84*(log x/10^45) 46?

Time:06-18

I've been struggling with plotting the line:

log y = (0.84 /- 0.03)*(log x/ 10^45) (44.06 /- 0.01)

For context, x is the mid-Infrared luminosity and y is the X-ray luminosity for quasars. The problem is that I've tried plotting it normally as one does with say

x = np.linspace(0, 10**50, 100)
y = 0.84*x/10**45   44
plt.plot(x, y, linestyle='-')
plt.xscale('log')
plt.yscale('log')

But this is obviously wrong. I am plotting this line along with points for the data. The data itself is plotted in log space. Right now, I'm going around in circles trying to figure this out. Essentially, I need help in figuring out how to plot log y vs log x for a line.

Thank you!

CodePudding user response:

You can try:

import numpy as np
from matplotlib import pyplot as plt

midir = np.logspace(40, 50, 100)
logxray = 0.84 * np.log10(midir / 1e45)   44

plt.semilogx(midir, logxray, linestyle="-")
plt.show()

Note that this will show the x-axis labels with the notation 10^X and the y-axis just a Y (despite both showing the log-values). If you wanted them to be consistent you could do, e.g.:

logmidir = np.linspace(40, 50, 100)
logxray = 0.84 * (logmidir - 45)   44
plt.plot(logmidir, logxray)
plt.show()
  • Related