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

16 visualizaciones (últimos 30 días)
attached figure

Respuesta aceptada

Chunru
Chunru el 11 de Mayo de 2023
Editada: Chunru el 11 de Mayo de 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

Más respuestas (1)

Dyuman Joshi
Dyuman Joshi el 11 de Mayo de 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')

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by