0

So here is my python code.

import matplotlib.pyplot as plt

M=[]
for i in np.arange(0.01,8,0.01):
    M.append(test(i))
plt.plot(M)
plt.grid(b=True,which="major",color='#666666', linestyle='-',linewidth=0.2)
plt.show()

Where test(x) is some complicated function. When i try to plot it python for some plots on X-axis from 1 to 800, but i want have scaled it plot from 0.01 to 8. So scaled down without changing graph. Due to complicated form of test(x) function, i would like to use arrays, and this method of ploting.

1 Answer 1

1

Add an index to plot against (essentially your x-axis values):

import matplotlib.pyplot as plt

M=[]
indices = []
for i in np.arange(0.01,8,0.01):
    M.append(test(i))
    indices.append(i)
plt.plot(indices, M)
plt.grid(b=True,which="major",color='#666666', linestyle='-',linewidth=0.2)
plt.show()
Sign up to request clarification or add additional context in comments.

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.