How to replace x or y axis tick values with texts
    50 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Nayeem Iftekher
 le 4 Mar 2021
  
    
    
    
    
    Commenté : Nayeem Iftekher
 le 4 Mar 2021
            I want to replace my yaxis tick values with texts.
x=[1,3,4,6]; y=[20,40,50,80]; Plot(x,y);
For this, I want to replace the ytick values with white, red, green, yellow instead of 20,40,50,80 respectively.
0 commentaires
Réponse acceptée
  Walter Roberson
      
      
 le 4 Mar 2021
        
      Modifié(e) : Walter Roberson
      
      
 le 4 Mar 2021
  
      x=[1,3,4,6]; y=[20,40,50,80]; plot(x,y);
yticks([20,40,60,80])
yticklabels({'white', '\color{red}red', '\color{green}green', 'yellow'}); set(gca,'TickLabelInterpreter', 'tex')
ycat = categorical(y, [20 40 50 80], {'white', 'red', 'green', 'yellow'})
plot(x, ycat)
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

