1

I have two plots based on two different features. I want to "superimpose" the two plots to show the effect of tumor subtypes (kirp, kirc, kich) on survival (lts, non-lts).

import pandas as pd 
import plotly.express as px
import numpy as np
from sklearn.decomposition import KernelPCA

# Data
X = meth_clin_sub_nt_2_kipan.iloc[:,7:-1]

# Kernel PCA
kpca = KernelPCA(n_components=2, kernel='rbf', 
                 gamma=15, random_state=42)
X_kpca = kpca.fit_transform(X)

# Survival plot

fig = px.scatter(X_kpca, x=0, y=1, color=meth_clin_sub_nt_2_kipan["survival"], width=600, height=600, title="Kernel PCA - Survival", symbol=meth_clin_sub_nt_2_kipan["survival"], symbol_sequence=['circle','square'])
fig.update_xaxes(automargin=True)
fig.update_yaxes(automargin=True)
fig.update_layout({'plot_bgcolor': 'rgb(240,240,240)','paper_bgcolor': 'rgb(240,240,240)'})
fig.show()

enter image description here

# Tumor subtype vs normal plot
fig = px.scatter(X_kpca, x=0, y=1, color=meth_clin_sub_nt_2_kipan["type"], width=600, height=600, color_discrete_sequence=["red", "orange", "brown", "green"], title="Kernel PCA - tumor subtype vs normal", symbol=meth_clin_sub_nt_2_kipan["type"], symbol_sequence=['circle','circle','circle','square'])
fig.update_traces(marker=dict(size=5,line=dict(width=0.5,color='DarkSlateGrey')),selector=dict(mode='markers'))
fig.update_xaxes(automargin=True)
fig.update_yaxes(automargin=True)
fig.update_layout({'plot_bgcolor': 'rgb(240,240,240)','paper_bgcolor': 'rgb(240,240,240)',})
fig.show()

enter image description here

melolilili
  • 199
  • 1
  • 3
  • 11
  • What about plotly subplot? https://plotly.com/python/subplots/ – Mohamed Thasin ah Aug 04 '22 at 09:58
  • I do not want subplots. I want one plot with both info. – melolilili Aug 04 '22 at 10:08
  • @melolilili Your code is not reproducible. Please consider sharing a sample of your dataset as described [here](https://stackoverflow.com/questions/63163251/pandas-how-to-easily-share-a-sample-dataframe-using-df-to-dict/63163254#63163254). – vestland Aug 04 '22 at 10:36

0 Answers0