Shrub communities play an irreplaceable role in maintaining ecological security in the stressed habitat areas of Northwest China. In these areas, multiple types of shrublands coexist simultaneously. Their diversity levels and community assembly processes may perform different patterns along different stress gradients. This study using linear model fitting, principal component analysis, analyzed the species and phylogenetic diversity of desert, alpine, and secondary shrublands along the gradients of environmental stress factors such as topography, soil, and climate, which reflect low temperature, human disturbance, and drought stress habitats. The changing trend of the phylogenetic structure of different types of shrublands was also studied with using variance decomposition, and phylogenetic structure analysis, which reveals their diversity maintenance mechanisms along environmental stress gradients. The research shows that (1) the mean annual temperature is the main environmental factor shaping the diversity patterns and maintenance processes of shrub communities because low temperatures may lead to habitat filtering; (2) in the western Loess Plateau, the community assembly of different types of shrublands is dominated by deterministic processes, but the diversity and assembly patterns of different shrublands are inconsistent across different environmental stress gradients. Systematic research on the diversity characteristics and assembly patterns of different shrub communities is of great significance for clarifying the restoration, succession, and stability of stressed habitat areas.