How can I change the x and y-axis limits in Matlab to arbitrary scales?

  • MATLAB
  • Thread starter Kidphysics
  • Start date
  • Tags
    Axis Matlab
In summary, The conversation is about scaling an image and changing the x-axis and y-axis ranges for the image. The person is having trouble setting the new ranges and asks for help. They also mention using the 'axis' function and the 'imresize' function, but these do not solve the issue.
  • #1
Kidphysics
164
0
Hello, I have an image which gets displayed and has the x and y-axis ranging from 0-812 and 0-607 respectively. This is because these are the pixel sizes for my image. I would like to change the x-axis to show -3.85, 3.85 and for the y-axis to show -2.9,2.9. However, when I load my image into the figure and go into the property editor Matlab believes I am typing in the range of pixels still. I would just like to scale my image with these arbitrary scales. Please help!
 
Physics news on Phys.org
  • #2
axis([XMIN XMAX YMIN YMAX]) sets scaling for the x- and y-axes on the current plot.

Type 'help axis' or 'doc axis' for more info.
 
  • #3
kreil said:
axis([XMIN XMAX YMIN YMAX]) sets scaling for the x- and y-axes on the current plot.

Type 'help axis' or 'doc axis' for more info.

this gave me the same problem. it did not scale the image it simple moved the image window to this location.
 
  • #4
B = imresize(A, scale) returns image B that is scale times the size of A.
 
  • #5


Hi there,

To change the x and y-axis limits in Matlab, you can use the "xlim" and "ylim" functions. For example, to change the x-axis limits to -3.85 and 3.85, you can use the following code:

xlim([-3.85 3.85])

Similarly, for the y-axis limits, you can use the following code:

ylim([-2.9 2.9])

This will scale your image to the desired limits. Additionally, you can also use the "xticks" and "yticks" functions to specify the tick marks on the axis. For example, to have tick marks at -3.85, 0, and 3.85 on the x-axis, you can use the following code:

xticks([-3.85 0 3.85])

I hope this helps! Let me know if you have any further questions.
 

1. How can I change the scale of the x and y axis in Matlab?

To change the scale of the x and y axis in Matlab, you can use the xlim and ylim functions. These functions allow you to specify the minimum and maximum values for the x and y axis, respectively.

2. Can I set the x and y axis to a logarithmic scale in Matlab?

Yes, you can set the x and y axis to a logarithmic scale in Matlab by using the loglog function. This function plots the x and y data on a log-log scale, which is useful for visualizing data that spans several orders of magnitude.

3. How do I label the x and y axis in a Matlab plot?

To label the x and y axis in a Matlab plot, you can use the xlabel and ylabel functions. These functions allow you to specify the label for the x and y axis, respectively.

4. Is it possible to change the font size of the x and y axis labels in Matlab?

Yes, you can change the font size of the x and y axis labels in Matlab by using the set(gca,'FontSize',size) function. This allows you to specify the font size, size, for the current axis, gca.

5. How can I customize the appearance of the x and y axis in Matlab?

You can customize the appearance of the x and y axis in Matlab by using the set(gca,'PropertyName',PropertyValue) function. This function allows you to specify various properties, such as line color, line width, and tick marks, for the current axis, gca.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
995
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top