# How to set PlotLegend Number Format

Is there any way to make Mathematica to show the legend labels like a real number rather than in fraction form? I read the BarLegend options, however they are just related to graphics so I just set the PlotLegend to Automatic.

A sample of legend I have problem with is shown below:

MatrixPlot[Rm1,
ColorFunction -> ColorData["GrayTones"],
ImageSize -> 200,
PlotLegends -> Automatic] • Can you please accept answers to the questions that you've asked so far, if they've actually been helpful (you can accept only one per question)? Accepting it indicates to other users that a particular answer was indeed helpful to you and also rewards the answerer with +15, as a token of appreciation for having helped write an accepted answer. – rm -rf Apr 7 '13 at 1:41

This should do it:

plot = MatrixPlot[Rm1, ColorFunction -> ColorData["GrayTones"],
ImageSize -> 200, PlotLegends -> Automatic];
MapAt[N, plot, 2] • ha ha! simple and effective! Thanks Brett. – K-1 Apr 6 '13 at 9:09

You can also do this way:

plot = MatrixPlot[RandomReal[{0, 1}, {10, 10}],
ColorFunction -> ColorData["GrayTones"], ImageSize -> 200,
PlotLegends -> Automatic];
plot /. Rational[x_, y_] :> ScientificForm[N[x/y]] Or combine it with Brett's answer so that it works both for large and small numbers:

plot = MatrixPlot[100000000 RandomReal[{0, 1}, {10, 10}],
ColorFunction -> ColorData["GrayTones"], ImageSize -> 200,
PlotLegends -> Automatic];
MapAt[N, plot /. Rational[x_, y_] :> ScientificForm[N[x/y]], 2] plot = MatrixPlot[0.00000001 RandomReal[{0, 1}, {10, 10}],
ColorFunction -> ColorData["GrayTones"], ImageSize -> 200,
PlotLegends -> Automatic];

MapAt[N, plot /. Rational[x_, y_] :> ScientificForm[N[x/y]], 2] 