Ask Your Question
1

Strange scale on x-axis for large value

asked 0 years ago

Emm gravatar image

Hello, When I try to plot the a function for large values of the variable, say:

plot(x, (x,2, 10^6))

both the x-axis and y-axis scale go from 0 to 1 instead of 0 to 10^6

How can I prevent this behavior?

Preview: (hide)

Comments

Long standing issue (but no easy way to find in tn Github issues...).

Possible workaround : scale your axes manually and display the scale factor somewhere in your plot (axis labels ?)

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 0 years ago )

Thank you!

I am reassured to know that this is not a mistake on my part.

Emm gravatar imageEmm ( 0 years ago )
1
1

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

Emm gravatar image

updated 0 years ago

Taking into account Emmanuel Charpentier’s comment, I propose the following solution, which consists of specifying the data on the axes manually:

plot(x,2,10^6,ticks=[[2,10^6/2,10^6],[2,10^6/2,10^6]], tick_formatter=[[2,10^6/2,10^6],[2,10^6/2,10^6]])

or

def Plot(f,min,max,n):
    labX = [ min + k*(max-min)/n for k in range(n+1)]
    labY = [ f(min + k*(max-min)/n) for k in range(n+1)]
    P=plot(f,min,max,ticks=[labX,labY], tick_formatter=[labX,labY])
    P.show()
Plot(lambda x : x,0,10^6,5)
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 0 years ago

Seen: 73 times

Last updated: Feb 12