-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3de7c15
commit a7fc898
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
Python Implementation/src/Plot_StringStableRegion_MonitoringOneHDV.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from scipy.io import loadmat | ||
from matplotlib.colors import ListedColormap | ||
|
||
# Key Parameters | ||
id = -2 # -2, -1, 1, 2 | ||
|
||
# Parameters | ||
n = 2 | ||
m = 2 | ||
DriverDynamics = 1 | ||
|
||
# Load data (adjust as per your data file's structure and path) | ||
# Replace this part with the appropriate loading mechanism for your .mat files | ||
mat_data_ps = loadmat(f'_data/18-Mar-2020_PSRegion_n_{n}_m_{m}_DriverDynamics_{DriverDynamics}_FeedbackID_{id}.mat') | ||
PS_bool = mat_data_ps['PS_bool'] | ||
K, Mu = mat_data_ps['K'].flatten(), mat_data_ps['Mu'].flatten() | ||
|
||
SSPS_bool = np.zeros_like(PS_bool) | ||
Mu_3d, K_3d = np.meshgrid(K, Mu) | ||
|
||
a = np.where(PS_bool == 0) | ||
PS_Y = Mu_3d[a] | ||
PS_X = K_3d[a] | ||
PS_Z = np.full(len(a[0]), 2) | ||
|
||
mat_data_ss = loadmat(f'_data/30-Mar-2020_SSRegion_n_{n}_m_{m}_DriverDynamics_{DriverDynamics}_FeedbackID_{id}.mat') | ||
SS_bool = mat_data_ss['SS_bool'] | ||
K, Mu = mat_data_ss['K'].flatten(), mat_data_ss['Mu'].flatten() | ||
Mu_3d, K_3d = np.meshgrid(K, Mu) | ||
|
||
|
||
|
||
|
||
|
||
# Plotting | ||
fig = plt.figure() | ||
ax = fig.add_subplot(111, projection='3d') | ||
#plt.figure(figsize=(10, 6)) | ||
# Colormap | ||
mymap = ListedColormap([(235/255, 235/255, 235/255), (113/255, 178/255, 246/255)]) | ||
|
||
# Surface Plot | ||
p = ax.plot_surface(K_3d, Mu_3d, SS_bool, cmap=mymap, edgecolor='none') | ||
#plt.pcolormesh(K_3d, Mu_3d, SS_bool, cmap=mymap, shading='auto') | ||
|
||
# View | ||
ax.view_init(elev=90, azim=-90) # Rotate the plot for a top-down view | ||
ax.set_zticks([]) | ||
# Formatting | ||
Wsize = 18 | ||
ax.tick_params(labelsize=Wsize - 2, which='both', axis='both', labelcolor='black') | ||
ax.set_xlim([np.min(K), np.max(K)]) | ||
ax.set_ylim([np.min(Mu), np.max(Mu)]) | ||
# Hiding the Z-axis | ||
|
||
# Labels based on id | ||
labels = { | ||
-2: ('$k_{-2}$', '$\mu_{-2}$'), | ||
-1: ('$k_{-1}$', '$\mu_{-1}$'), | ||
1: ('$k_1$', '$\mu_1$'), | ||
2: ('$k_2$', '$\mu_2$') | ||
} | ||
ax.set_xlabel(labels[id][0], fontsize=Wsize, labelpad=15) | ||
ax.set_xticks([-10, 0, 10]) | ||
ax.set_ylabel(labels[id][1], fontsize=Wsize, labelpad=15) | ||
|
||
# Scatter plots | ||
s = ax.scatter(PS_X, PS_Y, PS_Z, color='black', alpha=0.05, s=2 ) | ||
|
||
if id > 0: | ||
b = ax.scatter(-1, -1, 2, color='black', marker='x', s=50) | ||
ax.text(-8, -1, 2, '(-1, -1)', fontsize=Wsize-2) | ||
|
||
|
||
plt.show() | ||
|
||
# For saving the figure, uncomment the below line | ||
# fig.savefig(f'Fig3_Driver_{DriverDynamics}_id_{id}.eps', format='eps', dpi=300) |