(self, x, y, log_x, log_y, color_column=None, color_ramp=None, data_points=True)
| 3200 | |
| 3201 | |
| 3202 | def plot_custom(self, x, y, log_x, log_y, color_column=None, color_ramp=None, data_points=True): |
| 3203 | # Clear the current contents of the figure |
| 3204 | self.figure.clear() |
| 3205 | |
| 3206 | # Create an axis |
| 3207 | ax = self.figure.add_subplot(111) |
| 3208 | x_limits, y_limits = self.extract_plot_limits_from_json() |
| 3209 | ax.set_xlim(x_limits) |
| 3210 | ax.set_ylim(y_limits) |
| 3211 | |
| 3212 | # Plot the data |
| 3213 | if x and y and data_points: |
| 3214 | if color_column: |
| 3215 | if pd.api.types.is_numeric_dtype(self.data[color_column]): |
| 3216 | sc = ax.scatter(self.data[x], self.data[y], c=self.data[color_column], cmap=plt.get_cmap(color_ramp)) |
| 3217 | cbar = plt.colorbar(sc) |
| 3218 | cbar.set_label(color_column) |
| 3219 | else: |
| 3220 | categories = self.data[color_column].unique() |
| 3221 | for category in categories: |
| 3222 | data_category = self.data[self.data[color_column] == category] |
| 3223 | ax.scatter(data_category[x], data_category[y], label=category, cmap=plt.get_cmap(color_ramp)) |
| 3224 | ax.legend() |
| 3225 | else: |
| 3226 | ax.scatter(self.data[x], self.data[y]) |
| 3227 | |
| 3228 | # Use the plot information from the JSON file |
| 3229 | ax.set_title(self.plot_info.get('title', '')) |
| 3230 | ax.set_xlabel(self.plot_info.get('x_label', '')) |
| 3231 | ax.set_ylabel(self.plot_info.get('y_label', '')) |
| 3232 | |
| 3233 | |
| 3234 | # Set the x scale |
| 3235 | if log_x: |
| 3236 | ax.set_xscale('log') |
| 3237 | |
| 3238 | # Set the y scale |
| 3239 | if log_y: |
| 3240 | ax.set_yscale('log') |
| 3241 | |
| 3242 | # Add the labels |
| 3243 | labels = self.plot_info.get('labels', {}) |
| 3244 | for label, (x_pos, y_pos) in labels.items(): |
| 3245 | ax.text(x_pos, y_pos, label, ha='center', va='center', fontsize=8) |
| 3246 | |
| 3247 | # Plot the line segments |
| 3248 | for line_segment in self.plot_info.get('lines', []): |
| 3249 | print(line_segment) |
| 3250 | ax.plot(*zip(*line_segment), color='black') |
| 3251 | |
| 3252 | # Extract polygons |
| 3253 | polygons = self.plot_info.get('polygons', []) |
| 3254 | |
| 3255 | # Plot each polygon |
| 3256 | for polygon in polygons: |
| 3257 | points = polygon['points'] |
| 3258 | style = polygon['style'] |
| 3259 |
no test coverage detected