## 1 Introduction  
The geomagnetic field and stress field are important geophysical fields. Changes in these fields caused by tectonic activities such as earthquakes have long been central issues in geophysical research [1, 2]. Because these fields are associated with two different disciplines, little research on the relationship between the geomagnetic field and the stress field has been published [3, 4]. Most earthquakes are processes of crustal stress release, which causes changes in the stress field on or around the fault, and has a great impact on the seismic activity in the area near the earthquake source [5]. The inversion of the tectonic stress field (TSF) based on the earthquake focal mechanism solution (FMS) is an effective method to study the process and mechanism of earthquake initiation and occurrence [6, 7]. Although the FMS of a single earthquake cannot be used to define the actual direction of the tectonic stress applied underground, the characteristics of the TSF in the region can be inferred through many FMSs in a given area [8, 9, 10]. The lithospheric magnetic field, also known as the crustal magnetic field, is an important part of the geomagnetic field [11; 12]. The spatial structure of lithospheric magnetic anomalies is extremely complex but very stable over time because the sources of the local geomagnetic field (LGF) are stable [13; 14]. However, during strong tectonic activity, the LGF changes rapidly; examples of this include the magnetic field near earthquake buildup areas, volcanoes and faults [15; 16; 17]. Studies have shown that tectonic activities in the crust are related to changes in crustal stress [18; 19]. The magnetic mineral composition of crustal rocks at temperatures below the Curie point shows the characteristics of induced magnetization and residual magnetization [20; 21; 22]. In the area of tectonic movement, these magnetic minerals produce local geomagnetic anomalies due to the piezomagnetic variations caused by stress [23; 24; 25]. How then does tectonic movement cause changes in the crustal stress, which, in turn, lead to variations in local geomagnetic anomalies [26; 27]? The corresponding relationship between the stress and the magnetic changes in rock samples has been established under laboratory conditions [28; 29]. Based on laboratory results, many researchers have provided reasonable explanations for the magnetic anomalies caused by tectonic activity in the crust [18; 30; 31]. However, some researchers have also found that the magnetic anomalies observed during earthquakes are much smaller than expected. The expected magnetic changes are not observed in volcanic areas or near active faults, and even the magnetic changes observed during the storage of a reservoir are much larger than the calculated values based on the experimental conclusions [19; 32]. The reason is that the results of magnetic experiments on rock samples have certain limitations. Due to the limitation of experimental conditions, the experimental environment of rock samples is often quite different from the underground physical environment in an area with geological tectonic movement, and the scale of rock samples is very different from that of a tectonic area [4; 25]. The magnetic anomalies caused by general geological processes are difficult to explain based on conclusions from rock magnetic experiments. There are no reports on the correlation between the TSF and LMF caused by earthquakes. On May 21, 2021, a magnitude 6.4 earthquake occurred in Yangbi County, Yunnan Province, China [33]. To better understand the tectonic stress background and the magnetic anomaly changes resulting from the earthquake, we used the fault sliding direction to reverse the TSF in the epicentral area and then analyzed the changes in the TSF before and after the Yangbi earthquake. At the same time, repeated observations of the geomagnetic field were used to analyze the changes in the LGF before and after the Yangbi earthquake.