Saves a scatter plot of a visualization of W, the result from Poisson SE.
177059
def visualize_poisson_w(w, labels, filename, method='pca', figsize=(18,10), title='', **scatter_options):
    
    if method == 'pca':
        pca = PCA(2)
        r_dim_red = pca.fit_transform(w.T).T
    elif method == 'tsne':
        pass
    else:
        print("Method is not available. use 'pca' (default) or 'tsne'.")
        return
    visualize_dim_red(r_dim_red, labels, filename, figsize, title, **scatter_options)
1308434
def output_barplot(df, figformat, path, title=None, palette=None):
    """"""
    logging.info("Nanoplotter: Creating barplots for number of reads and total throughput.")
    read_count = Plot(path=path + "NanoComp_number_of_reads." + figformat,
                      title="Comparing number of reads")
    ax = sns.countplot(x="dataset",
                       data=df,
                       palette=palette)
    ax.set(ylabel='Number of reads',
           title=title or read_count.title)
    plt.xticks(rotation=30, ha='center')
    read_count.fig = ax.get_figure()
    read_count.save(format=figformat)
    plt.close("all")

    throughput_bases = Plot(path=path + "NanoComp_total_throughput." + figformat,
                            title="Comparing throughput in gigabases")
    if "aligned_lengths" in df:
        throughput = df.groupby('dataset')['aligned_lengths'].sum()
        ylabel = 'Total gigabase aligned'
    else:
        throughput = df.groupby('dataset')['lengths'].sum()
        ylabel = 'Total gigabase sequenced'
    ax = sns.barplot(x=list(throughput.index),
                     y=throughput / 1e9,
                     palette=palette,
                     order=df["dataset"].unique())
    ax.set(ylabel=ylabel,
           title=title or throughput_bases.title)
    plt.xticks(rotation=30, ha='center')
    throughput_bases.fig = ax.get_figure()
    throughput_bases.save(format=figformat)
    plt.close("all")
    return read_count, throughput_bases
840928
def scatter(h1: Histogram1D, ax: Axes, *, errors: bool = False, **kwargs):
    """"""
    show_stats = kwargs.pop("show_stats", False)
    show_values = kwargs.pop("show_values", False)
    density = kwargs.pop("density", False)
    cumulative = kwargs.pop("cumulative", False)
    value_format = kwargs.pop("value_format", None)
    text_kwargs = pop_kwargs_with_prefix("text_", kwargs)

    data = get_data(h1, cumulative=cumulative, density=density)

    if "cmap" in kwargs:
        cmap = _get_cmap(kwargs)
        _, cmap_data = _get_cmap_data(data, kwargs)
        kwargs["color"] = cmap(cmap_data)
    else:
        kwargs["color"] = kwargs.pop("color", "blue")

    _apply_xy_lims(ax, h1, data, kwargs)
    _add_ticks(ax, h1, kwargs)
    _add_labels(ax, h1, kwargs)

    if errors:
        err_data = get_err_data(h1, cumulative=cumulative, density=density)
        ax.errorbar(h1.bin_centers, data, yerr=err_data, fmt=kwargs.pop("fmt", "o"),
                    ecolor=kwargs.pop("ecolor", "black"), ms=0)
    ax.scatter(h1.bin_centers, data, **kwargs)

    if show_values:
        _add_values(ax, h1, data, value_format=value_format, **text_kwargs)
    if show_stats:
        _add_stats_box(h1, ax, stats=show_stats)
664257
void saveResults( List<List<NodeInfo>> graph ) {
		Grid g = foundGrids.grow();
		g.reset();

		g.columns = graph.get(0).size() + graph.get(1).size();
		g.rows = graph.size();

		for (int row = 0; row < g.rows; row++) {
			List<NodeInfo> list = graph.get(row);
			for (int i = 0; i < g.columns; i++) {
				if( (i%2) == (row%2))
					g.ellipses.add(list.get(i/2).ellipse );
				else
					g.ellipses.add(null);
			}
		}
	}
224720
def save_scan_plot(self, filename="scan.pdf",
                       img_format="pdf", coords=None):
        
        plt = self.get_scan_plot(coords)
        plt.savefig(filename, format=img_format)
411878
def plot_data(self, proj, ax):
        
        x, y = proj
        ax.scatter(self.ig.independent_data[x],
                   self.ig.dependent_data[y], c='b')
1366342
def _save_seaborn_chart(self, report, folderpath):
        
        if folderpath is None:
            if self.imgs_path is None:
                self.err(self._save_seaborn_chart,
                         "Please set a path where to save images: ds.imgs_path"
                         " = '/my/path'")
                return
            path = self.imgs_path
        else:
            path = folderpath
        path = path + "/" + report["slug"] + ".png"
        try:
            try:
                # print("*** TRY", report["seaborn_chart"].figure.show())
                fig = report["seaborn_chart"].figure
                fig.savefig(path)
            except Exception as e:
                try:
                    fig = report["seaborn_chart"]
                    fig.savefig(path)
                except Exception:
                    plot = report["seaborn_chart"]
                    plot = plot.get_figure()
                    plot.savefig(path)
        except Exception as e:
            self.err(e, self._save_seaborn_chart, "Can not save Seaborn chart")
            return
        if self.autoprint is True:
            self.ok("Seaborn chart writen to " + path)
743166
def plot_result(x_p, y_p, y_p_e, smoothed_data, smoothed_data_diff, filename=None):
    ''' 
    '''
    logging.info('Plot results')
    plt.close()

    p1 = plt.errorbar(x_p * analysis_configuration['vcal_calibration'], y_p, yerr=y_p_e, fmt='o')  # plot data with error bars
    p2, = plt.plot(x_p * analysis_configuration['vcal_calibration'], smoothed_data, '-r')  # plot smoothed data
    factor = np.amax(y_p) / np.amin(smoothed_data_diff) * 1.1
    p3, = plt.plot(x_p * analysis_configuration['vcal_calibration'], factor * smoothed_data_diff, '-', lw=2)  # plot differentiated data
    mpv_index = np.argmax(-analysis_utils.smooth_differentiation(x_p, y_p, weigths=1 / y_p_e, order=3, smoothness=analysis_configuration['smoothness'], derivation=1))
    p4, = plt.plot([x_p[mpv_index] * analysis_configuration['vcal_calibration'], x_p[mpv_index] * analysis_configuration['vcal_calibration']], [0, factor * smoothed_data_diff[mpv_index]], 'k-', lw=2)
    text = 'MPV ' + str(int(x_p[mpv_index] * analysis_configuration['vcal_calibration'])) + ' e'
    plt.text(1.01 * x_p[mpv_index] * analysis_configuration['vcal_calibration'], -10. * smoothed_data_diff[mpv_index], text, ha='left')
    plt.legend([p1, p2, p3, p4], ['data', 'smoothed spline', 'spline differentiation', text], prop={'size': 12}, loc=0)
    plt.title('\'Single hit cluster\'-occupancy for different pixel thresholds')
    plt.xlabel('Pixel threshold [e]')
    plt.ylabel('Single hit cluster occupancy [a.u.]')
    plt.ylim(0, np.amax(y_p) * 1.15)
    if filename is None:
        plt.show()
    else:
        filename.savefig(plt.gcf())
    return smoothed_data_diff
30649
def to_df(figure):
    
    dfs=[]
    for trace in figure['data']:
        if 'scatter' in trace['type']:
            try:
                if type(trace['x'][0])==float:
                    index=trace['x']
                else:
                    index=pd.to_datetime(trace['x'])
            except:
                index=trace['x']
            if 'marker' in trace:
                d={}
                if 'size' in trace['marker']:
                    size=trace['marker']['size']
                    if type(size)!=list:
                        size=[size]*len(index)
                    d['size']=size
                if 'text' in trace:
                    d['text']=trace['text']
                if 'name' in trace:
                    name=trace['name']
                    if type(name)!=list:
                        name=[name]*len(index)
                    d['categories']=name
                d['y']=trace['y']
                d['x']=trace['x']
                if 'z' in trace:
                    d['z']=trace['z']
                df=pd.DataFrame(d)
            else:
                df=pd.Series(trace['y'],index=index,name=trace['name'])
            dfs.append(df)
        elif trace['type'] in ('heatmap','surface'):
            df=pd.DataFrame(trace['z'].transpose(),index=trace['x'],columns=trace['y'])
            dfs.append(df)
        elif trace['type'] in ('box','histogram'):
            vals=trace['x'] if 'x' in trace else trace['y']
            df=pd.DataFrame({trace['name']:vals})
            dfs.append(df)
    if max(list(map(len,dfs)))==min(list(map(len,dfs))):
        if len(dfs)==1:
            return dfs[0]
        else:
            if type(dfs[0])==pd.core.series.Series:
                return pd.concat(dfs,axis=1)                
            if all(dfs[0].columns==dfs[1].columns):
                    return pd.concat(dfs,axis=0)
            else:
                return pd.concat(dfs,axis=1)
    else:
        try:
            return pd.concat(dfs)
        except:
            return dfs
1350850
def save_graph(graphdef):
    ''''''
    if graphdef.filename is None:
        if 'HOME' in os.environ:
            dname = os.path.join(os.environ['HOME'], '.mavproxy')
            if os.path.exists(dname):
                mp_util.mkdir_p(dname)
                graphdef.filename = os.path.join(dname, 'mavgraphs.xml')
        elif 'LOCALAPPDATA' in os.environ:
            dname = os.path.join(os.environ['LOCALAPPDATA'], 'MAVProxy')
            if os.path.exists(dname):
                mp_util.mkdir_p(dname)
                graphdef.filename = os.path.join(dname, 'mavgraphs.xml')
        else:
            graphdef.filename = 'mavgraphs.xml'
    if graphdef.filename is None:
        print("No file to save graph to")
        return
    try:
        graphs = load_graph_xml(open(graphdef.filename).read(), graphdef.filename, load_all=True)
    except Exception:
        graphs = []
    found_name = False
    for i in range(len(graphs)):
        if graphs[i].name == graphdef.name:
            graphs[i] = graphdef
            found_name = True
            break
    if not found_name:
        graphs.append(graphdef)
    pipe_console_input.send("Saving %u graphs to %s" % (len(graphs), graphdef.filename))
    f = open(graphdef.filename, "w")
    f.write("<graphs>\n\n")
    for g in graphs:
        f.write(" <graph name='%s'>\n" % g.name.strip())
        if g.description is None:
            g.description = ''
        f.write("  <description>%s</description>\n" % g.description.strip())
        for e in g.expressions:
            f.write("  <expression>%s</expression>\n" % e.strip())
        f.write(" </graph>\n\n")
    f.write("</graphs>\n")
    f.close()
1130878
def plot(self, data, w=800, h=420):
        """"""
        return HTML(
            self.iframe.format(
                source=self.render(
                    data=data, div_id="chart", head=self.head),
                w=w,
                h=h))
801845
public void saveCurrentPlot() {
    // TODO: exclude "do not export" layers!
    final SVGPlot currentPlot = svgCanvas.getPlot();
    if(currentPlot != null) {
      SVGSaveDialog.showSaveDialog(currentPlot, 512, 512);
    }
    else {
      LoggingUtil.warning("saveCurrentPlot() called without a visible plot!");
    }
  }
1237325
def _makeplot(self, ax, fig, data, zero_to_efermi=True,
                  vbm_cbm_marker=False, ymin=-6., ymax=6.,
                  height=None, width=None,
                  dos_plotter=None, dos_options=None, dos_label=None,
                  aspect=None):
        """"""
        # draw line at Fermi level if not zeroing to e-Fermi
        if not zero_to_efermi:
            ytick_color = rcParams['ytick.color']
            ef = self._bs.efermi
            ax.axhline(ef, color=ytick_color)

        # set x and y limits
        ax.set_xlim(0, data['distances'][-1][-1])
        if self._bs.is_metal() and not zero_to_efermi:
            ax.set_ylim(self._bs.efermi + ymin, self._bs.efermi + ymax)
        else:
            ax.set_ylim(ymin, ymax)

        if vbm_cbm_marker:
            for cbm in data['cbm']:
                ax.scatter(cbm[0], cbm[1], color='C2', marker='o', s=100)
            for vbm in data['vbm']:
                ax.scatter(vbm[0], vbm[1], color='C3', marker='o', s=100)

        if dos_plotter:
            ax = fig.axes[1]

            if not dos_options:
                dos_options = {}

            dos_options.update({'xmin': ymin, 'xmax': ymax})
            self._makedos(ax, dos_plotter, dos_options, dos_label=dos_label)
        else:
            # keep correct aspect ratio for axes based on canvas size
            x0, x1 = ax.get_xlim()
            y0, y1 = ax.get_ylim()
            if width is None:
                width = rcParams['figure.figsize'][0]
            if height is None:
                height = rcParams['figure.figsize'][1]

            if not aspect:
                aspect = height / width

            ax.set_aspect(aspect * ((x1 - x0) / (y1 - y0)))
605039
def save(self_or_cls, obj, basename, fmt='auto', key={}, info={}, options=None, **kwargs):
        
        if info or key:
            raise Exception('Renderer does not support saving metadata to file.')

        if isinstance(obj, (Plot, NdWidget)):
            plot = obj
        else:
            with StoreOptions.options(obj, options, **kwargs):
                plot = self_or_cls.get_plot(obj)

        if (fmt in list(self_or_cls.widgets.keys())+['auto']) and len(plot) > 1:
            with StoreOptions.options(obj, options, **kwargs):
                if isinstance(basename, basestring):
                    basename = basename+'.html'
                self_or_cls.export_widgets(plot, basename, fmt)
            return

        rendered = self_or_cls(plot, fmt)
        if rendered is None: return
        (data, info) = rendered
        encoded = self_or_cls.encode(rendered)
        prefix = self_or_cls._save_prefix(info['file-ext'])
        if prefix:
            encoded = prefix + encoded
        if isinstance(basename, (BytesIO, StringIO)):
            basename.write(encoded)
            basename.seek(0)
        else:
            filename ='%s.%s' % (basename, info['file-ext'])
            with open(filename, 'wb') as f:
                f.write(encoded)
274611
def correlation_plot(self, data):
        

        # CHECK: Add saved filename in result.json
        fig = plt.figure(Plot_Data.count)
        corr = data.corr()
        ax = sns.heatmap(corr)

        Plot_Data.count += 1
        return fig
709507
def scatter(data, color=None, point_size=2, f_tooltip=None):
    
    import warnings
    warnings.warn("deprecated, use geoplotlib.dot", DeprecationWarning)
    dot(data, color, point_size, f_tooltip)
918821
def save_html(out_file, plot_html):
    

    internal_open = False
    if type(out_file) == str:
        out_file = open(out_file, "w")
        internal_open = True
    out_file.write("<html><head><script>\n")

    # dump the js code
    bundle_path = os.path.join(os.path.split(__file__)[0], "resources", "bundle.js")
    with io.open(bundle_path, encoding="utf-8") as f:
        bundle_data = f.read()
    out_file.write(bundle_data)
    out_file.write("</script></head><body>\n")

    out_file.write(plot_html.data)

    out_file.write("</body></html>\n")

    if internal_open:
        out_file.close()