IBB-Helper 0.4.8.dev15__tar.gz → 0.4.8.dev17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {ibb_helper-0.4.8.dev15/src/IBB_Helper.egg-info → ibb_helper-0.4.8.dev17}/PKG-INFO +1 -1
  2. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/pyproject.toml +1 -1
  3. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/plot_2d.py +79 -51
  4. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17/src/IBB_Helper.egg-info}/PKG-INFO +1 -1
  5. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/LICENSE +0 -0
  6. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/README.md +0 -0
  7. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/setup.cfg +0 -0
  8. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/setup.py +0 -0
  9. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/__init__.py +0 -0
  10. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/animate.py +0 -0
  11. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/combine_plots.py +0 -0
  12. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/display.py +0 -0
  13. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/display_eigen.py +0 -0
  14. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/display_matrix.py +0 -0
  15. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/extend_plot.py +0 -0
  16. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/minimize.py +0 -0
  17. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/num_int.py +0 -0
  18. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/plot_3d.py +0 -0
  19. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/plot_param_grid.py +0 -0
  20. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper/symbolic_BSpline.py +0 -0
  21. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper.egg-info/SOURCES.txt +0 -0
  22. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper.egg-info/dependency_links.txt +0 -0
  23. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper.egg-info/requires.txt +0 -0
  24. {ibb_helper-0.4.8.dev15 → ibb_helper-0.4.8.dev17}/src/IBB_Helper.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: IBB_Helper
3
- Version: 0.4.8.dev15
3
+ Version: 0.4.8.dev17
4
4
  Summary: Helper functions for symbolic math, matrix visualization, and plotting
5
5
  Author-email: "University of Stuttgart, Institute for Structural Mechanics (IBB)" <mvs@ibb.uni-stuttgart.de>
6
6
  License-Expression: BSD-3-Clause
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "IBB_Helper"
7
- version = "0.4.8.dev15"
7
+ version = "0.4.8.dev17"
8
8
  description = "Helper functions for symbolic math, matrix visualization, and plotting"
9
9
  readme = "README.md"
10
10
  license = "BSD-3-Clause"
@@ -8,7 +8,7 @@ def plot_2d(exprs, var, labels=None, line_styles=None, colors=None,
8
8
  xlim=None, ylim=None, resolution=400, show=True, _break_=None,
9
9
  fontsize=14, title_size=None, label_size=None,
10
10
  tick_size=None, legend_size=None, linewidth=1,
11
- swap_axes=False,scaling=None):
11
+ swap_axes=False, scaling=None):
12
12
 
13
13
  """
14
14
  Plots 2D curves from symbolic expressions or numeric datasets using Matplotlib.
@@ -19,9 +19,9 @@ def plot_2d(exprs, var, labels=None, line_styles=None, colors=None,
19
19
  labels : Labels for each curve (default=None)
20
20
  line_styles : Line styles or markers for each curve (default=None)
21
21
  colors : Colors for each curve (default=None)
22
- title : Plot title (default="2D Plot")
23
- xlabel : X-axis label (default="x")
24
- ylabel : Y-axis label (default="y")
22
+ title : Plot title (default=None)
23
+ xlabel : X-axis label (default=None)
24
+ ylabel : Y-axis label (default=None)
25
25
  xlim : X-axis limits as (min, max) (default=None)
26
26
  ylim : Y-axis limits as (min, max) (default=None)
27
27
  resolution : Number of points used to evaluate symbolic expressions (default=400)
@@ -90,6 +90,10 @@ def plot_2d(exprs, var, labels=None, line_styles=None, colors=None,
90
90
  'o', 's', '^', 'x', '*', 'D', 'p', '+',
91
91
  'v', '<', '>', '1', '2', '3', '4'
92
92
  ]
93
+
94
+ #Initialize lists to collect all plotted data points
95
+ all_plot_x = []
96
+ all_plot_y = []
93
97
 
94
98
  # Plot expressions
95
99
  for i, expr in enumerate(exprs):
@@ -104,6 +108,10 @@ def plot_2d(exprs, var, labels=None, line_styles=None, colors=None,
104
108
  if isinstance(expr, Matrix):
105
109
  expr = np.array(expr).astype(np.float64).flatten()
106
110
 
111
+ # Variable to hold what we actually plot
112
+ final_x_data = None
113
+ final_y_data = None
114
+
107
115
  # Parametric or dataset plot
108
116
  if isinstance(expr, (tuple, list)) and len(expr) == 2:
109
117
  x_data, y_data = expr
@@ -126,24 +134,9 @@ def plot_2d(exprs, var, labels=None, line_styles=None, colors=None,
126
134
  marker = style
127
135
  style = ''
128
136
 
129
- if swap_axes:
130
- ax.plot(
131
- y_data, x_data,
132
- label=label,
133
- linestyle=style,
134
- color=color,
135
- marker=marker,
136
- linewidth=linewidth
137
- )
138
- else:
139
- ax.plot(
140
- x_data, y_data,
141
- label=label,
142
- linestyle=style,
143
- color=color,
144
- marker=marker,
145
- linewidth=linewidth
146
- )
137
+ # Assign to final variables
138
+ final_x_data = x_data
139
+ final_y_data = y_data
147
140
 
148
141
  # Standard y = f(x)
149
142
  else:
@@ -159,45 +152,80 @@ def plot_2d(exprs, var, labels=None, line_styles=None, colors=None,
159
152
  if original_expr in _break_:
160
153
  y_vals = _break_kinks(y_vals)
161
154
 
162
- if swap_axes:
163
- ax.plot(
164
- y_vals, x_vals_sample,
165
- label=label,
166
- linestyle=style,
167
- color=color,
168
- linewidth=linewidth
169
- )
170
- else:
171
- ax.plot(
172
- x_vals_sample, y_vals,
173
- label=label,
174
- linestyle=style,
175
- color=color,
176
- linewidth=linewidth
177
- )
155
+ # Assign to final variables
156
+ final_x_data = x_vals_sample
157
+ final_y_data = y_vals
158
+
159
+ # Re-check style for markers (in case it wasn't caught above)
160
+ if style in marker_symbols:
161
+ marker = style
162
+ style = ''
163
+
164
+ # Execute Plot & Collect Data
165
+ if swap_axes:
166
+ ax.plot(
167
+ final_y_data, final_x_data,
168
+ label=label, linestyle=style, color=color,
169
+ marker=marker, linewidth=linewidth
170
+ )
171
+ #Collect data as it appears on screen (Swapped)
172
+ all_plot_x.append(final_y_data)
173
+ all_plot_y.append(final_x_data)
174
+ else:
175
+ ax.plot(
176
+ final_x_data, final_y_data,
177
+ label=label, linestyle=style, color=color,
178
+ marker=marker, linewidth=linewidth
179
+ )
180
+ #Collect data as it appears on screen (Standard)
181
+ all_plot_x.append(final_x_data)
182
+ all_plot_y.append(final_y_data)
183
+
184
+ #Calculate and apply 10% Padding
185
+ if all_plot_x and all_plot_y:
186
+ # Concatenate all arrays to find global min/max
187
+ # np.atleast_1d ensuresconstant functions don't break concatenation
188
+ flat_x = np.concatenate([np.atleast_1d(a) for a in all_plot_x])
189
+ flat_y = np.concatenate([np.atleast_1d(a) for a in all_plot_y])
190
+
191
+ # Use nanmin/nanmax to ignore gaps from _break_kinks
192
+ min_x, max_x = np.nanmin(flat_x), np.nanmax(flat_x)
193
+ min_y, max_y = np.nanmin(flat_y), np.nanmax(flat_y)
194
+
195
+ # Calculate padding (handle case where max == min)
196
+ pad_x = (max_x - min_x) * 0.1 if max_x != min_x else 0.5
197
+ pad_y = (max_y - min_y) * 0.1 if max_y != min_y else 0.5
198
+
199
+ # Apply padded limits
200
+ # These act as the "Auto" default. They will be overwritten below
201
+ # if the user specifically provided xlim/ylim arguments.
202
+ ax.set_xlim(min_x - pad_x, max_x + pad_x)
203
+ ax.set_ylim(min_y - pad_y, max_y + pad_y)
178
204
 
179
205
  # Styling & Labels
180
- ax.set_title(smart_label(title), fontsize=title_size)
206
+ if title is not None:
207
+ ax.set_title(smart_label(title), fontsize=title_size)
181
208
 
182
209
  if swap_axes:
183
- ax.set_xlabel(smart_label(ylabel), fontsize=label_size)
184
- ax.set_ylabel(smart_label(xlabel), fontsize=label_size)
210
+ if ylabel is not None:
211
+ ax.set_xlabel(smart_label(ylabel), fontsize=label_size)
212
+ if xlabel is not None:
213
+ ax.set_ylabel(smart_label(xlabel), fontsize=label_size)
185
214
  else:
186
- ax.set_xlabel(smart_label(xlabel), fontsize=label_size)
187
- ax.set_ylabel(smart_label(ylabel), fontsize=label_size)
215
+ if xlabel is not None:
216
+ ax.set_xlabel(smart_label(xlabel), fontsize=label_size)
217
+ if ylabel is not None:
218
+ ax.set_ylabel(smart_label(ylabel), fontsize=label_size)
188
219
 
189
220
  ax.tick_params(axis='both', labelsize=tick_size)
190
221
 
222
+ # Manual Limits Override (Manual > Auto Padding)
191
223
  if swap_axes:
192
- if ylim:
193
- ax.set_xlim(ylim)
194
- if xlim:
195
- ax.set_ylim(xlim)
224
+ if ylim: ax.set_xlim(ylim)
225
+ if xlim: ax.set_ylim(xlim)
196
226
  else:
197
- if xlim:
198
- ax.set_xlim(xlim)
199
- if ylim:
200
- ax.set_ylim(ylim)
227
+ if xlim: ax.set_xlim(xlim)
228
+ if ylim: ax.set_ylim(ylim)
201
229
 
202
230
  if scaling == 'constrained':
203
231
  ax.set_aspect('equal', adjustable='box')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: IBB_Helper
3
- Version: 0.4.8.dev15
3
+ Version: 0.4.8.dev17
4
4
  Summary: Helper functions for symbolic math, matrix visualization, and plotting
5
5
  Author-email: "University of Stuttgart, Institute for Structural Mechanics (IBB)" <mvs@ibb.uni-stuttgart.de>
6
6
  License-Expression: BSD-3-Clause