Accurately analyzing drivers' driving styles is crucial for road safety and enhancing intelligent driving systems. However, existing studies have not fully explored the hidden information in driving sequences or considered the influence of driving environments on driving styles. Based on natural driving data from electric vehicles in Wuhan, a framework for driving style analysis based on driving behavior pattern extraction was proposed. Driving sequences were extracted under free-driving and car-following scenarios, where the convergence of driving features was verified using kernel density estimation and relative entropy. A driving propensity indicator based on a dynamic threshold was constructed, and combined with the Hierarchical Dirichlet Process Hidden Semi-Markov Model (HDP-HSMM) and K-means clustering algorithm, 4 and 5 types of driving behavior pattern were extracted under free-driving and car-following scenarios, respectively. Energy consumption distribution was introduced to verify the validity of driving pattern extraction. Jensen-Shannon (JS) divergence was utilized to calculate the difference in the distribution of the driving propensity indicator among different drivers. By quantifying behavioral differences, drivers were categorized into aggressive, moderate, and conservative types. The results show that the statistical characteristics of driving patterns are consistent with the distribution of energy consumption, with the highest energy consumption occurs in aggressive acceleration and high-speed steady-state patterns, and the highest braking energy recovery occurs in aggressive deceleration pattern. Furthermore, the driving environment influences driving styles to certain degree while exhibiting consistent or diverse driving styles in different driving scenarios and patterns.