Problems with formatting yticks

조회 수: 37 (최근 30일)
John Stanfield
John Stanfield 2020년 9월 23일
댓글: Ameer Hamza 2020년 9월 23일
I am trying to plot a set of data that has 20 points on the y axis from 0.03 to 0.38, I want to lessen the yticks on the plot for simplicity reasons but everytime i attempt to do this I get the error "Value must be a vector of increasing categorical values as ordered by the ruler Categories property."
Here is the code for the yticks i am trying to use:
yvec = [0, 0.1, 0.2, 0.3];
set(gca, 'YTick', unique(yvec))
Here is what the plot looks like as of now:
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 9월 23일
Did you use hold on to create the plot? Did you use yyaxis or plotyy?

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 9월 23일
편집: Ameer Hamza 2020년 9월 23일
It seems that you have created the plot with categorical variables. Therefore, yticks must also be of categorical type. Change the line to
set(gca, 'YTick', categorical(yvec))
  댓글 수: 2
John Stanfield
John Stanfield 2020년 9월 23일
I still get the same error. Is that not the same line that I have in the code already?
Ameer Hamza
Ameer Hamza 2020년 9월 23일
Sorry! there was a mistake in the code. Try now.

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

추가 답변 (0개)

카테고리

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