From 421dfe9c325a58cd51eb647f205b3fc85871e53b Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Thu, 26 Sep 2019 18:03:39 -0700 Subject: [PATCH] turn off x/y labels --- click_plots/portrait_plots.py | 57 ++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/click_plots/portrait_plots.py b/click_plots/portrait_plots.py index 86cb38e..fc71ed2 100644 --- a/click_plots/portrait_plots.py +++ b/click_plots/portrait_plots.py @@ -144,13 +144,10 @@ def plot(self, data, full_dic, merge=None, # It DOES modify the data axes self.decorate(data, yax, xax) - tmp_template = vcs.gettemplate(template) - tmp_template.xlabel2.list() mesh, template, meshfill = super(ClickablePortrait, self).plot( data, template=template, multiple=multiple) png_file = self.png_template() self.x.png(png_file) - targets, tips, extras, tips_lbls_x, extras_lbls_x, tips_lbls_y, extras_lbls_y = self.createModalTargets( data, full_dic, merge=merge, sector=sector) # Creates clickable polygons numpy arrays @@ -158,39 +155,51 @@ def plot(self, data, full_dic, merge=None, meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) click_labels_x1 = vcs.utils.axisToPngCoords([], meshfill, template, 'x1', [ meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) - click_labels_y1 = vcs.utils.axisToPngCoords([], meshfill, template, 'y1', [ - meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) click_labels_x2 = vcs.utils.axisToPngCoords([], meshfill, template, 'x2', [ meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) - click_labels_y2 = vcs.utils.axisToPngCoords([], meshfill, template, 'y2', [ - meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) - + click_labels_x = numpy.concatenate((click_labels_x1, click_labels_x2)) targets_lbls_x = [ meshfill.xticlabels1[k] for k in sorted(meshfill.xticlabels1)] - targets_lbls_y = [ - meshfill.yticlabels1[k] for k in sorted(meshfill.yticlabels1)] targets_lbls_x += [ meshfill.xticlabels2[k] for k in sorted(meshfill.xticlabels2)] - targets_lbls_y += [ - meshfill.yticlabels2[k] for k in sorted(meshfill.yticlabels2)] + if self.ylabels_tooltips_images_template is not None: + click_labels_y1 = vcs.utils.axisToPngCoords([], meshfill, template, 'y1', [ + meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) + click_labels_y2 = vcs.utils.axisToPngCoords([], meshfill, template, 'y2', [ + meshfill.datawc_x1, meshfill.datawc_x2, meshfill.datawc_y1, meshfill.datawc_y2], png=png_file) + targets_lbls_y += [ + meshfill.yticlabels2[k] for k in sorted(meshfill.yticlabels2)] + targets_lbls_y = [ + meshfill.yticlabels1[k] for k in sorted(meshfill.yticlabels1)] + click_labels_y = numpy.concatenate((click_labels_y1, click_labels_y2)) + # when using multiple we have different shapes so we need to "extend" - click_labels_x = numpy.concatenate((click_labels_x1, click_labels_x2)) - click_labels_y = numpy.concatenate((click_labels_y1, click_labels_y2)) - if click_areas.shape[-1] > click_labels_x1.shape[-1]: + if click_areas.shape[-1] > click_labels_x.shape[-1]: # ok more vertices in click area click_labels_x = add_extra_vertices(click_labels_x) - click_labels_y = add_extra_vertices(click_labels_y) elif click_areas.shape[-1] < click_labels_x.shape[-1]: # ok less vertices in click area click_areas = add_extra_vertices(click_areas) - - clicks = numpy.concatenate( - (click_areas, click_labels_x, click_labels_y)) - targets = numpy.concatenate((targets, targets_lbls_x, targets_lbls_y)) - tips = numpy.concatenate((tips, tips_lbls_x, tips_lbls_x, tips_lbls_y, tips_lbls_y)) - extras = numpy.concatenate((extras, extras_lbls_x, extras_lbls_x, extras_lbls_y, extras_lbls_y)) - - print("SHAPED OUT:", clicks.shape, targets.shape, tips.shape, extras.shape) + if self.ylabels_tooltips_images_template is not None: + if click_areas.shape[-1] > click_labels_1.shape[-1]: + click_labels_y = add_extra_vertices(click_labels_y) + elif click_areas.shape[-1] < click_labels_y.shape[-1]: + # ok less vertices in click area + click_areas = add_extra_vertices(click_areas) + + clicks = click_areas + if self.xlabels_tooltips_images_template is not None: + clicks = numpy.concatenate((clicks, click_labels_x)) + targets = numpy.concatenate((targets, targets_lbls_x)) + tips = numpy.concatenate((tips, tips_lbls_x, tips_lbls_x)) + extras = numpy.concatenate((extras, extras_lbls_x, extras_lbls_x)) + if self.ylabels_tooltips_images_template is not None: + clicks = numpy.concatenate((clicks, click_labels_y)) + targets = numpy.concatenate((targets, targets_lbls_x)) + tips = numpy.concatenate((tips, tips_lbls_y, tips_lbls_y)) + extras = numpy.concatenate((extras, extras_lbls_y, extras_lbls_y)) + + print("OUT:", clicks.shape, targets.shape, tips.shape, extras.shape) return clicks, targets, tips, extras def createModalTargets(self, data, update_names, merge=None, sector=None):