Remove the bottom x-axis line of a plot
    127 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Hi, 
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
Thanks
0 commentaires
Réponse acceptée
  TTA
 le 26 Mai 2022
        4 commentaires
  DLR
 le 4 Oct 2024
				Removing the box also seems like it removes the right y-axis. Is there any way to avoid this?
  Les Beckham
      
 le 4 Oct 2024
				
      Modifié(e) : Les Beckham
      
 le 4 Oct 2024
  
			If you just want to restore the right side of the box (without ticks or tick labels on the right side), you could do this:
plot(1:10)
set(gca,'XAxisLocation','top', 'box','off')
xline(max(xlim)) % <<< this draws the right side of the "box"
Plus de réponses (1)
  Veronica Taurino
      
 le 26 Mai 2022
        
      Modifié(e) : Veronica Taurino
      
 le 26 Mai 2022
  
      In general, to move your x-asix on top:
set(gca,'XAxisLocation','top')
To hide the axis:
set(gca,'xtick',[])
or 
h = gca;
h.XAxis.Visible = 'off';
2 commentaires
  Veronica Taurino
      
 le 26 Mai 2022
				
      Modifié(e) : Veronica Taurino
      
 le 26 Mai 2022
  
			I gave you more options because your need is not clear to me. You should try one of the above. I think the first one could be fine:
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
set(gca,'XAxisLocation','top')
Voir également
Catégories
				En savoir plus sur Particle & Nuclear Physics 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!





