Plot a Calendar?

Posted on
Sun Jul 10, 2016 10:14 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Plot a Calendar?

Maybe some way to plot a monthly calendar?
Just looking to be able to pull up a monthly calendar on
my living room display screen./control page.

Thanks,

Carl

Posted on
Sun Jul 10, 2016 10:15 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Plot a Calendar?

I'm working on a plugin that does this but it's a bit away with some other updates I have to do in front of it.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jul 10, 2016 10:02 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Plot a Calendar?

Great news! You are one amazingly prolific plugineer.

Thanks,

Carl

Posted on
Mon Jul 11, 2016 6:22 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plot a Calendar?

Until such time as @Colorado4Wheeler has time to do something (which I hope happens!), here is a quick and dirty script to generate a calendar plot. The script will place an image into the Indigo Static Images Folder called 'calendar.png' which should make it easy to add to a control page. You can adjust the font and the color by changing the first two variables.

Cautions:
- the font needs to be a monospace font in order for things to line up properly.
- the background is transparent, so choose a color that will work well with your control page background (you can use the OS X color picker to find the HTML color value).
- if you change the font size, it won't be centered in the box any longer (and may not fit if you go much larger); if necessary, uncomment the 'ax.axis('off')' to hide the box.

Note: this script requires matplotlib be installed on the Indigo server machine If your machine does not have matplotlib installed, this is probably not a solution for you (later Macs ship with it preinstalled.)
Code: Select all
#! /usr/bin/env python2.6
# -*- coding: utf-8 -*-

import calendar
from datetime import datetime, time
import matplotlib.pyplot as plt

font_name = 'Andale Mono'
font_color = '#000000'

year = int(datetime.today().strftime('%Y'))
month = int(datetime.today().strftime('%m'))
cal = calendar.month(year, month)
output_file_path = '/Library/Application Support/Perceptive Automation/Indigo 6/IndigoWebServer/images/controls/static/calendar.png'

fig = plt.figure(figsize=(5, 3))
ax = fig.add_subplot(111)
ax.text(0.07, 0.95, cal, transform=ax.transAxes, color=font_color, fontname=font_name, fontsize=20, verticalalignment='top')
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
# ax.axis('off')  # uncomment this line to hide the box

plt.savefig(output_file_path, transparent=True)


calendar.png
calendar.png (28.92 KiB) Viewed 4303 times
Last edited by DaveL17 on Mon Jul 11, 2016 11:30 am, edited 1 time in total.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jul 11, 2016 8:54 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Plot a Calendar?

Looks great! Thing is it wants a mathplotlib installed. I'm running 10.6.8. I see the install for it uses Python 2.7,
Do you think installing mathplotlib will work?

Thanks,

Carl

Posted on
Mon Jul 11, 2016 9:06 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plot a Calendar?

ckeyes888 wrote:
Looks great! Thing is it wants a mathplotlib installed. I'm running 10.6.8. I see the install for it uses Python 2.7,
Do you think installing mathplotlib will work?

Thanks,

Carl

Hmmm. I believe it was only on later installs where matplotlib was factory installed on OS X. You could try this:

Code: Select all
pip-2.6 install matplotlib

I can't guarantee compatibility (mine is matplotlib 1.1.1 and you will likely get a later version) although it should work.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jul 11, 2016 9:15 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Plot a Calendar?

Tried: pip-2.6 install matplotlib and pip-2.7 install matplotlib
both return command not found.

Thanks,

Carl

Posted on
Mon Jul 11, 2016 9:22 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plot a Calendar?

Try:

Code: Select all
pip2.6 install matplotlib

(no hyphen) My mistake thinking that you'd be on an earlier version of pip.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jul 11, 2016 9:39 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Plot a Calendar?

Nuts. Same issue: command not found.

Thanks,

Carl

Posted on
Mon Jul 11, 2016 9:41 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plot a Calendar?

Do you have pip installed?


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jul 11, 2016 9:45 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Plot a Calendar?

I do have Macports installed so I tried: sudo port install py27-matplotlib
and it seems to be installing. Hope it doesn't mess anything up :-)
Let you know how it goes.

Thanks,

Carl

Posted on
Mon Jul 11, 2016 9:55 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plot a Calendar?

What you're doing shouldn't mess anything up, but in order for the script to work in Indigo, you're going to need to install matplotlib for Python 2.6.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jul 11, 2016 9:59 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Plot a Calendar?

Now the error is: no module named mathplotlib.pyplot
Maybe called something else?

Thanks,

Carl

Posted on
Mon Jul 11, 2016 10:07 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Plot a Calendar?

ckeyes888 wrote:
Now the error is: no module named mathplotlib.pyplot
Maybe called something else?

Thanks,

Carl

It's matplotlib NOT mathplotlib i.e. no 'H' after 'MAT' :)

Posted on
Mon Jul 11, 2016 10:57 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Plot a Calendar?

Looks great! Thing is it wants a mathplotlib installed. I'm running 10.6.8. I see the install for it uses Python 2.7,
Do you think installing mathplotlib will work?

I tried to get matplotlib installed on v2.6 on OS X and ended up giving up - there were too many workarounds and hacks that were published as how to do it and some worked to get past an error or two, but then ran into others. Mostly dependency issues that Apple apparently fixed on later OS X versions where it is pre-installed. Your mileage may vary, of course, but I found it an exercise in frustration.

Who is online

Users browsing this forum: No registered users and 4 guests