Home > Back-end >  How can I align multiple line plot titles?
How can I align multiple line plot titles?

Time:10-27

Currently I use plotly and it looks not so nice when I use mutliple line titles, it is not aligned. Is there a way to align them properly?

This is how it looks like right now:

import pandas as pd
import plotly.express as px
s = pd.Series(np.random.randn(5), index=["a", "b", "c", "d", "e"])
fig = px.line(s, title='This is a fantasy dataset <br> Why is this line not aligned with the text above?')
fig.show

Output:

enter image description here

CodePudding user response:

There is a space before Why, removing that will put the line aligned to top line.

import pandas as pd
import plotly.express as px
import numpy as np
s = pd.Series(np.random.randn(5), index=["a", "b", "c", "d", "e"])
fig = px.line(s, title='This is a fantasy dataset <br>Why is this line not aligned with the text above?')
fig.show()

After <br />, there should not be a space.

This outputs as -

enter image description here

  • Related