how to bold only one axis?
Mostrar comentarios más antiguos
I am trying to make the blue y-axis on the right bold like the lines it is referencing, and for the life of me cannot figure out how without bolding the whole box. any help would be appreciated. my apologies for the long code:
clear all;clc;close all;
%enter data
CA1=[138986 123678 125128 118552 115738 134278];
FL1=[48069 55599 56687 47862 35900 32190];
NY1=[62601 61067 63445 77430 88250 89503];
CA2=[0.651 0.589 0.595 0.616 0.637 0.682];
FL2=[0.573 0.607 0.633 0.589 0.474 0.468];
NY2=[0.085 0.059 0.058 0.054 0.046 0.051];
x=2007:2:2017;
f1=figure(1);
left_color = [0 0 0];
right_color = [0 0 1];
set(f1,'defaultAxesColorOrder',[left_color; right_color]);
yyaxis right
%make axis bold set(gca,'linewidth',2)
plot(x,CA2,'b','LineWidth',2)
hold on
plot(x,NY2,'b--','LineWidth',2)
plot(x,FL2,'b:','LineWidth',2)
ylabel('Percent Unsheltered')
set(get(gca,'YLabel'),'Rotation',-90)
yyaxis left
b=bar(x,transpose([CA1/1000;NY1/1000;FL1/1000]));
b(1).FaceColor = '0.9294 0.6902 0.1294';
b(2).FaceColor = '0.9294 0.6000 0.5020';
b(3).FaceColor = '1.0000 1.0000 0.7020';
ylabel('Homeless Population (Thousands)')
ylim([0 150])
%line([2006.1 2006.1],[0 150],'Color','k','LineWidth',2)
% line([2010 2010],[0 150],'Color','k','LineWidth',2)
annotation('doublearrow',[0.14 0.31],[0.7 0.7],'LineWidth',1)
%gray box
annotation('rectangle',[0.13 0.11 0.193 0.81],'FaceColor',[0.6 0.6 0.6],'EdgeColor', 'none','FaceAlpha',0.2)
text(2007.15,115,'Recession')
%str = {'CA -','NY --','FL ..'};
%annotation('textbox',[0.57 0.55 0.2 0.2],'String',str,'FitBoxToText','on')
%legend
h1=plot([1:10],'Color','b','DisplayName','This one');hold on;
h2=plot([1:2:10],'Color','b','DisplayName','This two');
h3=plot([1:3:10],'Color','b','DisplayName','This three');
legend([h1 h2 h3],{'\color{blue} CA','\color{blue} FL','\color{blue} NY'})
legend boxoff % Hides the legend's axes (legend border and background)
text(2006.42,141,'CA')
text(2006.9,66,'NY')
text(2007.35,51,'FL')
text(2008.42,126,'CA')
text(2008.9,64,'NY')
text(2009.35,59,'FL')
text(2010.42,128,'CA')
text(2010.9,66,'NY')
text(2011.35,59,'FL')
text(2012.42,121,'CA')
text(2012.9,80,'NY')
text(2013.35,51,'FL')
text(2014.42,118,'CA')
text(2014.9,91,'NY')
text(2015.35,39,'FL')
text(2016.42,136.5,'CA')
text(2016.9,92,'NY')
text(2017.35,35,'FL')
xlim([2006 2018])
xlabel('year');
xticks([2007 2009 2011 2013 2015 2017])
%white background
set(gcf,'color','w');
%window size
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 .5 .5]);
%turn on grid lines
set(gca,'XGrid','off')
set(gca,'YGrid','on')
title('Largest Homeless Populations 2007-2017', 'fontsize', 18);
Respuesta aceptada
Más respuestas (1)
Alfonso
el 10 de Jun. de 2018
Look at this example:
% Only put in bold X axis
plot(randn(100,1));
title('X axis in bold');
xlabel('X axis','fontweight','bold');
% Only put in bold Y axis
plot(randn(100,1));
title('Y axis in bold');
ylabel('Y axis','fontweight','bold');
1 comentario
Minka Califf
el 10 de Jun. de 2018
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
