Created
February 25, 2014 14:43
-
-
Save kidpixo/9210117 to your computer and use it in GitHub Desktop.
glue manipulation code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glue | |
clients_classes = (glue.clients.HistogramClient,glue.clients.ImageClient,glue.clients.ScatterClient) | |
clients = [] | |
for i in range(size(hub._subscriptions.keys())): | |
tmp = hub._subscriptions.keys()[i] | |
if isinstance(tmp, glue.clients.HistogramClient): | |
is_class = 'histogram' | |
elif isinstance(tmp, glue.clients.ImageClient): | |
is_class = 'image' | |
elif isinstance(tmp, glue.clients.ScatterClient): | |
is_class = 'scatter' | |
else : | |
is_class = 'noclient' | |
if is_class != 'noclient' : | |
print '%s client instance at position %d: %40s' % (is_class,i,tmp) | |
print 'X_label : %s' % (tmp.axes.get_xlabel()) | |
print 'Y_label : %s' % (tmp.axes.get_ylabel()) | |
print '-'*10 | |
clients.append(is_class) | |
# | |
# scatter client instance at position 4: <glue.clients.scatter_client.ScatterClient object at 0x12e2b7290> | |
# X_label : RandomPCA comp 1 | |
# Y_label : K-Means_StandardScaler_2_classes | |
# ---------- | |
# image client instance at position 7: <glue.clients.image_client.ImageClient object at 0x12db05310> | |
# X_label : World 1 | |
# Y_label : World 0 | |
# ---------- | |
# scatter client instance at position 9: <glue.clients.scatter_client.ScatterClient object at 0x12f786d50> | |
# X_label : elmap_casi | |
# Y_label : elmap_ssi | |
# ---------- | |
# scatter client instance at position 11: <glue.clients.scatter_client.ScatterClient object at 0x13038e1d0> | |
# X_label : max_surf_temperature | |
# Y_label : crustal_thickness | |
# ---------- | |
# image client instance at position 12: <glue.clients.image_client.ImageClient object at 0x114f231d0> | |
# X_label : World 1 | |
# Y_label : World 0 | |
# ---------- | |
# histogram client instance at position 13: <glue.clients.histogram_client.HistogramClient object at 0x117733050> | |
# X_label : max_surf_temperature | |
# Y_label : N | |
# ---------- | |
i = 13 | |
plo = hub._subscriptions.keys()[i] | |
plo.axes.set_xlabel('Crustal Thickness (km)') | |
# plo.axes.set_xlabel('Maximum Surface Temperature (K)') | |
# plo.axes.set_ylabel('Mg/Si') | |
plo.axes.set_ylabel('Frequency') | |
# update plot | |
plo.axes.figure.canvas.draw() | |
path = '/Users/damo_ma/Documents/Dropbox/work/python/LPCSC2014/' | |
img_type = 'pdf' | |
if clients[i] == 'histogram': | |
name = ('%s_%s.%s') % (clients[i],plo.axes.get_xlabel(),img_type) | |
elif clients[i] == 'image': | |
name = ('%s_%s.%s') % (clients[i],plo.axes.get_xlabel(),img_type) | |
elif clients[i] == 'scatter': | |
# FIXME extract image title or variable visualized! | |
name = ('%s_%s_vs_%s.%s') % (clients[i],plo.axes.get_xlabel(),plo.axes.get_ylabel(),img_type) | |
name = name.replace(" ", "_").replace("/", "") | |
plo.axes.figure.savefig(path+name, bbox_inches='tight',dpi=300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment