What command do i need after de hold off fuction to print the labels in my plot?

조회 수: 3 (최근 30일)
Ellen
Ellen 2023년 12월 2일
댓글: Ellen 2023년 12월 3일
kin_sector=[meteo.data.sector]';
figure(1)
fs=11;
set(gca,'FontSize', fs)
cc=jet(noy);
hold on
.........% I left the correct working part of the plot.
hold off
xlabel('wind direction')
ylabel('annual mean sectorial wind energy (MJ)')
title('1996 - 2022 Vlissingen')
axis([0.4 8.6 0 0.9])
set(gca,'xtick',1:1:8,'FontSize',fs)
set(gca,'XTickLabel',{'N','NE','E','SE','S','SW','W','NW'},'FontSize',fs)
box on
grid on
orient portrait
print -dpng -r400 windclimate_allyears.png
this is the last part of my code from aan older version of matlab. after hold off the script seems to stop. Do I need a special command in my matlab version? Or do I have to put the code for the labels etc at an other place in the script?
this is the plot that is printed but no labels
kind regards Ellen
  댓글 수: 3
Ellen
Ellen 2023년 12월 2일
이동: madhan ravi 2023년 12월 2일
that seems not to be the solution. Probably the erro lies in de plot code
hold on
for j=1:noy % divide by 1e6 to get energy in MJ
bar(1:nos,kin_sector(j,:)/1e6,'FaceColor','none','EdgeColor',cc(j,:),'LineWidth',1.5);
%for k=1:15
% sh=(k-8)*0.025;
%plot(1+sh:nos+sh,kin_sector(j,:)/1e6,'s','Color',cc(j,:),'MarkerFaceColor',cc(j,:),'MarkerSize',2);
%end
plot(1:nos,mean(kin_sector,1)/1e6,'k s','MarkerFaceColor','k','MarkerSize',12);
end
% highlight 1996 & 2015 & 2018
% year=1;
% plot([0.5:1:7.5], kin_sector(year,:)/1e6,'>','Color',cc(year,:),'MarkerFaceColor',cc(year,:),'MarkerSize',6) %
% year=20;
% plot([0.5:1:7.5], kin_sector(year,:)/1e6,'>','Color',cc(year,:),'MarkerFaceColor',cc(year,:),'MarkerSize',6) %
% year=23;
% plot([0.5:1:7.5], kin_sector(year,:)/1e6,'>','Color',cc(year,:),'MarkerFaceColor',cc(year,:),'MarkerSize',6) %
year=1;
plot(0.5:1:7.5, kin_sector(year,:)/1e6,'>','Color','k','MarkerFaceColor','k','MarkerSize',6) %
year=2;
plot(0.5:1:7.5, kin_sector(year,:)/1e6,'>','Color','k','MarkerFaceColor',[0.6 0.6 0.6],'MarkerSize',6) %
year=3;
plot(0.5:1:7.5, kin_sector(year,:)/1e6,'>','Color','k','MarkerFaceColor','w','MarkerSize',6) %
year=4;
plot(0.5:1:7.5, kin_sector(year,:)/1e6,'>','Color','k','MarkerFaceColor','r','MarkerSize',6) %
year=5;
plot(0.5:1:7.5, kin_sector(year,:)/1e6,'>','Color','k','MarkerFaceColor','r','MarkerSize',6) %
hold off
Ellen
Ellen 2023년 12월 2일
이동: madhan ravi 2023년 12월 2일
I attached the full file with the mat file it created.

댓글을 달려면 로그인하십시오.

답변 (1개)

VBBV
VBBV 2023년 12월 2일
print('-image','-dpng', 'windclimate_allyears.png')
Try using the OpenGL graphics rendering format as above. The version of Matlab you have probably used the vector format which can cause stray lines to appear and label issues in the plot
  댓글 수: 5
VBBV
VBBV 2023년 12월 3일
편집: VBBV 2023년 12월 3일
% axis([0.4 8.6 0 0.9)])
Comment the axis line since this limits the y-axis values always to 0.9.
The bar plot produces values which are greater than 0.9.
Ellen
Ellen 2023년 12월 3일
You mean I have to give 0.9 another value for example the 600 wich is te highest Y value in the former diagram?
I ll try that.
thks Ellen

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by