필터 지우기
필터 지우기

Bar Graph Misaligned on X Axis

조회 수: 3 (최근 30일)
Spencer Ferris
Spencer Ferris 2023년 2월 13일
댓글: Voss 2023년 2월 13일
My first value for my x axis is not lining uyp with my tick mark labels and I can't figure out why, any ideas? Code is below image.
%%% Vector of the averages
VectorOfEachRatioAverage = [Only18125Average Only18750Average Only19375Average Only20000Average Only20625Average Only21250Average Only21875Average];
VectorOfRatioNamesForGraph = [ "1.8125" "1.8750" "1.9375" "2.0000" "2.0625" "2.1250" "2.1875" ];
%%% Create bar graph of Each Speed Ratio means. %%%
% Assign figure to plot over
figure('units','normalized','outerposition',[0 0 1 1]);
xlabel('Speed Ratio of Right Circle/Left Circle');
ylabel('Slider Error ((d/b)*100)');
title("Mean Error for Training and Testing Trials for Participant " + ParticipantNumber)
colormap(gray);
axis padded
hold on;
bar(VectorOfEachRatioAverage)
xticklabels(VectorOfRatioNamesForGraph)

채택된 답변

Voss
Voss 2023년 2월 13일
That's because xticklabels doesn't set the x-ticks, only their labels, so the left-most x-tick - wherever it is - gets the first label you specify, and so on.
To make sure the x-ticks and labels are coherent, set them together:
xticks(1:numel(VectorOfRatioNamesForGraph))
xticklabels(VectorOfRatioNamesForGraph)
  댓글 수: 2
Spencer Ferris
Spencer Ferris 2023년 2월 13일
Had a feeling it was something like that, thanks!
Voss
Voss 2023년 2월 13일
You're welcome!

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by