# Magic
%matplotlib inline
# Reload modules whenever they change
%load_ext autoreload
%autoreload 2
# Make clusterking package available even without installation
import sys
sys.path = ["../../"] + sys.path
import pandas as pd
import os.path
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from pathlib import Path
from clusterking.plots import ClusterPlot
from clusterking.data.data import Data
d = Data("output/cluster/", "tutorial_basics")
clusters = list(df['cluster'].unique())
colors = ["red", "green", "blue", "pink"]
markers = ["o", "v", "^"]
df = d.df
ax = plt.figure().gca(projection='3d')
ax.set_xlabel('CVL_bctaunutau')
ax.set_ylabel('sl')
ax.set_zlabel('CT_bctaunutau')
for index, cluster in enumerate(clusters):
df_cluster = df[df['cluster'] == cluster]
ax.scatter(
df_cluster['CVL_bctaunutau'],
df_cluster['CSL_bctaunutau'],
df_cluster['CT_bctaunutau'],
color=colors[cluster % len(colors)],
marker=markers[cluster % len(markers)],
label=cluster
)
plt.legend(loc='upper left');
plt.show()
fig, ax = plt.subplots()
ax.set_xlabel('CVL_bctaunutau')
ax.set_ylabel('CSL_bctaunutau')
# fix remaining Wilson coefficients
t_value_index = 1
t_value = df['CT_bctaunutau'].unique()[t_value_index]
for index, cluster in enumerate(clusters):
df_cluster = df[df['cluster'] == cluster]
df_cluster = df_cluster[df_cluster['CT_bctaunutau'] == t_value]
ax.scatter(
df_cluster['CVL_bctaunutau'],
df_cluster['CSL_bctaunutau'],
color=colors[cluster % len(colors)],
marker=markers[cluster % len(markers)],
label=cluster
)
plt.legend(bbox_to_anchor=(1.2, 1.0));
plt.show()
plot_clusters
¶Set up the plotter:
cp = ClusterPlot(d)
cp.draw_legend=True
Scatter plot: The list is the list of the columns on the axes. Changing the order of the columns will turn around the cube.
cp.scatter(['CVL_bctaunutau', 'CSL_bctaunutau', 'CT_bctaunutau'])
If it is still not easy to get an overview, use the clusters
argument to limit ourselves to certain clusters.
cp.scatter(['CVL_bctaunutau', 'CSL_bctaunutau', 'CT_bctaunutau'], clusters=[0, 2])
cp.savefig("/home/fuchur/scatter_3d_02.png")
If only two columns are given, several cuts will be presented (up to 16 by default):
cp.scatter(['CVL_bctaunutau', 'CSL_bctaunutau'])
Again, we can also limit ourselves on the clusters that we want to display:
cp.scatter(['CVL_bctaunutau', 'CSL_bctaunutau'], clusters=[1,2])
If many wilson points are available, it is better to switch to a 'fill' plot:
cp.fill(['CVL_bctaunutau', 'CSL_bctaunutau'])
Several options to configure the the ClusterPlot object can be changed after the object has been initialized.
The number of plots for the 'slices' by
cp.max_subplots
Let's change that (note that no warning is issued when trying to set a non-existing property, so do be careful with your typing):
cp.max_subplots =
And try it out:
cp.scatter(['CVL_bctaunutau', 'CSL_bctaunutau'])
cp.fill(['CVL_bctaunutau', 'CSL_bctaunutau'])
cp.savefig("/home/fuchur/fill_2d.png")
To see all options, see the Attribute
section of the help.
help(cp)