Displaying an axis scale in mm rather than pixels
Show older comments
I have written a code for image analysis that uses the number of pixels throughout to calculate lengths. Now I want to plot graphs and have my axis reading in millimetres rather than number of pixels. I have a calibration factor calculated, is there a simple way I can have axis in millimetres. I need this code to work for multiple pictures therefore using the xticks and xticklabels method would help.
Accepted Answer
More Answers (2)
elvis okacha
on 10 Apr 2019
0 votes
Look I'm trying to implement your solution within a button program in my guitar,but I still get error that 'undefined variable 'xticks''.allitle new to Matias.is there some additional code on the use of stick and xticklabels?kindly
9 Comments
Walter Roberson
on 10 Apr 2019
Which MATLAB release are you using? xticks() is R2016b and later. Before that you had to set the XTicks property of the axes.
elvis okacha
on 10 Apr 2019
R2015a.what do I add to looky's code to achieve the conversion?
Walter Roberson
on 10 Apr 2019
xticks = get(gca, 'XTicks');
yticks = get(gca, 'YTicks');
before the code you posted earlier.
elvis okacha
on 10 Apr 2019
Thanks.though I'm getting an error that 'there is no XTicks property on the Axes class'.ive attached a picture
Walter Roberson
on 10 Apr 2019
xticks = get(gca, 'XTick');
yticks = get(gca, 'YTick');
elvis okacha
on 10 Apr 2019
Yes I tried that already.but error then occurs on the label saying 'undefined function or variable 'xticklabels'.when I replace with 'xticklabel',I get same error
elvis okacha
on 12 Apr 2019
Any help?
Walter Roberson
on 12 Apr 2019
set() the axes XTickLabels and YTickLabels properties instead of calling xticklabels() and yticklabels()
elvis okacha
on 13 Apr 2019
Ok thanks
elvis okacha
on 10 Apr 2019
0 votes
Sorry.'looky' not 'look'
Categories
Find more on Axis Labels 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!