Skip to content

Instantly share code, notes, and snippets.

@bilinin
Last active June 18, 2016 12:30
Show Gist options
  • Save bilinin/b5fbc985b291824bf80b2d0b76a4a93e to your computer and use it in GitHub Desktop.
Save bilinin/b5fbc985b291824bf80b2d0b76a4a93e to your computer and use it in GitHub Desktop.
http://pythonworld.ru/web/cgi-2.html
sudo -H pip install matplotlib
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['font.family'] = 'fantasy'
mpl.rcParams['font.fantasy'] = 'Arial' # Для Windows
mpl.rcParams['font.fantasy'] = 'Ubuntu' # Для Ubuntu
mpl.rcParams['font.fantasy'] = 'Arial, Ubuntu' # работает как под Windows, так и под Ubuntu
from matplotlib import rc
mpl.rcdefaults() # сброс настроек
font = {'family': 'Courier New',
'weight': 'normal'}
rc('font', **font)
def make_autopct(values):
def my_autopct(pct):
print(values[0][0])
return '({h:d}) часов \n ({m:d}) минут '.format(h=values[0][0], m=values[0][1])
print(my_autopct)
return my_autopct
# Одно дело
current_label = 'Сделать диплом'
day = 24*60
current_min = 50
current_hour = 21
procent = ((current_min+current_hour*60)/day)*100
# The slices will be ordered and plotted counter-clockwise.
labels = current_label, 'Свободное время'
sizes = [procent, 100 - procent]
colors = ['gold', 'gray']
explode = (0, 0.1) # only "explode" the 2nd slice (i.e. 'Hogs')
plt.pie(sizes, labels=labels, colors=colors,
autopct=make_autopct([[current_hour,current_min],[24 - current_hour, 60 - current_min]]), shadow=False, startangle=90)
mpl.rcdefaults() # сброс настроек
plt.title(u'Планы на день',{'fontname':'Tahoma'})
plt.savefig('lol')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment