relabel x axis tick marks

조회 수: 3 (최근 30일)
Rhys
Rhys 2011년 8월 2일
Hi,
Sorry for what seems an easy question, but I have been searching and have not found the answer.
I want to relabel the data points on the x-axis. Currently the x-axis is axis([0.27 0.9 0 1]) and I want the values shown to range from 30 to 85 rather than 0.27 to 0.9. So where the graph currently had label 0.27 on the x axis, replace that with 30 and so on upto replacing 0.9 with 85.
axis([30 85 0 1]) obviously puts the axis out of range of the data. Hope that makes sense, thanks in advance,
Rhys

채택된 답변

Walter Roberson
Walter Roberson 2011년 8월 2일
set() the XTickLabel to whatever cell array of strings that you want.
It would be easier if there was a nice formula for determining the bounds. For example, .27 * (1000 / 9) gives 30, but .9 * (1000/9) gives 100 rather than the desired 85. There is a linear formula given those two bounds, but it is 87.3015873015873 * x + 6.42857142857143 which seems too ugly to be plausible.
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 8월 2일
You want a tick range of 55 (30 to 85) over an axis range of 0.63 . Are you sure these are the correspondences you want?
Rhys
Rhys 2011년 8월 2일
Re: question about values, it may seem odd, it is a pc monitor luminance reading (in candelas - 30 to 85 candelas, given a display brightness value in the programme of between 0.326 and 0.9 as below). Ive fitted response values to different luminance values in the range 0.27 and 0.9 and am populating the x axis between these with candela's which is hopefully something more meaningful.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Rhys
Rhys 2011년 8월 2일
Thanks Walter and Fangjun, used both in the end
plot(StimLevels, ProportionCorrectOnset, 'k.', 'markersize',30,'HandleVisibility','off');
axis([0.27 0.9 0 1]);
set(gca,'XTick', [0.326 0.379 0.431 0.483 0.535 0.587 0.639 0.691 0.743 0.796 0.848 0.9])
set(gca,'XTickLabel', [ 30 35 40 45 50 55 60 65 70 75 80 85])
set(gca,'fontsize',12);

Fangjun Jiang
Fangjun Jiang 2011년 8월 2일
set the 'XTickLabel' property of the axes.
h=axes;
get(h,'XTickLabel') % shows 0 to 1
set(h,'XTickLabel',num2str((1:11)')) %shows 1 to 11
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 8월 2일
You indicate to set the XTick property but show setting the XTickLabel property.
Fangjun Jiang
Fangjun Jiang 2011년 8월 2일
Thanks! Updated.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by