Borrar filtros
Borrar filtros

Removing unwanted data from a Histogram

17 visualizaciones (últimos 30 días)
pratapaneni Chetan
pratapaneni Chetan el 23 de Sept. de 2021
Comentada: pratapaneni Chetan el 24 de Sept. de 2021
In the given histogram below, I want to remove all the data thats below 4000 on the Y axis. How can this be done?
Thanks in advance :)

Respuesta aceptada

Image Analyst
Image Analyst el 24 de Sept. de 2021
Here is a full demo. Attach your data or histogram if you need more help.
% Demo by Image Analyst.
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
% str = "MathWorks was founded in 198.4. Patterns were 1st introduced in R2020b.";
% pat = digitsPattern;
% % pat = lettersPattern;
% year = extract(str,pat)
data = 10 + 5 * randn(1000000, 1);
subplot(2, 1, 1)
counts = histcounts(data); % Get histogram.
bar(counts, 1);
grid on;
title('Original -- All Bins', 'FontSize', fontSize);
xlabel('Value', 'FontSize', fontSize);
ylabel('Counts', 'FontSize', fontSize);
yline(4000, 'Color', 'r', 'LineWidth', 2);
indexes = counts < 4000; % Find out what bins have less than 4000 counts.
counts(indexes) = 0; % Set those bins to zero.
subplot(2, 1, 2)
bar(counts, 1);
grid on;
title('Now With Bins Below 4000 Zeroed Out', 'FontSize', fontSize);
xlabel('Value', 'FontSize', fontSize);
ylabel('Counts', 'FontSize', fontSize);
yline(4000, 'Color', 'r', 'LineWidth', 2);
fprintf('Done running %s.m\n', mfilename);

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by