BiomedicalMachineLearning / stLearn

A novel machine learning pipeline to analyse spatial transcriptomics data
Other
190 stars 25 forks source link

How to show figure in python console #218

Closed Feng-Zhang closed 1 year ago

Feng-Zhang commented 1 year ago

Dear authors, I am running the code given from the maunal.

# K-means clustering on stSME normalised PCA
st.tl.clustering.kmeans(data_SME,n_clusters=19, use_data="X_pca", key_added="X_pca_kmeans")
st.pl.cluster_plot(data_SME, use_label="X_pca_kmeans")

The above code expects plotting a figure, but not in python console when I debug the code using pycharm. However, the figure shows up when I use notebook. This seems that I have to use like plt.show() function to show it. But plt.show() doesn't work in this case. Could you give me a hand? Thank you.

duypham2108 commented 1 year ago

Can you try this code to use figure to show it

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
st.pl.cluster_plot(data_SME, use_label="X_pca_kmeans", ax=ax)
fig.show()
Feng-Zhang commented 1 year ago

Sorry for my bad. plt.show() works.