5
$\begingroup$

I am using the Plot function in a usual way. I use Mathematica 9.0.1.0 in English (I do not know if it is available in other languages, but I do not mind), and as a result of that, the numbers that appear in the frame tick labels use dots as decimal markers.

I need all numbers in the plot to be shown with a comma as a decimal marker. Is that possible?

Here you have a MWE —nothing special:

Plot[Sin[x], {x, 0, 10}, PlotRange -> Automatic, Frame -> True, 
 Axes -> False, AspectRatio -> 1/GoldenRatio, ImageSize -> 600, 
 Frame -> True, FrameTicks -> Automatic, 
 LabelStyle -> Directive[FontFamily -> "Calibri", FontSize -> 12]]

This is what I get:

Minimum Working Example

This is a minor issue, as I can export the image and change its labels outside Mathematica, but in case I would like to do this inside Mathematica, how could I get it?

ADDITIONAL INFORMATION:

I've tried it by using $Language = "Spanish", with no success.

$\endgroup$
1
  • 1
    $\begingroup$ LabelStyle -> Directive[FontFamily -> "Calibri", FontSize -> 12, NumberPoint -> ","]? $\endgroup$
    – kglr
    Jul 8, 2014 at 17:15

3 Answers 3

7
$\begingroup$

You can also use the option NumberPoint->"," as a sub-option in LabelStyle:

Plot[Sin[x], {x, 0, 10}, PlotRange -> Automatic, Frame -> True, 
    Axes -> False, AspectRatio -> 1/GoldenRatio, ImageSize -> 600, 
    Frame -> True, FrameTicks -> Automatic, 
LabelStyle -> Directive[FontFamily -> "Calibri", FontSize -> 20, Red, NumberPoint -> ","]]

enter image description here

Or use BaseStyle -> (NumberPoint -> ","):

 Plot[Sin[x], {x, 0, 10}, PlotRange -> Automatic, Frame -> True, 
    Axes -> False, AspectRatio -> 1/GoldenRatio, ImageSize -> 600, 
    Frame -> True, FrameTicks -> Automatic, 
    BaseStyle -> (NumberPoint -> ","),
    LabelStyle -> Directive[FontFamily -> "Calibri", FontSize -> 20, Red]]

 (* same picture *)
$\endgroup$
2
  • $\begingroup$ I just found the same solution at the same time! Thank you! $\endgroup$
    – Vicent
    Jul 8, 2014 at 17:26
  • 1
    $\begingroup$ @Vicent, "Great minds ..." / Mr.Wizard :) Welcome to MMMSE. $\endgroup$
    – kglr
    Jul 8, 2014 at 17:34
4
$\begingroup$

First, you can use Style:

Style[
 Plot[Sin[x], {x, 0, 10}, PlotRange -> Automatic, Frame -> True, 
  Axes -> False, AspectRatio -> 1/GoldenRatio, ImageSize -> 600, 
  Frame -> True, FrameTicks -> Automatic, 
  LabelStyle -> Directive[FontFamily -> "Calibri", FontSize -> 12]],
 NumberPoint -> ","]

enter image description here

Second, you can set it globally in Preferences > Appearance > Numbers > Formatting.

Third, you can select the output cell and use the Options Inspector to set the NumberPoint option for the cell.

$\endgroup$
5
  • $\begingroup$ OK! Thanks! In fact, I have just found the answer at the same time. This is an alternative, putting NumberPoint within the LabelStyleoption: Plot[Sin[x], {x, 0, 10}, PlotRange -> Automatic, Frame -> True, Axes -> False, AspectRatio -> 1/GoldenRatio, ImageSize -> 600, Frame -> True, FrameTicks -> Automatic, LabelStyle -> Directive[FontFamily -> "Calibri", FontSize -> 12, NumberPoint -> ","]] $\endgroup$
    – Vicent
    Jul 8, 2014 at 17:19
  • $\begingroup$ @Vincent Cool. I didn't try LabelStyle. You can put that in your own answer. Some other users might look only at the answers and not at the comments. $\endgroup$
    – Michael E2
    Jul 8, 2014 at 17:24
  • $\begingroup$ Another user gave the same answer than me. If you don't mind, I am going to give him the "mark". $\endgroup$
    – Vicent
    Jul 8, 2014 at 17:28
  • 2
    $\begingroup$ @Vicent No problem. Actually, it's good practice to wait (at least a few hours) before accepting. You encourage more answers that way, and sometimes the best one is not the first one. $\endgroup$
    – Michael E2
    Jul 8, 2014 at 17:30
  • $\begingroup$ I'm including this to BaseStyle :) $\endgroup$
    – Kuba
    Jul 8, 2014 at 18:40
2
$\begingroup$

To apply the comma to several plots, resp. to any output:

$Post = Style[#, NumberPoint -> ","] &

Grid[{Plot[#@x, {x, 0, Pi}] & /@ {Cos, Sin, Tanh}}]

enter image description here

$Post=. (* Reset *)

You can customize the NumberPoint also via Option Inspector (Menu "Format")

$\endgroup$
1
  • $\begingroup$ Wow, thank you! $\endgroup$
    – Vicent
    Jul 8, 2014 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.