DavidT3 / XGA

X-ray: Generate and Analyse is a module designed to make the analysis of XMM observations simple and efficient. It provides an interface with SAS for the creation of XMM data products, as well as a way to easily perform fits (scalable for multiple observations) and retrieve information about an object, all within a Python package.
BSD 3-Clause "New" or "Revised" License
29 stars 3 forks source link

When plotting third data axis on scalingrelation (i.e. colour of points) with new deps we get an error #1207

Closed DavidT3 closed 2 months ago

DavidT3 commented 2 months ago

ValueError Traceback (most recent call last) Cell In[21], line 2 1 # lx52_tx_r500_metfree.view(y_lims=Quantity([1e+43, 1e+45], 'erg/s')) ----> 2 lx52_tx_r500_metfree.view(save_path=fig_pth+"lx52_tx_r500_metfree.pdf")

File /mnt/ufs18/home-218/turne540/code/XGA/xga/products/relation.py:1148, in ScalingRelation.view(self, x_lims, log_scale, plot_title, figsize, data_colour, model_colour, grid_on, conf_level, custom_x_label, custom_y_label, fontsize, legend_fontsize, x_ticks, x_minor_ticks, y_ticks, y_minor_ticks, save_path, label_points, point_label_colour, point_label_size, point_label_offset, show_third_dim, third_dim_cmap) 1146 # If we did colour the data by a third dimension then we should add a colour-bar to the relation 1147 if show_third_dim: -> 1148 cbar = plt.colorbar(cmap_mapper) 1149 if self.third_dimension_data.unit.is_equivalent(''): 1150 cbar_lab = self.third_dimension_name

File ~/software/anaconda3/envs/xga_dev/lib/python3.12/site-packages/matplotlib/pyplot.py:2341, in colorbar(mappable, cax, ax, kwargs) 2336 if mappable is None: 2337 raise RuntimeError('No mappable was found to use for colorbar ' 2338 'creation. First define a mappable such as ' 2339 'an image (with imshow) or a contour set (' 2340 'with contourf).') -> 2341 ret = gcf().colorbar(mappable, cax=cax, ax=ax, kwargs) 2342 return ret

File ~/software/anaconda3/envs/xga_dev/lib/python3.12/site-packages/matplotlib/figure.py:1285, in FigureBase.colorbar(self, mappable, cax, ax, use_gridspec, *kwargs) 1283 if cax is None: 1284 if ax is None: -> 1285 raise ValueError( 1286 'Unable to determine Axes to steal space for Colorbar. ' 1287 'Either provide the cax argument to use as the Axes for ' 1288 'the Colorbar, provide the ax argument to steal space ' 1289 'from it, or add mappable to an Axes.') 1290 fig = ( # Figure of first axes; logic copied from make_axes. 1291 [ax.flat] if isinstance(ax, np.ndarray) 1292 else [*ax] if np.iterable(ax) 1293 else [ax])[0].figure 1294 current_ax = fig.gca()

ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument to use as the Axes for the Colorbar, provide the ax argument to steal space from it, or add mappable to an Axes.

DavidT3 commented 2 months ago

Should be an easy fix - just a change in the matplotlib api i hadn't noticed - specifying the axis to steal space from should return this to usual function.