Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Priestley Timeline to vis-common-plots.html#priestly-timeline #77

Open
timsteeno opened this issue Aug 30, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working
Milestone

Comments

@timsteeno
Copy link

Noticed that the Priestley timeline at /vis-common-plots.html#priestly-timeline was incomplete. This code or some variation of it should complete it - I can make a pull request.

df = df.sort_values('Born')

# Create the plot
fig, ax = plt.subplots(figsize=(12, 6))

for i, (index, row) in enumerate(df.iterrows()):
    lifespan = (row['Died'] - row['Born']).days
    bar = ax.barh(len(df) - 1 - i, lifespan, left=row['Born'], height=0.5)
    text_x = row['Born'] + pd.Timedelta(days=lifespan/2)
    
    # Add text inside the bar
    ax.text(text_x, len(df) - 1 - i, row['Name'], 
            va='center', ha='center', 
            color='white', fontweight='bold', fontsize=8)

ax.set_yticks([])
plt.xlabel('Year')
plt.show()

image

@aeturrell aeturrell self-assigned this Sep 7, 2024
@aeturrell aeturrell added the bug Something isn't working label Sep 7, 2024
@aeturrell
Copy link
Owner

Thank you. Would welcome a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants