0

I wanted to create graphs for some math functions and tried to do this using matplotlib.I need to plot graphs of several functions in one plot sothat these can be compared against each other.

say these are the math functions

2**(math.log(x,2))
2**(2**(math.log(x,2)))

I tried this

from matplotlib.pyplot import plot as plt
x=arange(1000,1010)
y1=[2**(math.log(t,2)) for t in x ]
y2=[2**(2**(math.log(t,2))) for t in x ]
plt.plot(x,y1)
plt.plot(x,y2)
plt.show()

this only shows one graph..that of (x,y2)

how do I make all the graphs show in one plot?

edit:

using plt.plot(x,y1,x,y2) produces this graph enter image description here

1 Answer 1

2

I don't think they are going to be visible on the same scale. The first one is essentially y = x, y is about 1000. The second one is y = 2**x, and x starts at 1000...

However, plotting with log scale can help:

matplotlib.pyplot.yscale('log')
Sign up to request clarification or add additional context in comments.

2 Comments

that could be the problem..I thought the plot would scale
It is scaled so that both plots fit into the window. In such as scale the first plot is a line lying just .0001 mm above the X-axis. Maybe you will see it if you make the line thicker, but for a real comparison linear scale is of no use in this case.

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.