How to put strings on the x axes
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Seyhan Emre Gorucu
le 31 Mai 2012
Commenté : Nathaniel Werner
le 25 Août 2017
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,
0 commentaires
Réponse acceptée
Oleg Komarov
le 31 Mai 2012
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 commentaires
Nathaniel Werner
le 25 Août 2017
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?
Plus de réponses (1)
Thomas
le 31 Mai 2012
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)))
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!