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

3 Ansichten (letzte 30 Tage)
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 Kommentare
Ellen
Ellen am 2 Dez. 2023
Verschoben: madhan ravi am 2 Dez. 2023
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 am 2 Dez. 2023
Verschoben: madhan ravi am 2 Dez. 2023
I attached the full file with the mat file it created.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

VBBV
VBBV am 2 Dez. 2023
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 Kommentare
VBBV
VBBV am 3 Dez. 2023
Bearbeitet: VBBV am 3 Dez. 2023
% 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 am 3 Dez. 2023
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by