Annotation box over gridlines in plot
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ga97cad
am 7 Dez. 2021
Kommentiert: ga97cad
am 7 Dez. 2021
Hi everyone!
I have a problem with annotation boxes in a 2D plot. I would like to have the annotation box 'over' the grid lines, like it is usual for a legend. I have attached two different fiugres which illustrate my problem to this post. The file "plot_with_grid" has the gridlines over the text in the annotation box which looks a little unprofessional. Is there a way to put the annotation box 'over' the gridlines like the legend?
here's also a sniplet of the code which generates the plot
h=plot(160:10:1200,ft(160:10:1200),'-r');
ax=gca;
hold on
errorbar(x_fit,y_fit,err_y_fit,'ks');
errorbar(x_val,y_val,err_y_val,'bo');
plot(160:10:1200,ft_upper(160:10:1200),'m--');
plot(160:10:1200,ft_down(160:10:1200),'m--');
hold off
ax.XAxis.Limits=[150 1200];
ax.YAxis.Limits=[17 50];
ax.FontSize=12;
xtickangle(45);
%dim=[.68 .6 .3 .3];
dim=[.15 .02 .3 .3];
str={'$h_0$=50 $\mu$m','$T_R$ =20$^\circ$C','$v_w$=0.1 m/min'};
%str={'$h_0=$ $50$ $\mu m$','$T_R =$ $20^\circ C$','$v_w=0.1$ $m/min$'};
annotation('textbox',dim,'String',str,'FitBoxToText','on','Interpreter','latex');
xlabel('Line load $q_L$ in N/mm $\rightarrow$','Interpreter','latex')
ylabel('Thickness $h_{1}$ in $\mu$m $\rightarrow$','Interpreter','latex')
lg=legend ('$Regression$','$Parameterization$ $data$','$Validation$ $data$','$95\%$ $confidence$ $interval$','Interpreter','latex','Location','northeast')
ax.YGrid='off';
Thank you for your help and best regards
Lukas
0 Kommentare
Akzeptierte Antwort
Atsushi Ueno
am 7 Dez. 2021
You should add 'BackgroundColor','white' as argument of annotation function.
h=plot(0:10:1200,0:10:1200,'-r'); grid on; % as example
annotation('textbox',[.15 .02 .3 .3],'String',{'$h_0$=50 $\mu$m','$T_R$ =20$^\circ$C','$v_w$=0.1 m/min'}, ...
'FitBoxToText','on','Interpreter','latex','BackgroundColor','white'); % <<<< here
legend ('Regression');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!