<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Bar plot customizations	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/bar-plot-customizations/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/bar-plot-customizations?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bar-plot-customizations</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Tue, 05 Sep 2017 12:13:09 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Cyril		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-413128</link>

		<dc:creator><![CDATA[Cyril]]></dc:creator>
		<pubDate>Tue, 05 Sep 2017 12:13:09 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-413128</guid>

					<description><![CDATA[Hi. I have a problem with making scatered bar graph in matlab.

I need to create graph where on X axis will be years from 2005 to 2016 and on Y axis will be another numbers.
If I use just simple number for example from 1 to 10 for X axis is working, but I need put years on X axis.

I use this example from web:
&lt;pre lang=&quot;matlab&quot;&gt;
measles = [38556 24472 14556 18060 19549 8122 28541 7880 3283 4135 7953 1884]&#039;;
mumps = [20178 23536 34561 37395 36072 32237 18597 9408 6005 6268 8963 13882]&#039;;
chickenPox = [37140 32169 37533 39103 33244 23269 16737 5411 3435 6052 12825 23332]&#039;;

% Create a stacked bar chart using the bar function
figure
bar(1:12, [measles mumps chickenPox], 0.5, &#039;stack&#039;)

% Adjust the axis limits
axis([0 13 0 100000])
set(gca, &#039;XTick&#039;, 1:12)

% Add title and axis labels
title(&#039;Childhood diseases by month&#039;)
xlabel(&#039;Month&#039;)
ylabel(&#039;Cases (in thousands)&#039;)

% Add a legend
legend(&#039;Measles&#039;, &#039;Mumps&#039;, &#039;Chicken pox&#039;) 
&lt;/pre&gt;

But then I repleaced nummbers for X axis (how you can see below), nad now is not working.
Some advice in this issue for me?

&lt;pre lang=&quot;matlab&quot;&gt;
% Create data for application of fertilizer in arable land
dusikate = [70147.6	84165.8	92217.6	73166.4	85068.2	90982.2	98787.2	110714.4 116029.5 111892.1]&#039;;
fosforecne = [15757.9 19187.6 19828.2 13866.1 12797.9 14982.2 18898 20306.7 22497.4 21286.5]&#039;;
draselne = [13698.8	15764.6	16232.1	9798.1 8002.1 10108.4 13038.3 14534.1 16366.4 15868.7]&#039;;

x = 2005:1:2016;

% Create a stacked bar chart using the bar function   
figure
bar(x,[dusikate fosforecne draselne], 0.8, &#039;stack&#039;)

% Adjust the axis limits
axis([50000 180000])
set(gca, &#039;XTick&#039;, x)
ax = gca; 
ax.YAxis.Exponent = 0;

% Add title and axis labels
title({&#039;Celková spotreba draselných, fosforečných a dusíkatých hnojív (v tonách) na&#039;;&#039;sledovanej výmere ornej pôdy na Slovensku v období rokov 2005/2006 - 2014/2015&#039;})
xlabel(&#039;sezóna (hospodársky rok&#039;)
ylabel(&#039;spotreba hnojív v tonách [t]&#039;)

% Add a legend
legend(&#039;dusikaté&#039;, &#039;fosforečné&#039;, &#039;draselné&#039;)
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hi. I have a problem with making scatered bar graph in matlab.</p>
<p>I need to create graph where on X axis will be years from 2005 to 2016 and on Y axis will be another numbers.<br />
If I use just simple number for example from 1 to 10 for X axis is working, but I need put years on X axis.</p>
<p>I use this example from web:</p>
<pre lang="matlab">
measles = [38556 24472 14556 18060 19549 8122 28541 7880 3283 4135 7953 1884]';
mumps = [20178 23536 34561 37395 36072 32237 18597 9408 6005 6268 8963 13882]';
chickenPox = [37140 32169 37533 39103 33244 23269 16737 5411 3435 6052 12825 23332]';

% Create a stacked bar chart using the bar function
figure
bar(1:12, [measles mumps chickenPox], 0.5, 'stack')

% Adjust the axis limits
axis([0 13 0 100000])
set(gca, 'XTick', 1:12)

% Add title and axis labels
title('Childhood diseases by month')
xlabel('Month')
ylabel('Cases (in thousands)')

% Add a legend
legend('Measles', 'Mumps', 'Chicken pox') 
</pre>
<p>But then I repleaced nummbers for X axis (how you can see below), nad now is not working.<br />
Some advice in this issue for me?</p>
<pre lang="matlab">
% Create data for application of fertilizer in arable land
dusikate = [70147.6	84165.8	92217.6	73166.4	85068.2	90982.2	98787.2	110714.4 116029.5 111892.1]';
fosforecne = [15757.9 19187.6 19828.2 13866.1 12797.9 14982.2 18898 20306.7 22497.4 21286.5]';
draselne = [13698.8	15764.6	16232.1	9798.1 8002.1 10108.4 13038.3 14534.1 16366.4 15868.7]';

x = 2005:1:2016;

% Create a stacked bar chart using the bar function   
figure
bar(x,[dusikate fosforecne draselne], 0.8, 'stack')

% Adjust the axis limits
axis([50000 180000])
set(gca, 'XTick', x)
ax = gca; 
ax.YAxis.Exponent = 0;

% Add title and axis labels
title({'Celková spotreba draselných, fosforečných a dusíkatých hnojív (v tonách) na';'sledovanej výmere ornej pôdy na Slovensku v období rokov 2005/2006 - 2014/2015'})
xlabel('sezóna (hospodársky rok')
ylabel('spotreba hnojív v tonách [t]')

% Add a legend
legend('dusikaté', 'fosforečné', 'draselné')
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: dgm		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-412166</link>

		<dc:creator><![CDATA[dgm]]></dc:creator>
		<pubDate>Fri, 18 Aug 2017 20:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-412166</guid>

					<description><![CDATA[Thanks for this solution.  In addition to needing to label the individual bars, I have floating point numbers as the labels at the tops of the bars.  Is there a way to center those labels over the bars instead of starting the text at the mid-point of each bar?]]></description>
			<content:encoded><![CDATA[<p>Thanks for this solution.  In addition to needing to label the individual bars, I have floating point numbers as the labels at the tops of the bars.  Is there a way to center those labels over the bars instead of starting the text at the mid-point of each bar?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-383268</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 17 Jul 2016 09:38:42 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-383268</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-382892&quot;&gt;NG Keerthy&lt;/a&gt;.

@NG - you will need to adapt the code in my post. This should not be too difficult: all the components are there, it&#039;s basically just switching between X-Y etc., so I am not going to spoon-feed the answer. If you cannot do this (or don&#039;t have time), then contact me by email for a short consulting.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-382892">NG Keerthy</a>.</p>
<p>@NG &#8211; you will need to adapt the code in my post. This should not be too difficult: all the components are there, it&#8217;s basically just switching between X-Y etc., so I am not going to spoon-feed the answer. If you cannot do this (or don&#8217;t have time), then contact me by email for a short consulting.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: NG Keerthy		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-382892</link>

		<dc:creator><![CDATA[NG Keerthy]]></dc:creator>
		<pubDate>Wed, 13 Jul 2016 11:53:55 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-382892</guid>

					<description><![CDATA[how to display the stack values for horizontal bar graph]]></description>
			<content:encoded><![CDATA[<p>how to display the stack values for horizontal bar graph</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: afaq		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-362706</link>

		<dc:creator><![CDATA[afaq]]></dc:creator>
		<pubDate>Sat, 28 Nov 2015 11:25:23 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-362706</guid>

					<description><![CDATA[Hi
I used the following code.
But I wanted to display the ranges of each stacked portion along its bar.
Please share if anyone knows how to display the ranges (limits of the each portion).

&lt;pre lang=&#039;matlab&#039;&gt;
Y = [5 1 2; 8 3 7; 9 6 8; 5 5 5; 4 2 3];  % sample data from bar example...
Z=cumsum(Y,2);                            % bar cumulative heights for positioning
X=repmat([1:5].&#039;,1,3);                    % x locations for each Y
bar(Y,&#039;stack&#039;)                            % base stacked bar
colormap(copper);                         % change color map
arrayfun(@(x,y,z) text(x,y,num2str(z), &#039;horizontalalign&#039;,&#039;center&#039;, &#039;verticalalign&#039;,&#039;top&#039;, &#039;color&#039;,&#039;w&#039;), X,Z,Y);

% write the labels for each subset
sumTotals = sum(Y,2);
sumTotals = sumTotals(~isnan(sumTotals));
labels = arrayfun(@num2str,sumTotals,&#039;uniform&#039;,false);
hText = text(1:size(Y,1), sumTotals, labels);
set(hText, &#039;VerticalAlignment&#039;,&#039;bottom&#039;, &#039;FontSize&#039;,8, &#039;Color&#039;,&#039;k&#039;);
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hi<br />
I used the following code.<br />
But I wanted to display the ranges of each stacked portion along its bar.<br />
Please share if anyone knows how to display the ranges (limits of the each portion).</p>
<pre lang='matlab'>
Y = [5 1 2; 8 3 7; 9 6 8; 5 5 5; 4 2 3];  % sample data from bar example...
Z=cumsum(Y,2);                            % bar cumulative heights for positioning
X=repmat([1:5].',1,3);                    % x locations for each Y
bar(Y,'stack')                            % base stacked bar
colormap(copper);                         % change color map
arrayfun(@(x,y,z) text(x,y,num2str(z), 'horizontalalign','center', 'verticalalign','top', 'color','w'), X,Z,Y);

% write the labels for each subset
sumTotals = sum(Y,2);
sumTotals = sumTotals(~isnan(sumTotals));
labels = arrayfun(@num2str,sumTotals,'uniform',false);
hText = text(1:size(Y,1), sumTotals, labels);
set(hText, 'VerticalAlignment','bottom', 'FontSize',8, 'Color','k');
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yaroslav		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-353929</link>

		<dc:creator><![CDATA[Yaroslav]]></dc:creator>
		<pubDate>Tue, 28 Jul 2015 05:59:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-353929</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-353719&quot;&gt;Michael Cappello&lt;/a&gt;.

So far, a smart solution is elusive; you can inspect Yair&#039;s &lt;a href=&quot;http://undocumentedmatlab.com/blog/bar-plot-customizations#comment-329872&quot; rel=&quot;nofollow&quot;&gt;previous comment&lt;/a&gt; for a detailed analysis.  In the meanwhile, you can try the old-school simple approach:
&lt;pre lang=&quot;matlab&quot;&gt;
N = 15;
hAxes = axes(&#039;NextPlot&#039;,&#039;add&#039;);
facecolors = jet(N);
for i = N : -1 : 1
    hBar(i) = bar(i, 2*i, &#039;FaceColor&#039;,facecolors(i,:));
end
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-353719">Michael Cappello</a>.</p>
<p>So far, a smart solution is elusive; you can inspect Yair&#8217;s <a href="http://undocumentedmatlab.com/blog/bar-plot-customizations#comment-329872" rel="nofollow">previous comment</a> for a detailed analysis.  In the meanwhile, you can try the old-school simple approach:</p>
<pre lang="matlab">
N = 15;
hAxes = axes('NextPlot','add');
facecolors = jet(N);
for i = N : -1 : 1
    hBar(i) = bar(i, 2*i, 'FaceColor',facecolors(i,:));
end
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michael Cappello		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-353719</link>

		<dc:creator><![CDATA[Michael Cappello]]></dc:creator>
		<pubDate>Sat, 25 Jul 2015 14:47:07 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-353719</guid>

					<description><![CDATA[Yair (or anyone),

I have an application where I need to color the bars individually, and have tried to figure out how to get the handles of the underlying patches or graphical objects. I am doing this in HG2.  Any ideas?

Thank you,
Mike]]></description>
			<content:encoded><![CDATA[<p>Yair (or anyone),</p>
<p>I have an application where I need to color the bars individually, and have tried to figure out how to get the handles of the underlying patches or graphical objects. I am doing this in HG2.  Any ideas?</p>
<p>Thank you,<br />
Mike</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jared		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-335276</link>

		<dc:creator><![CDATA[Jared]]></dc:creator>
		<pubDate>Sun, 26 Oct 2014 12:55:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-335276</guid>

					<description><![CDATA[Here&#039;s how to get multiple colors in a single Bar series. The ColorBinding can also be &#039;interpolated&#039;.

&lt;pre lang=&quot;matlab&quot;&gt;
hBar = bar(...);
hBar.Face.StripData = [];
vi = [1:4:N*4; 2:4:N*4; 4:4:N*4; 3:4:N*4];
hBar.Face.VertexIndices = uint32(vi(:)&#039;);
hBar.Face.ColorBinding = &#039;discrete&#039;;
hBar.Face.ColorData = ... % 4xN uint8
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to get multiple colors in a single Bar series. The ColorBinding can also be &#8216;interpolated&#8217;.</p>
<pre lang="matlab">
hBar = bar(...);
hBar.Face.StripData = [];
vi = [1:4:N*4; 2:4:N*4; 4:4:N*4; 3:4:N*4];
hBar.Face.VertexIndices = uint32(vi(:)');
hBar.Face.ColorBinding = 'discrete';
hBar.Face.ColorData = ... % 4xN uint8
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-329878</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 19 Aug 2014 11:21:50 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-329878</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-329876&quot;&gt;Sergey&lt;/a&gt;.

or use &lt;i&gt;&lt;b&gt;try/catch&lt;/b&gt;&lt;/i&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-329876">Sergey</a>.</p>
<p>or use <i><b>try/catch</b></i></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sergey		</title>
		<link>https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-329876</link>

		<dc:creator><![CDATA[Sergey]]></dc:creator>
		<pubDate>Tue, 19 Aug 2014 11:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4828#comment-329876</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-329872&quot;&gt;Yair Altman&lt;/a&gt;.

Thank you very much, Yair. Apparently I need to read more about the HG2 and use &quot;if-s&quot; in my code for compatibility.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/bar-plot-customizations#comment-329872">Yair Altman</a>.</p>
<p>Thank you very much, Yair. Apparently I need to read more about the HG2 and use &#8220;if-s&#8221; in my code for compatibility.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
