plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -


i've plotted data points , fitted exponential curve between them using 'fit' in matlab. problem fit-function got fitted line wanted plot, markers on top of regular markers. solved problem plotting wanted markers on top of unwanted couldn't seen. problem. when want show legends dots in there. how can remove markers legend without removing fitted line since both of them hidden inside fit-function? can stop 'fit' plotting unwanted markers? so, want remove blue dot called 'hoff' in picture below.

enter image description here

you can leave out legend-entries manually leaving out handles of lines, dont want in legend. try this:

%if plot something, want showing in legend, save handle: h_line = plot(x,y) %you dont want show line? dont anything, plot it: plot(mymarker) %then set legend-> can add text legend-entries  %a cell-array   containing strings want show up: legend([h_line another_line],{'text1' 'text2'}) 

with example (see comments) came solution:

close x=[1:10]; y=x*0.5+0.1; ft = fittype('poly2');  f = fit(x', y',ft);  ha=plot(f) hold on hc=plot(x,y) hb=errorbar(x, y, x*0.1, 'squarek','markerfacecolor','k','markersize',5) hleg1 = legend([ha hc],{'hnh','ghg'}); 

-> splitting plot-command. hope helps...

the result should this:

enter image description here


Comments

Popular posts from this blog

android - Invite new users for my app using app notifications facebook -

html - CSS: Combine Texture and Color -

Need help in packaging app using TideSDK on Windows -