Answers for "sns datetime histogram"

0

sns datetime histogram

import datetime
import seaborn as sns
import matplotlib.pyplot as plt
# Generate dates -- change by your actual dates!
dates = [datetime.datetime.fromordinal(int(d)) for d in (43 * np.random.randn(200) + 737555)]
# Go back to ordinal numbers...
ordinal_dates = np.array([d.toordinal() for d in dates])
sns.distplot(ordinal_dates, kde=True)
# Now, get the positions of the xticks
ticks_locations, _ = plt.xticks();
# Get the labels for those positions
labels = [datetime.datetime.fromordinal(int(t)).date() for t in ticks_locations]
plt.xticks(ticks_locations, labels, rotation=90)
plt.title("Date distribution");
Posted by: Guest on September-29-2021

Python Answers by Framework

Browse Popular Code Answers by Language