MATLAB: How do you turn off a polar grid while retaining a title

gridpolartitle

Here is a slice of my longer code:
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
theta = pi/2 : 2*pi/3 : 2*pi + pi/2;
r = ones(1,length(theta));
myline = polar(theta, r); title('Triangle')
%%
set(gcf,'Color','w');
set(0,'Showhiddenhandles','on')
extrastuff = setdiff(get(gca,'children'),myline);
delete(extrastuff)
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
I grabbed the second portion of code online to get rid of the polar axis, but it destroyed my title as well. Please help, thanks. 🙂

Best Answer

If all you want is the triangle and the title, then this will work:
theta = pi/2 : 2*pi/3 : 2*pi + pi/2;
r = ones(1,length(theta));
myline = polar(theta, r); ht = title('Triangle');
set(gcf,'Color','w');
set(0,'Showhiddenhandles','on')
extrastuff = setdiff(get(gca,'children'),[myline ht]);
delete(extrastuff)
Notice that what I did was to get the handle of the title, and add that handle to the list of ones not to delete (in the second argument of your setdiff command).