title: pyclustering visualising xmeans when the matrix has more than three dimensions
body: <p>I'm trying to cluster and visualise some data with xmeans from the pyclustering lib.
  I copied the code directly from the <a href="https://pyclustering.github.io/docs/0.9.0/html/dd/db4/classpyclustering_1_1cluster_1_1xmeans_1_1xmeans.html" rel="nofollow noreferrer">example</a> in the documentation,</p>
  <pre><code>from pyclustering.cluster import cluster_visualizer
  from pyclustering.cluster.xmeans import xmeans
  from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
  from pyclustering.utils import read_sample
  from pyclustering.samples.definitions import SIMPLE_SAMPLES
  sample = X # read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE3)    
  # Prepare initial centers - amount of initial centers defines amount of clusters from which X-Means will
  # start analysis.
  amount_initial_centers = 2
  initial_centers = kmeans_plusplus_initializer(sample, amount_initial_centers).initialize()
  # Create instance of X-Means algorithm. The algorithm will start analysis from 2 clusters, the maximum
  # number of clusters that can be allocated is 20.
  xmeans_instance = xmeans(sample, initial_centers, 20)
  xmeans_instance.process()
  # Extract clustering results: clusters and their centers
  clusters = xmeans_instance.get_clusters()
  centers = xmeans_instance.get_centers()
  # Print total sum of metric errors
  print(&quot;Total WCE:&quot;, xmeans_instance.get_total_wce())
  # Visualize clustering results
  visualizer = cluster_visualizer()
  visualizer.append_clusters(clusters, sample)
  visualizer.append_cluster(centers, None, marker='*', markersize=10)
  visualizer.show()
  </code></pre>
  <p>The only difference is that I assigned to <code>sample</code> the value of my matrix X instead of loading a sample dataset.</p>
  <p>When I try to visualise the clustering result I get this error:</p>
  <pre><code>Only objects with size dimension 1 (1D plot), 2 (2D plot) or 3 (3D plot) can be displayed. For multi-dimensional data use 'cluster_visualizer_multidim'.
  </code></pre>
  <p>My X matrix is generated in this way:</p>
  <pre><code>features = [&quot;I&quot;, &quot;Iu&quot;, other 7 column names]
  data = df[features]
  ...
  X = scaler.fit_transform(data)
  </code></pre>
  <p><strong>Is there a way to visualise the clusters and plotting only two/three features at a time?</strong></p>
  <p>I can't find anything on the documentation.</p>
  <p>I tried this:</p>
  <pre><code>visualizer.append_clusters(clusters, sample[:,[0,1]])
  </code></pre>
  <p>in order to visualise only the first two features and got this error</p>
  <pre><code>Only clusters with the same dimension of objects can be displayed on canvas.
  </code></pre>
  <p>EDIT:</p>
  <p>I updated the code as suggested in the answer by annoviko but now I get the following error:</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-69-6fd7d2ce5fcd&gt; in &lt;module&gt;
       20 visualizer.append_clusters(clusters, X)
       21 visualizer.append_cluster(centers, None, marker='*', markersize=10)
  ---&gt; 22 visualizer.show(pair_filter=[[0, 1], [0, 2]])
  
  /usr/local/lib/python3.8/site-packages/pyclustering/cluster/__init__.py in show(self, pair_filter, **kwargs)
      224             raise ValueError(&quot;There is no non-empty clusters for visualization.&quot;)
      225 
  --&gt; 226         cluster_data = self.__clusters[0].data or self.__clusters[0].cluster
      227         dimension = len(cluster_data[0])
      228 
  
  ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  </code></pre>
  <p>It is raised by visualizer.show(), and it happens even if I remove the pair_filter from within the function call.</p>