[英]adjust color scale location in plotly
我想使用並行類別圖顯示我的 dataframe 的兩列之間的連接,它們有重復的連接。 問題是,我不知道如何調整顏色條的位置,這樣它就不會中斷標簽的 rest。 我正在添加更多上下文的代碼:
import plotly.express as px
from Models.Linear import Linear
model = Linear('YAP1')
index = model.get_index()
m, n = model.get_full_A().shape
df = pd.DataFrame(index=np.arange(m), columns=['Expression', 'Methylation'])
df['Data Set'] = index.get_level_values(0).values.flatten()
df['Expression'] = index.get_level_values(1).values.flatten()
df['Methylation'] = index.get_level_values(2).values.flatten()
df['size'] = how_much_to_satisfy()
fig = px.parallel_categories(df, dimensions=['Expression', 'Methylation'],
color="size", color_continuous_scale=px.colors.sequential.Inferno,
width=100, )
fig.update_layout(autosize=False, width=1200, height=1500,
margin=dict(l=500, r=300, b=65, t=90, pad=4), font=dict(size=15))
謝謝!
您可以通過其x
屬性移動顏色條的 position 。
fig.layout['coloraxis']['colorbar']['x'] = 1.15
我無權訪問您的數據集,但這里有一個來自 Plotly 的示例,它顯示了同樣的問題,即顏色條與標簽重疊。
import plotly.express as px
df = px.data.tips()
df['day'].replace({'Sun': 'Sunday יום ראשון', 'Sat': 'Saturday יום שבת', 'Thur': 'Thursday יום חמישי',
'Fri': 'Friday יום שישי'}, inplace=True)
fig = px.parallel_categories(df, dimensions=['sex', 'smoker', 'day'],
color="size", color_continuous_scale=px.colors.sequential.Inferno,
labels={'sex':'Payer sex', 'smoker':'Smokers at the table', 'day':'Day of week'},
)
fig.show()
fig.layout['coloraxis']['colorbar']['x'] = 1.15
fig.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.