Created
March 13, 2014 11:09
-
-
Save kidpixo/9526464 to your computer and use it in GitHub Desktop.
Glueviz Image Manipulation
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) | |
# image client instance at position 6: <glue.clients.image_client.ImageClient object at 0x11ec89ed0> | |
# X_label : World 1 | |
# Y_label : World 0 | |
# ---------- | |
# scatter client instance at position 7: <glue.clients.scatter_client.ScatterClient object at 0x1216ff7d0> | |
# X_label : K-Means_StandardScaler_3_classes | |
# Y_label : RandomPCA comp 1 | |
# ---------- | |
# scatter client instance at position 10: <glue.clients.scatter_client.ScatterClient object at 0x1253edc10> | |
# X_label : K-Means_StandardScaler_2_classes | |
# Y_label : RandomPCA comp 1 | |
# ---------- | |
# | |
# elmaps scatterplot | |
# | |
# scatter client instance at position 4: <glue.clients.scatter_client.ScatterClient object at 0x11f857a10> | |
# X_label : Al/Si | |
# Y_label : Mg/Si | |
# ---------- | |
# | |
# other scatterplot | |
# | |
# scatter client instance at position 12: <glue.clients.scatter_client.ScatterClient object at 0x121698f90> | |
# X_label : grid_center_lon | |
# Y_label : elmap_mgsires | |
# ---------- | |
# | |
# histogram client instance at position 9: <glue.clients.histogram_client.HistogramClient object at 0x11f851510> | |
# X_label : crater_density | |
# Y_label : N | |
# ---------- | |
i = 2 | |
plo = hub._subscriptions.keys()[i] | |
# x_label = 'Maximum Surface Temperature (K)' | |
y_label = 'Latitude' | |
x_label = 'XRS resolution' | |
plo.axes.set_xlabel(x_label) | |
plo.axes.set_ylabel(y_label) | |
# update plot | |
plo.axes.figure.canvas.draw() | |
path = '/Users/damo_ma/Documents/Dropbox/work/python/LPCSC2014/' | |
if clients[i] == 'histogram': | |
name = ('%s_%s.') % (clients[i],plo.axes.get_xlabel()) | |
elif clients[i] == 'image': | |
name = ('%s_%s.') % (clients[i],plo.axes.get_xlabel()) | |
elif clients[i] == 'scatter': | |
# FIXME extract image title or variable visualized! | |
name = ('%s_%s_vs_%s.') % (clients[i],plo.axes.get_xlabel(),plo.axes.get_ylabel()) | |
name = name.replace(" ", "_").replace("/", "") | |
# for format in ('png','pdf','eps'): | |
format = 'jpg' | |
plo.axes.figure.savefig(path+name+format, bbox_inches='tight',dpi=300) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment