bar and histograms for categorical data
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    F.O
 el 28 de Sept. de 2017
  
    
    
    
    
    Respondida: Ramnarayan Krishnamurthy
    
 el 4 de Oct. de 2017
            I have this vector and std =[ 0.4041 0.7670 1.0682 0.6582 0.0475] and these lyer=categoris [{'crust','upper mantle','lower mantle','outer core','inner core'} and each of them correspound to the array values and want to make a histogram of this . i used bar(lyers,std) but the order of categores is not as required. is there a way to fix this or i should use diffrent commands.
0 comentarios
Respuesta aceptada
  Ramnarayan Krishnamurthy
    
 el 4 de Oct. de 2017
        MATLAB by default places categories in alphabetical order. One of the possible approaches to switching the order of the bars is as follows (tested in R2017a):
   % Setup data
    std =[ 0.4041 0.7670 1.0682 0.6582 0.0475]
    lyer = categorical({'crust' 'upper mantle' 'lower mantle' 'outer core' 'inner core'})
    figure
    bar(lyer,std)
   % Reorder the categories in the order you want using reordercats
    reorder_lyer = reordercats(lyer,{'crust','lower mantle' ,'upper mantle' ,'inner core' ,'outer core'});
    figure
    bar(reorder_lyer,std)
Another approach may involve switching the XData, YData or XDataMode.
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!