79252007

Date: 2024-12-04 16:39:41
Score: 1
Natty:
Report link

This is a way to go if you want different colors on different intervals. Three plots with separate x-vectors.

import matplotlib.pyplot as plt
import numpy as np

x1 = np.linspace(-50,-36,50)
x2 = np.linspace(-36, -34 ,10)
x3 = np.linspace(-34, 20, 100)

y1 = []
y2 = []
y3 = []

for xval in x1:
    y1.append(np.log10(((10**xval)/(10**-36))**(1/2)))
for xval in x2:
    y2.append(np.log10(np.exp((10**36)*((10**xval)-(10**-36)))))
for xval in x3:
    y3.append(np.log10((np.exp((10**36)*((10**-34) - (10**-36)))*(((10**xval)/(10**-36))**(1/2)))))
   
plt.plot(x1,y1, color='r')
plt.plot(x2,y2, color='b')
plt.plot(x3,y3, color='g')
plt.xlabel('log x')
plt.ylabel('log y')
plt.show()

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Clas Östman