Paul, the order that you are calling the functions is incorrect. You need to create the histogram plot prior to assigning labels and a title. Also, you are using the xlabel, ylabel, and title functions with the wrong syntax. What you are using is basically creating a variable with the same name as the xlabel, ylabel, and title functions. See example below.
histogram(salmon_length,edges,'DisplayStyle','stairs');
% Now that a graphics object (histogram plot axes) exists, the following functions will target the
% active axes.
xlabel('Length')
ylabel('Count')
title('Histogram of salmon lengths') Answer from Allen on mathworks.com
Top answer 1 of 2
5
Your code should have worked. Try my boilerplate code snippet:
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
bar(grayLevels, pixelCount); % Plot it as a bar chart.
grid on;
title('Histogram of original image', 'FontSize', fontSize);
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('Pixel Count', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
2 of 2
1
This sometimes happens to me too. The problem is xlabel sometimes get stuck BEHIND the imhist colorbar at the bottom. To fix it you can use this instead (may need to play around with the values for your liking):
xlabel('grayscale range')
xl = get(gca,'XLabel');
set(xl,'Position',get(xl,'Position') - [0 60000 0])
And Image Analyst's solution would also work because it gets rid of the default bar at the bottom. Take your pick.
How could you write a function that returns a histogram with axis labels and title
Currently I have: which creates the graph with the axis and title labels but the data for the histogram doesn't show up on the histogram. pls help <3 ... Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/422233-how-could-you-write-a-fu... More on mathworks.com
Why are title and label not working on histogram?
I have two subplots, both containing histograms but I can't add a title or labels to both of them. Matlab tells me, that the value assigned to "title", "xlabel" and "ylabel" might be unused. But ... More on mathworks.com
plot - Figuring out where to add text in a MATLAB histogram - Stack Overflow
It does not interfere with the histogram. ... Because it isn't the title? There's already a title for the graph, and this is just some relevant data that will be useful when the plot is viewed as an image. ... @sundar Do you have to do it programmatically? You can do it very easily interactively through the matlab ... More on stackoverflow.com
Help with axes labels on histogram plot
Hello, I am simply trying to add labels to this histogram under the the middle of the columns and I am unable to figure out how to add for the other two columns. histogram(F) title('Distributi... More on mathworks.com
MathWorks
mathworks.com › matlab › graphics › graphics objects › graphics object properties
ScatterHistogramChart - Control scatter histogram chart appearance and behavior - MATLAB
If you specify the label as a categorical array, MATLAB uses the values in the array, not the categories. Example: s = scatterhistogram(__,'YLabel','My Label') ... Legend title, specified as a character vector, string array, cell array of character vectors, or categorical array.
MathWorks
mathworks.com › matlabcentral › answers › 422233-how-could-you-write-a-function-that-returns-a-histogram-with-axis-labels-and-title
How could you write a function that returns a histogram with axis labels and title - MATLAB Answers - MATLAB Central
October 4, 2018 - NB2: hist has been deprecated; strongly urge to consider using histogram instead unless you are forced to use a release prior to R2014b.
MathWorks
mathworks.com › matlabcentral › answers › 1712135-why-are-title-and-label-not-working-on-histogram
Why are title and label not working on histogram? - MATLAB Answers - MATLAB Central
May 5, 2022 - I have two subplots, both containing histograms but I can't add a title or labels to both of them. Matlab tells me, that the value assigned to "title", "xlabel" and "ylabel" might be unused. But ...
MathWorks
mathworks.com › statistics and machine learning toolbox › industrial statistics › statistical process control
histfit - Histogram with a distribution fit - MATLAB
Create a histogram with a normal ... with 10 bins. In the right subplot, plot a histogram with 5 bins. Add a title to each plot by passing the corresponding Axes object to the title function....
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › data distribution plots
Histogram - Histogram plot - MATLAB
Histograms are a type of bar plot that group data into bins.
MathWorks
mathworks.com › videos › using-hist-and-bar-to-customize-your-histograms-97279.html
How to Customize Histograms in MATLAB - MATLAB
First, we’ll modify the y-axis ticks to display percentages, and adjust the count to match. And as with any good graph, we should add a title, and label the axes. To learn more about histograms and other customizations for MATLAB graphs, check out the links in the description.
Published: February 4, 2021
Undocumented Matlab
undocumentedmatlab.com › articles › customizing-histogram-plots
Customizing histogram plots - Undocumented Matlab
January 17, 2018 - hAxes = hBar.Parent; xtickformat(hAxes, '%g%%'); title(hAxes, 'Distribution of total returns (monthly %)'); set(hAxes, 'FontSize',8, 'Box','off') Improved histogram bar plot So far nothing undocumented. Note that the xtickformat/ytickformat functions were only introduced in R2016b – for earlier Matlab releases see this post (which does rely on undocumented aspects).
MathWorks
mathworks.com › matlabcentral › answers › 2043367-help-with-axes-labels-on-histogram-plot
Help with axes labels on histogram plot - MATLAB Answers - MATLAB Central
November 6, 2023 - https://www.mathworks.com/matl... to figure out how to add for the other two columns. histogram(F) title('Distribution of Traction Forces') xticks(0.0135) xticklabels("0.149") yticks(1:5) Dyuman Joshi on 6 Nov 2023 ...
MathWorks
mathworks.com › matlabcentral › answers › 2158655-help-with-histogram-plot
Help with Histogram Plot - MATLAB Answers - MATLAB Central
October 9, 2024 - title('Histogram', 'FontSize', fontSize); xlabel('Average Power', 'FontSize', fontSize); ylabel('Count', 'FontSize', fontSize); Mahnoor on 10 Oct 2024 · Share · Translate · Share a link to this comment · https://www.mathworks.com/matlab...
Tutorbin
tutorbin.com › home › education › how to plot a histogram in matlab: a step-by-step guide
How to Plot a Histogram in MATLAB: A Step-by-Step Guide
October 15, 2024 - Use the command histogram(data) to create a basic histogram, where data is your variable. You can customize the number of bins, colors, and labels for better visualization. MATLAB’s flexibility allows for adjustments in bin widths and the addition of titles and axis labels, making it an essential ...
Stack Overflow
stackoverflow.com › questions › 47760638 › matlab-histogram-plotting-setting-specific-x-axis-label
matlab histogram plotting: setting specific x-axis label - Stack Overflow
cd C:\User\Aisk_000\Desktop\A\NC\Subjects\2414A\ A = dlmread('data.txt'); % Upper tri, removing 0's and repeated values % Histogram plots a = triu(A) a=a' a(a==0) = [] aA = a histogram(aA) title('Normal count distribution')
MathWorks
mathworks.com › matlabcentral › answers › 15725-histogram
Histogram - MATLAB Answers - MATLAB Central
September 13, 2011 - title('Histogram of Y', 'fontSize', fontSize); % Enlarge figure to full screen. set(gcf, 'Position', get(0,'Screensize')); Irene on 13 Sep 2011 · Share · Translate · Share a link to this comment · https://www.mathworks.com/matlabcentral...
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › data distribution plots
scatterhistogram - Create scatter plot with histograms - MATLAB
If you specify the title as a categorical array, MATLAB® uses the values in the array, not the categories. Example: s = scatterhistogram(__,'Title','My Title Text') ... Number of histogram bins, specified as a positive integer scalar, 2-by-1 positive integer vector, or 2-by-n positive integer ...
MathWorks
mathworks.com › matlabcentral › answers › 625868-manually-adjust-labels-on-axis-of-plot-histogram
Manually adjust labels on axis of plot (histogram) - MATLAB Answers - MATLAB Central
October 25, 2020 - Because I don't want to completely remove the outliers in my dataset, I manually changed the outlier values to some capped value and created the histogram normally. However, now I want to change the x-axis label for the first column, and last column to show that they might contain outliers. For example, instead of "5", which is generated automatically, it should be "<5". Is there a way to do this? Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/625868-manually-adjust-labels-on-axis-of-plot-histogram#answer_524318