Effacer les filtres
Effacer les filtres

How to format notation to use "... x 10^-5..." instead of "...e..." in this figure

5 vues (au cours des 30 derniers jours)
T K
T K le 11 Mai 2023
attached figure

Réponse acceptée

Chunru
Chunru le 11 Mai 2023
Modifié(e) : Chunru le 11 Mai 2023
websave("Fig.fig", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1380189/Fig.fig")
ans = '/users/mss.system.h2XMFA/Fig.fig'
h = openfig("Fig.fig", "visible");
hlegend = get(gca, "legend");
hlegend.String = strrep(hlegend.String, 'e', ' x 10\^')
hlegend =
Legend (Dn= 2.6 x 10\^-05, Dn= 3.39 x 10\^-05, Dn= 4.4 x 10\^-05, Dn= 5.56 x 10\^-05) with properties: String: {'Dn= 2.6 x 10\^-05' 'Dn= 3.39 x 10\^-05' 'Dn= 4.4 x 10\^-05' 'Dn= 5.56 x 10\^-05'} Location: 'northeast' Orientation: 'vertical' FontSize: 9 Position: [0.5763 0.7440 0.3094 0.1560] Units: 'normalized' Show all properties

Plus de réponses (1)

Dyuman Joshi
Dyuman Joshi le 11 Mai 2023
%Random graph
syms x
fplot(jacobiP(1:4,4,4,x))
axis([-1 2 -5 5])
grid on
%Values to be displayed as the legend
arr = rand(4,1)*1e-4
arr = 4×1
1.0e-04 * 0.3941 0.0632 0.3042 0.5611
out=floor(log10(arr)); %take abs() of arr in case of negative values
str = compose('%f x 10^{%d}', arr./10.^out, out)
str = 4×1 cell array
{'3.941188 x 10^{-5}'} {'6.315990 x 10^{-6}'} {'3.042007 x 10^{-5}'} {'5.611243 x 10^{-5}'}
legend(str,'Location','best')

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by