erdogant / pca

pca: A Python Package for Principal Component Analysis.
https://erdogant.github.io/pca
MIT License
284 stars 42 forks source link

How to remove text labels from scatterplots? #43

Closed wmsheer closed 11 months ago

wmsheer commented 1 year ago

Hi,

Thanks for the great package. Whenever I plot my data with the scatter() function, I get large text labels on each point. I'd like to remove these, but if I use any of the "fontcolor", "fontsize", or "fontweight" arguments, I get a TypeError stating "scatter() got an unexpected keyword argument 'fontcolor'" or the like. Do you know what may be happening?

Thanks!

erdogant commented 1 year ago

try to update to the latest version. This seems to be an issue in the scatterd library.

pip install -U scatterd or also try pip install -U pca

pca version should be >= 2.0.0 scatterd version should be >= 1.3.1

Here is an example to set to fontsize to 0

from sklearn.datasets import make_friedman1
from pca import pca

X, _ = make_friedman1(n_samples=200, n_features=30, random_state=0)
model = pca()
model.fit_transform(X)

# Set fontsize to 0 to remove the labels. Note that the fontsize of the arrows is set in the arrowdict.
model.biplot(density=True, fontsize=0, arrowdict={'weight':'bold', 'fontsize':14})

image

# Set the s(ize) to 0 to remove the dots
model.biplot(density=True, s=0, arrowdict={'weight':'bold', 'fontsize': 14})

image

erdogant commented 1 year ago

text labels can be removed with the font size:

# Remove text in scatter
fig, ax = model.biplot(fontsize=0)
# Remove text in arrow
fig, ax = model.biplot(arrowdict={'fontsize': 0})
# # Remove both
fig, ax = model.biplot(fontsize=0, arrowdict={'fontsize': 0})
erdogant commented 11 months ago

closing this one.