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

3 次查看(过去 30 天)
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

请先登录,再进行评论。

回答(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