Ask Your Question
1

Strange scale on x-axis for large value

asked 2025-02-11 23:39:49 +0100

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?

edit retag flag offensive close merge delete

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 ( 2025-02-12 13:44:12 +0100 )edit

Thank you!

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

Emm gravatar imageEmm ( 2025-02-12 17:02:25 +0100 )edit
1
1

1 Answer

Sort by » oldest newest most voted
1

answered 2025-02-12 17:02:38 +0100

Emm gravatar image

updated 2025-02-12 17:19:02 +0100

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)
edit flag offensive delete link more

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: 2025-02-11 23:39:49 +0100

Seen: 72 times

Last updated: Feb 12