Mathematica How to Rescale the X-Axis in Mathematica?

  • Thread starter Thread starter olietc
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
To rescale the x-axis in a plot while maintaining the function's integrity, users can employ specific plotting techniques. One effective method is to plot the function with a transformed variable, such as using Plot[f[10x], {x, 0, 3}, AxesLabel -> {x/10, y-label}]. Alternatively, users can adjust the ticks directly with Plot[f[x], {x, 0, 30}, Ticks -> {Table[{i, i/10}, {i, 0, 30, 5}], Automatic}, AxesLabel -> {x/10, y-label}]. This approach allows for a clear representation of the function while displaying the desired x-axis labels, such as T/10. The discussion highlights the preference for the latter method, as it preserves the original function without modification.
olietc
Messages
2
Reaction score
0
Hi guys
I am trying to plot a function with respect to T, but I want to rescale my axis.
For example my range right now shows 0, 10, 20, 30. But I want it to show 0, 1, 2, 3 and so that I can then put an x-axis label of T/10.
Can anyone help?
 
Physics news on Phys.org
Try with:

Plot[function, {x, 0, 3}, AxesLabel -> {T/10, y-label}]
 
Here's a function that has zeros at x=10 and x=20.
Code:
f[x_]:=(x-10)(x-20)
and it's normal plot
Code:
Plot[f[x],{x,0,30},AxesLabel->{x,f}]

Here's two different ways to change the x-axis units to x/10:
Code:
Plot[f[10x],{x,0,3},AxesLabel->{x/10,f}]
Code:
Plot[f[x],{x,0,30},Ticks->{Table[{i,i/10.},{i,0,30,5}],Automatic},AxesLabel->{x/10,f}]
 
Thanks so much!
I like that last option Simon_Tylor, it keeps the function the same. Up until now the only thing I could think of was changing the x inside the function like you did in your first example..
 
Not a problem olietc!
 

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
5
Views
3K
Replies
18
Views
4K
Replies
5
Views
2K
Back
Top