How can I delete last Yticklabel?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I don't need my last Yticklabel so how can i delete this? And I need matlab to do labelling automatically.
0 commentaires
Réponses (3)
Adam
le 13 Oct 2016
Modifié(e) : Adam
le 13 Oct 2016
Do you mean just the label or the actual tick too?
If you want Matlab to still auto label them if you allow anything to happen on your plot that can change the axes limits (e.g. zooming, panning, data changing) you will likely have to attach a listener to the YTick property and respond in there.
What to do to remove the tick is trivial.
hAxes.YTickLabel{end} = []
will remove just the tick label.
hAxes.YTick(end) = []
will remove the tick. If you want to remove the tick then just do that and the label will be removed automatically.
Note: The above syntax assumes R2014b or later.
addlistener( hAxes, 'YLim', 'PostSet', @(src,evt) disp( 'Hello' ) )
is an example of adding a listener to an axes property. Just replace that simple function handle with one of your own that does either of the above two statements. You will have to define it in a separate function and create a function handle to it.
0 commentaires
Star Strider
le 13 Oct 2016
One approach:
figure(1)
plot(rand(1,100), rand(1, 100), 'bp') % Create DAta & Plot It
grid
ytix = get(gca, 'YTick'); % Y-Tick Values
ytixlbl = get(gca, 'YTickLabel'); % Y-Tick Labels
set(gca, 'YTick',ytix(1:end-1), 'YTickLabel',ytixlbl(1:end-1)) % Omit Last Y-Tick Label
0 commentaires
KXS
le 4 Juil 2019
figure(1)
plot(rand(1,100),rand(1,100))
hold on
ylim([min max])
set(gca,'YTick',(min:int:max-1)) %note that min,int and max are integers
% also work in X labels
0 commentaires
Voir également
Catégories
En savoir plus sur Axis Labels 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!