Set custom x and y axis

63 views (last 30 days)
Rahul Thakur
Rahul Thakur on 7 Oct 2017
Commented: Kian Azami on 7 Oct 2017
Hi All,
I have a quick and I believe it would be fairly easy as well but being a newbie I am not able to crack it.
I have one image having x and y axis values as of 0-640 and 0-1024 respectively. Now, I can plot these same numbers easily but is there a way where I can put custom values on both axis as I would like to put 0-1 in y and 0-2 in y axis?
I have tried basic commands such as axis([xmin xmax ymin ymax]) but it also changes the orientation and the image I have completely.
Question: How to plot custom axis value in both axis while keeping the image same?
I have also attached the image I am working on. Please help, thanks.

Answers (1)

Kian Azami
Kian Azami on 7 Oct 2017
Edited: Kian Azami on 7 Oct 2017
Maybe you just need to use:
xlim([xmin xmax])
ylim([ymin ymax])
  2 Comments
Rahul Thakur
Rahul Thakur on 7 Oct 2017
Hi Kian,
Sorry, no it didn't work. As I mentioned in my initial question when I tried this code it changes the orientation of my image and the image as well.
I will probably need something else, I guess.
Kian Azami
Kian Azami on 7 Oct 2017
It is strange that it changes the orientation. Maybe put your image and code here which is easier to check for everyone.
If you want to change the axis values by yourself you need to access to the properties of the axis. So you can do this by going to plot tools and then clicking on the white areas in your figure (I mean to choose the axis) and then go to 'Ticks...' properties and change them.
Or you can do it by writing code:
Figure_Axis = get(gcf,'children');
set(Figure_Axis,'YTickLabelMode','manual')
Y_Label_Positions = get(Figure_Axis,'YTick')
Y_Label = get(Figure_Axis,'YTickLabel')
you need to change Y_Label to show the values that you want. If you want to change their position you need to change the values of Y_Label_Positions also. But before that, you need to make it manual:
set(Figure_Axis,'YTickMode','manual')
You can use the same for the other axis.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!