def render(self, ax): from matplotlib import pyplot from matplotlib import colors render_2d.render(self, ax) if self._open_circle_points.size(): x, y = self._open_circle_points.parts() ax.scatter( x.as_numpy_array(), y.as_numpy_array(), s=self._open_circle_radii, marker='o', edgecolors=self._open_circle_colors, facecolors=None) if self._filled_circle_points.size(): x, y = self._filled_circle_points.parts() # use pyplot colormaps then we can more easily get a colorbar data = self.scene.multiplicities.data() cmap_d = { 'heatmap': 'hot', 'redblue': colors.LinearSegmentedColormap.from_list("RedBlud",["b","r"]), 'grayscale': 'Greys_r' if self.settings.black_background else 'Greys', 'mono': (colors.LinearSegmentedColormap.from_list("mono",["w","w"]) if self.settings.black_background else colors.LinearSegmentedColormap.from_list("mono",["black","black"])), } cm = cmap_d.get( self.settings.color_scheme, self.settings.color_scheme) if isinstance(cm, basestring): cm = pyplot.cm.get_cmap(cm) im = ax.scatter( x.as_numpy_array(), y.as_numpy_array(), s=self._filled_circle_radii, marker='o', c=data.select(self.scene.slice_selection).as_numpy_array(), edgecolors='none', vmin=0, vmax=flex.max(data), cmap=cm) # colorbar cb = self.fig.colorbar(im, ax=ax) [t.set_color(self._foreground) for t in cb.ax.get_yticklabels()] [t.set_fontsize(self.settings.font_size) for t in cb.ax.get_yticklabels()] self.ax.set_aspect('equal') self.ax.set_axis_bgcolor(self._background) xmax, ymax = self.GetSize() ax.set_xlim(0, xmax) ax.set_ylim(0, ymax) ax.invert_yaxis() ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) self.fig.tight_layout() self.fig.savefig( self.settings.filename, bbox_inches='tight', facecolor=self._background)
def render(self, ax): from matplotlib import pyplot from matplotlib import colors render_2d.render(self, ax) if self._open_circle_points.size(): x, y = self._open_circle_points.parts() ax.scatter( x.as_numpy_array(), y.as_numpy_array(), s=self._open_circle_radii, marker="o", edgecolors=self._open_circle_colors, facecolors=None, ) if self._filled_circle_points.size(): x, y = self._filled_circle_points.parts() # use pyplot colormaps then we can more easily get a colorbar data = self.scene.multiplicities.data() cmap_d = { "heatmap": "hot", "redblue": colors.LinearSegmentedColormap.from_list( "RedBlue", ["b", "r"] ), "grayscale": "Greys_r" if self.settings.black_background else "Greys", "mono": ( colors.LinearSegmentedColormap.from_list("mono", ["w", "w"]) if self.settings.black_background else colors.LinearSegmentedColormap.from_list( "mono", ["black", "black"] ) ), } cm = cmap_d.get(self.settings.color_scheme, self.settings.color_scheme) if isinstance(cm, str): cm = pyplot.cm.get_cmap(cm) im = ax.scatter( x.as_numpy_array(), y.as_numpy_array(), s=self._filled_circle_radii, marker="o", c=data.select(self.scene.slice_selection).as_numpy_array(), edgecolors="none", vmin=0, vmax=flex.max(data), cmap=cm, ) # colorbar cb = self.fig.colorbar(im, ax=ax) [t.set_color(self._foreground) for t in cb.ax.get_yticklabels()] [t.set_fontsize(self.settings.font_size) for t in cb.ax.get_yticklabels()] self.ax.set_aspect("equal") self.ax.set_facecolor(self._background) xmax, ymax = self.GetSize() ax.set_xlim(0, xmax) ax.set_ylim(0, ymax) ax.invert_yaxis() ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) self.fig.tight_layout() self.fig.savefig( self.settings.plot.filename, bbox_inches="tight", facecolor=self._background )
def render(self, ax): render_2d.render(self, ax) data = [] if self._open_circle_points.size(): x, y = self._open_circle_points.parts() z = self._open_circle_colors data.append( { "x": list(x.round(1)), "y": list(y.round(1)), #'z': list(z), "type": "scatter", "mode": "markers", "name": "missing reflections", "showlegend": False, "marker": { #'color': list(z), "color": ( "white" if self.settings.black_background else "black" ), "line": { #'color': 'black', "width": 0 }, "symbol": "circle", "size": 5, }, } ) if self._filled_circle_points.size(): x, y = self._filled_circle_points.parts() z = self.scene.multiplicities.data().select(self.scene.slice_selection) # why doesn't this work? # colorscale = [] # assert len(z) == len(self._filled_circle_colors) # for zi in range(flex.max(z)+1): # i = flex.first_index(z, zi) # if i is None: continue # print i, self._filled_circle_colors[i], 'rgb(%i,%i,%i)' %tuple(rgb * 264 for rgb in self._filled_circle_colors[i]) # colorscale.append([zi, 'rgb(%i,%i,%i)' %self._filled_circle_colors[i]]) cmap_d = { "rainbow": "Jet", "heatmap": "Hot", "redblue": "RdbU", "grayscale": "Greys", "mono": None, } color = list(z) colorscale = cmap_d.get( self.settings.color_scheme, self.settings.color_scheme ) if self.settings.color_scheme == "mono": color = "black" colorscale = None data.append( { "x": list(x.round(1)), "y": list(y.round(1)), #'z': list(z), "type": "scatter", "mode": "markers", "name": "multiplicity", "showlegend": False, "marker": { "color": color, "colorscale": colorscale, "cmin": 0, "cmax": flex.max(self.scene.multiplicities.data()), "showscale": True, "colorbar": {"title": "Multiplicity", "titleside": "right"}, "line": { #'color': 'white', "width": 0 }, "symbol": "circle", "size": 5, }, } ) text = {"mode": "text", "showlegend": False, "textposition": "top right"} text.update(self._text) data.append(text) shapes = [] for x0, y0, x1, y1 in self._lines: # color = 'rgb(%i,%i,%i)' %tuple(rgb * 264 for rgb in self._foreground) color = "black" shapes.append( { "type": "line", "x0": x0, "y0": y0, "x1": x1, "y1": y1, "layer": "below", "line": {"color": color, "width": 2}, } ) d = { "data": data, "layout": { "plot_bgcolor": "rgb(%i,%i,%i)" % tuple(rgb * 264 for rgb in self._background), "title": "Multiplicity plot (%s=%s)" % (self.settings.slice_axis, self.settings.slice_index), "shapes": shapes, "hovermode": False, "xaxis": { "showgrid": False, "zeroline": False, "showline": False, "ticks": "", "showticklabels": False, }, "yaxis": { "autorange": "reversed", "showgrid": False, "zeroline": False, "showline": False, "ticks": "", "showticklabels": False, }, }, } return d
def render(self, ax): render_2d.render(self, ax) data = [] if self._open_circle_points.size(): x, y = self._open_circle_points.parts() z = self._open_circle_colors data.append({ 'x': list(x.round(1)), 'y': list(y.round(1)), #'z': list(z), 'type': 'scatter', 'mode': 'markers', 'name': 'missing reflections', 'showlegend': False, 'marker': { #'color': list(z), 'color': ('white' if self.settings.black_background else 'black'), 'line': { #'color': 'black', 'width': 0, }, 'symbol': 'circle', 'size': 5, }, }) if self._filled_circle_points.size(): x, y = self._filled_circle_points.parts() z = self.scene.multiplicities.data().select( self.scene.slice_selection) # why doesn't this work? #colorscale = [] #assert len(z) == len(self._filled_circle_colors) #for zi in range(flex.max(z)+1): # i = flex.first_index(z, zi) # if i is None: continue # print i, self._filled_circle_colors[i], 'rgb(%i,%i,%i)' %tuple(rgb * 264 for rgb in self._filled_circle_colors[i]) # colorscale.append([zi, 'rgb(%i,%i,%i)' %self._filled_circle_colors[i]]) cmap_d = { 'rainbow': 'Jet', 'heatmap': 'Hot', 'redblue': 'RdbU', 'grayscale': 'Greys', 'mono': None, } color = list(z) colorscale = cmap_d.get(self.settings.color_scheme, self.settings.color_scheme) if self.settings.color_scheme == 'mono': color = 'black' colorscale = None data.append({ 'x': list(x.round(1)), 'y': list(y.round(1)), #'z': list(z), 'type': 'scatter', 'mode': 'markers', 'name': 'multiplicity', 'showlegend': False, 'marker': { 'color': color, 'colorscale': colorscale, 'cmin': 0, 'cmax': flex.max(self.scene.multiplicities.data()), 'showscale': True, 'colorbar': { 'title': 'Multiplicity', 'titleside': 'right', }, 'line': { #'color': 'white', 'width': 0, }, 'symbol': 'circle', 'size': 5, }, }) text = { 'x': [x for x, y, text in self._text], 'y': [y for x, y, text in self._text], 'text': [text for x, y, text in self._text], 'mode': 'text', 'showlegend': False, 'textposition': 'top right', } data.append(text) shapes = [] for x0, y0, x1, y1 in self._lines: #color = 'rgb(%i,%i,%i)' %tuple(rgb * 264 for rgb in self._foreground) color = 'black' shapes.append({ 'type': 'line', 'x0': x0, 'y0': y0, 'x1': x1, 'y1': y1, 'layer': 'below', 'line': { 'color': color, 'width': 2, } }) d = { 'data': data, 'layout': { 'plot_bgcolor': 'rgb(%i,%i,%i)' % tuple(rgb * 264 for rgb in self._background), 'title': 'Multiplicity plot (%s=%s)' % (self.settings.slice_axis, self.settings.slice_index), 'shapes': shapes, 'hovermode': False, 'xaxis': { 'showgrid': False, 'zeroline': False, 'showline': False, 'ticks': '', 'showticklabels': False, }, 'yaxis': { 'autorange': 'reversed', 'showgrid': False, 'zeroline': False, 'showline': False, 'ticks': '', 'showticklabels': False, }, }, } return d