Bar graph with coustomize x axis

조회 수: 3 (최근 30일)
mrituanjay kumar
mrituanjay kumar 2020년 8월 27일
댓글: Ameer Hamza 2020년 9월 27일
I have four vectors
a = [1, 3, 5,7]
b = [2,4,6,8]
c = [5,7,9,6]
d = [8,5,11,12]
I need to plot a bar graph, in which x axis vary from 1 to 12. First element of all vectors need to be plot against 1 on x axias, similarly second element of all vectors need to be plot against 4 on x axias, third element of all vectors need to be plot against 8 on x axias and fourth element of all vectors need to be plot against 12 on x axias.
I do not want to show the intermediate value on x axis, I mean 2, 3, 5, 6, 7, 9, 10, 11.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 8월 27일
Try something like this
a = [1, 3, 5,7];
b = [2,4,6,8];
c = [5,7,9,6];
d = [8,5,11,12];
M = [a; b; c; d].';
f = figure();
ax = axes();
bar(ax, M);
ax.XTickLabel = {'1', '4', '8', '12'};
  댓글 수: 2
mrituanjay kumar
mrituanjay kumar 2020년 9월 27일
Thank you so much for your response. One more thing, I want to make xtick and ytick bold. What else I have to do ?
Ameer Hamza
Ameer Hamza 2020년 9월 27일
I am glad to be of help!
Add the line
ax.FontWeight = "bold";
at the end of the code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by