Skip to content

mda.plot_selected_centroids() fails when plotting only two variables #75

@fernanqv

Description

@fernanqv

If the input dataset provided to mda.fit has only two columns, the call to mda.plot_selected_centroids() fails:


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 7
      5 mda = MDA(num_centers=mda_parameters.get("num_centers"))
      6 mda.fit(data=df_dataset, first_centroid_seed=88)
----> 7 mda.plot_selected_centroids(plot_text=True)

File /vols/abedul/home/grupos/valvanuz/HySwash/BlueMath_tk/bluemath_tk/datamining/_base_datamining.py:249, in BaseClustering.plot_selected_centroids(self, data_color, centroids_color, plot_text, **kwargs)
    246 for c1, v1 in enumerate(variables_names[1:]):
    247     for c2, v2 in enumerate(variables_names[:-1]):
    248         default_static_plot.plot_scatter(
--> 249             ax=axes[c2, c1],
    250             x=self.data[v1],
    251             y=self.data[v2],
    252             c=data_color,
    253             alpha=0.6,
    254             **kwargs,
    255         )
    256         if self.centroids is not None:
    257             default_static_plot.plot_scatter(
    258                 ax=axes[c2, c1],
    259                 x=self.centroids[v1],
   (...)
    263                 **kwargs,
    264             )

TypeError: 'Axes' object is not subscriptable

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions