Changing x-axis in Mathematica

  • Mathematica
  • Thread starter olietc
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses how to rescale the x-axis when plotting a function with respect to T. Various options are suggested, including using a different function, changing the x-axis label, and adjusting the ticks. The last option is preferred as it keeps the function the same.
  • #1
olietc
2
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
  • #2
Try with:

Plot[function, {x, 0, 3}, AxesLabel -> {T/10, y-label}]
 
  • #3
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}]
 
  • #4
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..
 
  • #5
Not a problem olietc!
 

Related to Changing x-axis in Mathematica

1. How do I change the range of values shown on the x-axis in Mathematica?

To change the range of values on the x-axis, you can use the "PlotRange" option in the Plot function. Simply specify the minimum and maximum values you want to display, for example: Plot[x^2, {x, 0, 10}, PlotRange->{0, 100}] will plot the function x^2 from 0 to 10 on the x-axis with a range of 0 to 100.

2. Can I change the scaling of the x-axis in Mathematica?

Yes, you can use the "ScalingFunctions" option in the Plot function to change the scaling of the x-axis. For example, Plot[x^2, {x, 0, 10}, ScalingFunctions->"Log"] will plot the function x^2 on a logarithmic scale for the x-axis.

3. How do I add labels to the x-axis in Mathematica?

To add labels to the x-axis, you can use the "AxesLabel" option in the Plot function. Specify the label as a string, for example: Plot[x^2, {x, 0, 10}, AxesLabel->"x-axis"] will add the label "x-axis" to the x-axis.

4. Can I change the tick marks on the x-axis in Mathematica?

Yes, you can use the "Ticks" option in the Plot function to specify the tick marks you want to display. For example, Plot[x^2, {x, 0, 10}, Ticks->{Range[0, 10, 2]}] will plot the function x^2 with tick marks at intervals of 2 on the x-axis.

5. Is it possible to change the appearance of the x-axis in Mathematica?

Yes, you can use the "Frame" option in the Plot function to change the appearance of the x-axis. For example, Plot[x^2, {x, 0, 10}, Frame->True] will display the x-axis with a frame around it. You can also use other options such as "FrameStyle" and "FrameTicks" to further customize the appearance of the x-axis.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
124
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
331
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
290
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
93
Back
Top