Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python – Timeline chart

Does anyone know if it’s possible to create a graph like this, with some Python library? If so, does anyone have any examples to share?

Thanks.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It should be pretty straight forward using plotly.express.timeline. Look at the first example on that page. If you want it on one y-axis position like your screenshot then try

# example directly from Plotly
import plotly.express as px
import pandas as pd

df = pd.DataFrame([
    dict(Task="Job A", Start='2009-01-01', Finish='2009-01-03'),
    dict(Task="Job B", Start='2009-01-03', Finish='2009-01-16'),
    dict(Task="Job C", Start='2009-01-16', Finish='2009-01-18')
])
# add color param and remove the y param from the example
fig = px.timeline(df, x_start="Start", x_end="Finish", color='Task')
fig.show()

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading