#!/usr/bin/python # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as mdates import datetime def main(): # Sample data epoch_times = [1696000000, 1696086400, 1696172800, 1696259200] # Epoch seconds y_values = [10, 20, 15, 25] # Some y-axis values # Convert epoch times to datetime objects dates = [datetime.datetime.fromtimestamp(ts) for ts in epoch_times] # Create the plot fig, ax = plt.subplots() ax.plot(dates, y_values, marker='o', linestyle='-') # Format the x-axis as date # ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d\n%H:%M:%S')) # Customize as needed ax.xaxis.set_major_locator(mdates.AutoDateLocator()) # Automatically adjusts for readability ax.xaxis.set_major_formatter( mdates.ConciseDateFormatter(ax.xaxis.get_major_locator())) # Rotate date labels for better visibility plt.xticks(rotation=45) # Labels and title plt.xlabel("Date & Time") plt.ylabel("Values") plt.title("Epoch to Human Readable Time Plot") # Show the plot plt.show() if __name__ == '__main__': main()