I'm greenhand with Python plots but I was trying to do a PCA for different human populations; while I'm still working on the actual data, the main issue I'm having with visualizations in Python, as opposed to R, is that doesn't make things very easy...
Specifically, I spent some time figuring out how to set the layout of my plot but I can't get the legend title to show in the middle of the legend itself.
Supposedly, there is an option in title_side which should do so; however, instead, it corrupts the plot legend. If anyone has any experience with this, any help would be much appreciated. Below the code for plotting and the PCA plot.
fig = px.scatter(pca, x='PC1', y='PC2', color='#LOC', template="seaborn")
fig.update_layout(legend=dict(
title="<i> metapopulation <i>",
title_side="top",
orientation="h",
entrywidthmode='fraction',
entrywidth=.2,
x=.5),
autosize=False,
height=800,
width=800
)
fig.update_xaxes(title_text = f"PC1 ( {pve.at[pve.index[0], 0]} %)",
range=(-0.05, 0.2),
constrain='domain')
fig.update_yaxes(title_text = f"PC2 ( {pve.at[pve.index[1], 0]} %)",
scaleanchor="x",
scaleratio=1)
fig.show()
EDIT for @Naren Murali
This is what I mean by corrupted legend and figure too, I just realized the use of a dict somehow shifts the whole scatter plot...


Could you try changing
titleto a dict containing two propertiestextandside. Since we are using legend as adictthen we cannot uselegend_title_sidesince its not a part of the root dict offig.update_layoutAs per the docs:
side
text