[Errorbar plot] How to set letters/word on x axis properly?
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Moritz Pohl
il 31 Ago 2017
Commentato: Star Strider
il 31 Ago 2017
Hello folks,
I'm using this code to create an error bar plot
errorbar(1:1:34,[cell{2,:}],[cell{3,:}],'o');
which results in
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166978/image.png)
When I try add specific names to the x axis with
set(gca,'XtickLabel', cell(1,:));
This happens:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166979/image.png)
Where i expect the x axis to fill with all supplied names.
cell(1,:)
has the same format as well as the same size as the other ones. Can someone help me?
0 Commenti
Risposta accettata
Star Strider
il 31 Ago 2017
You didn’t post ‘all the supplied names’ or other details, so writing specific code for your problem is not possible.
Adapt this idea:
Cell{1} = {'k','d','X','b','f'};
figure(1)
plot(1:5, rand(1,5), 'o')
set(gca, 'XTick',1:5, 'XTickLabel',Cell{1})
set(gca, 'XLim',[0 6])
4 Commenti
Star Strider
il 31 Ago 2017
As always, my pleasure.
The default interpreter is 'latex' since you set it that way. Setting it using gca (‘get current axes’) affects only that axes object, so there is no need to reset it for others. The 'latex' interpreter remains the default.
It’s good practice to always specify 'XTick' locations first when you’re specifying 'XTickLabel' to be certain the labels are plotted where you want them. (I also did that in my example code.)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Errorbars in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!