def _make_histogram(data, axis_labels, nbins, barcolor): """Create a fig, ax instance and generate a histogram. :param data: np.array :param axis_labels: (tuple of str) (axis label, y axis label) :return: matplotlib fig, ax """ # axis_labels = ('Median Distance Between Adapters', 'Pre-Filter Reads') fig, ax = get_fig_axes_lpr() apply_histogram_data(ax, data, nbins, axis_labels=axis_labels, barcolor=barcolor) return fig, ax
def _make_histogram(datum, axis_labels, nbins, barcolor): """Create a fig, ax instance and generate a histogram. :param datum: np.array :param axis_labels: (tuple of str) (axis label, y axis label) :return: matplotlib fig, ax """ # axis_labels = ('Median Distance Between Adapters', 'Pre-Filter Reads') fig, ax = get_fig_axes_lpr() apply_histogram_data(ax, datum, nbins, axis_labels=axis_labels, barcolor=barcolor) return fig, ax
def _create_histogram(stats): """ Returns a fig,ax histogram plot for this reference :param stats: (ReferenceStats) """ numBins = 100 binSize = max(1, int(stats.maxbin / numBins)) # handle case where the coverage is zero. This prevents the histogram # construction from crashing with an index error. m = 1 if stats.maxbin == 0.0 else stats.maxbin bins = np.arange(0, m, binSize) fig, ax = get_fig_axes_lpr() apply_histogram_data(ax, stats.means, bins, ('Coverage', 'Reference Regions'), barcolor=Constants.COLOR_STEEL_BLUE_DARK, showEdges=False) return fig, ax
def _create_histogram(self, stats): """ Returns a fig,ax histogram plot for this reference :param stats: (ReferenceStats) """ numBins = 100 binSize = max(1, int(stats.maxbin / numBins)) # handle case where the coverage is zero. This prevents the histogram # construction from crashing with an index error. m = 1 if stats.maxbin == 0.0 else stats.maxbin bins = np.arange(0, m, binSize) fig, ax = get_fig_axes_lpr() xlabel = get_plot_xlabel(self.spec, Constants.PG_COVERAGE_HIST, Constants.P_COVERAGE_HIST) ylabel = get_plot_ylabel(self.spec, Constants.PG_COVERAGE_HIST, Constants.P_COVERAGE_HIST) apply_histogram_data(ax, stats.means, bins, (xlabel, ylabel), barcolor=Constants.COLOR_STEEL_BLUE_DARK, showEdges=False) return fig, ax
def test_save_histograms(self): """Save std histograms.""" tmpdir = tempfile.mkdtemp(prefix='pbreport_output') fig, ax = get_fig_axes_lpr() dump = os.path.join(tmpdir, 'dmp.data') log.debug('dmp file is {d}'.format(d=dump)) apply_histogram_data(ax, [1, 2, 3, 4, 5, 6], 2, axis_labels=('foo', 'bar'), barcolor='#505050', xlim=(0, 20000), data_file=dump) self.assertTrue(os.path.exists(dump)) log.info("Writing temp histogram to {t}".format(t=tmpdir)) save_figure_with_thumbnail(fig, os.path.join(tmpdir, 'foo.png')) self.assertTrue(os.path.exists(os.path.join(tmpdir, 'foo.png'))) self.assertTrue(os.path.exists(os.path.join(tmpdir, 'foo_thumb.png')))