Page 1 of 2

Plot a Calendar?

PostPosted: Sun Jul 10, 2016 10:14 am
by ckeyes888
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

Re: Plot a Calendar?

PostPosted: Sun Jul 10, 2016 10:15 am
by Colorado4Wheeler
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.

Re: Plot a Calendar?

PostPosted: Sun Jul 10, 2016 10:02 pm
by ckeyes888
Great news! You are one amazingly prolific plugineer.

Thanks,

Carl

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 6:22 am
by DaveL17
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 4453 times

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 8:54 am
by ckeyes888
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

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:06 am
by DaveL17
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.

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:15 am
by ckeyes888
Tried: pip-2.6 install matplotlib and pip-2.7 install matplotlib
both return command not found.

Thanks,

Carl

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:22 am
by DaveL17
Try:

Code: Select all
pip2.6 install matplotlib

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

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:39 am
by ckeyes888
Nuts. Same issue: command not found.

Thanks,

Carl

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:41 am
by DaveL17
Do you have pip installed?


Sent from my iPhone using Tapatalk

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:45 am
by ckeyes888
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

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:55 am
by DaveL17
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.

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 9:59 am
by ckeyes888
Now the error is: no module named mathplotlib.pyplot
Maybe called something else?

Thanks,

Carl

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 10:07 am
by autolog
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' :)

Re: Plot a Calendar?

PostPosted: Mon Jul 11, 2016 10:57 am
by RogueProeliator
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.