I want to convert the linear graph to exponential graph.
There are 2 values generated on x-axis value of SCORE which ranges from [-1,-0.9,-0.8,..0,0.1,0.2,....1]
and y-axis value range from [0,255]
The linear graph generated is
And I want the exponential graph as given in the below image to be generated
I want to scale the y-values in such a way they have an exponential shape and their maximum value is 255
.
You only need to scale the values for the y-axis, but first you need to do some simple math. As you want your largest y-value to be 255, you need to solve:
which results in:
So, you have to scale by this number. Now let's see the code
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-1,1,21)
y = np.linspace(0,255,21)
#scaling here
y = (np.e**(np.log(255)/255))**y
plt.xlabel("Score")
plt.ylabel("Pixel")
plt.plot(x,y)
plt.show()