This repository has been archived on 2024-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
powd/plot.py

24 lines
687 B
Python
Raw Normal View History

import psycopg2
import matplotlib.pyplot as plt
from mplcursors import cursor # separate package must be installed
# Connect to your postgres DB
conn = psycopg2.connect("postgres://postgres:password@localhost:5420/postgres")
# Open a cursor to perform database operations
cur = conn.cursor()
# Execute a query
cur.execute("SELECT difficulty FROM logs ORDER BY difficulty")# LIMIT 100000")
# Retrieve query results
difficulty = cur.fetchall()
cur.execute("SELECT time FROM logs ORDER BY difficulty")# LIMIT 100000")
time = cur.fetchall()
# reproducible sample data as a pandas dataframe
#plt.figure(figsize=(4096, 4096))
plt.scatter(difficulty, time)
#cursor(hover=True)
plt.show()