Hi All,
I did something that was rather unfortunate when scouring code in mathworks, while trying to understand what some code did, I was typing it into my command line a while ago. In the process it changed my default coloring of the background of my figure (which I promptly fixed), and global text color in matlab.
This is a current example of the figure is the png attachment 'Alexa_t_AllCells.png'. and the 'XandYColorChange.png' is an example of what I am looking for on a global scale. My code for making the figure is rather simple: see below.
figure
heatmap(log10(T_Alexaheat), table2cell(U_3), table2cell(U_3), ...
'%0.2f', 'TickAngle', 45, 'Colormap', redblue(30), ...
'Colorbar', true)
title('Log 10 Relationships of Median T_{1/2} Alexa Note: (x/y)')
%% this is for the second picture %%
ax = gca;
ax.XColor = 'k';
ax.YColor = 'k';
I figured a simple
set(groot, 'defaultFontColor' or 'defaultTextColor', 'k')
or
reset(gcf)
would get me to what I need, but that doesn't work. The second picture is not correct either, as I need the color bar and title to be readable, and I do not want to have to repeat the same code for every figure I create from hereon.
How does one fix this? (note that groot, defaultTextColor, 'k' will only cause the title to become black, not the axes nor the color bar follow suite)
Thanks,
Nick

 Réponse acceptée

Steven Lord
Steven Lord le 8 Mai 2023

0 votes

See the "Remove Default Values" or "Set Properties to Factory-Defined Values" sections on this documentation page.

3 commentaires

Nicholas Scott
Nicholas Scott le 8 Mai 2023
Modifié(e) : Nicholas Scott le 8 Mai 2023
I already looked at this page (it is where I got the thought to set groot), and unfortunately could not discern what to do. Hence coming here.
Is there a quick way to restore all figure properties to default?
I just tried get(groot, 'factory') and there are a ton of entries. I don't know if what I accidentally changed was under a specific object type or not (I'm relatively novice to Matlab).
I also tried get(groot,'factoryImage') and get(groot,'factoryFigure'), and did not see anything that explicity had to do with text/font color so I definitely would love a little extra help!
The simplest way to reset the figure properties is to restart MATLAB, especially if you've changed a lot of property default values (which it sounds like you have.)
If that's not an option, try scrolling back in the Command History looking for set calls.
If that too isn't an option, you should probably look for default axes properties set on either groot or the current figure.
get(groot, 'defaultaxes')
ans = struct with no fields.
get(gcf, 'defaultaxes')
ans = []
Nicholas Scott
Nicholas Scott le 8 Mai 2023
excellent. Thank you! I wasn't aware that restarting matlab restored factory settings! Thank goodness. I rarely restart matlab, so I didn't know that was a quick fix! That worked! Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange

Produits

Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by