How to put strings on the x axes

조회 수: 3 (최근 30일)
Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012년 5월 31일
댓글: Nathaniel Werner 2017년 8월 25일
Hello,
I want to plot types of methods vs their corresponding numbers. That is, X axes will be string and Y axes will be numbers. Currently, my matrix is cell as below:
neworder =
'N2' [0.1700]
'HC' [0.1700]
'SAGD' [0.1800]
'Steamflood' [0.4500]
'CSS' [0.4500]
'hot Water' [0.4500]
'CO2' [0.5100]
'Polymer' [0.6300]
'ASP' [0.6300]
'Combustion' [0.6500]
I tried to plot string vs. numbers. It didn't work out. Basically, my X axes is the first column and Y axes is the second column.
Thank you,

채택된 답변

Oleg Komarov
Oleg Komarov 2012년 5월 31일
neworder = {
'N2' [0.1700]
'HC' [0.1700]
'SAGD' [0.1800]
'Steamflood' [0.4500]
'CSS' [0.4500]
'hot Water' [0.4500]
'CO2' [0.5100]
'Polymer' [0.6300]
'ASP' [0.6300]
'Combustion' [0.6500]}
bar([neworder{:,2}])
set(gca,'XtickL',neworder(:,1))
  댓글 수: 2
Matt
Matt 2017년 1월 9일
With Matlab R2016a I need to use 'XtickLabel'
Nathaniel Werner
Nathaniel Werner 2017년 8월 25일
I have a similar problem.
I am trying to do this in my code
data_strings = {...
'-[(u^\prime\cdot\nabla)\omega_r^\prime]^*' [-2.5 -1.6 -1. -2.1 -1.25 -0.85]...
'[(\omega^\prime\cdot\nabla)u_r^\prime]_\perp^*' [0.15 0.05 0.01 2.2 1.04 0.5]...
'[(\omega^\prime\cdot\nabla)u_r^\prime]_{||}^*' [0.3 0.25 0.1 -1.3 -0.65 -0.62]...
'[-(2\Omega\cdot\nabla)u_r^\prime]^*' [0.87 0.7 0.77 1 0.81 0.79]
'[\nu\nabla^2\omega_r^\prime]^*' [0.6 0.42 0.3 0.12 0.17 0.05]};
But I keep getting the following error.
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Is there a way I can make this work?

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

추가 답변 (1개)

Thomas
Thomas 2012년 5월 31일
figure1 = figure;
axes1 = axes('Parent',figure1,'XTickLabel',neworder(:,1));
box(axes1,'on');
hold(axes1,'all');
% Create plot
plot(cell2mat(neworder(:,2)));
or
bar(cell2mat(neworder(:,2)))

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by