Skip to content

Instantly share code, notes, and snippets.

@linusheck
Created February 18, 2018 13:22
Show Gist options
  • Save linusheck/2aa8c9ed2a0a2a4a6ed787409f27e747 to your computer and use it in GitHub Desktop.
Save linusheck/2aa8c9ed2a0a2a4a6ed787409f27e747 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
img_name = 'plot.png'
data_s = open("data.txt").read()
data = eval(data_s)
data = data[:-2]
names = [x[0] for x in data]
heights = [x[1] for x in data]
coords = range(len(data))
fig = plt.figure(figsize=(30, 2), dpi=1000)
plt.ylabel("Votes per comment", fontsize = 3)
plt.tick_params(axis='both', which='major', labelsize=3)
plt.tick_params(axis='both', which='minor', labelsize=3)
plt.bar(coords, heights)
plt.xticks(coords, names, rotation=90, fontsize=3)
plt.margins(0.0, 0)
plt.subplots_adjust(left=.01, right=.98, top=0.9, bottom=.5)
fig.savefig(img_name, dpi=1000)
from PIL import Image
img = Image.open(img_name)
img = img.rotate(-90, expand=True)
img.save(img_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment