4
$\begingroup$

I know I can manipulate ticks:

 Plot[PDF[NormalDistribution[0, 1.5], x], {x, -7, 7}, 
   Ticks -> {{
     {-6, "-6σ"}, {-5, "-5σ"}, {-4, "-4σ"}, {-3, "-3σ"}, {-2, "-2σ"}, {-1, "-σ"}, 
     {1, "σ"}, {2, "2σ"}, {3, "3σ"}, {4, "4σ"}, {5, "5σ"}, {6, "6σ"}
 }}]

But the ticks disappear when I add Frame -> True. What am I doing wrong?

$\endgroup$
0

1 Answer 1

8
$\begingroup$

Nothing wrong as such... only for Frame you need the FrameTicks option (to add some spice see another way to get your ticks):

xticks = {#, StringReplace[ToString[# σ], " " -> ""]} & /@Range[-6, 6];

Plot[PDF[NormalDistribution[0, 1.5], x], {x, -7, 7}, 
 FrameTicks -> {{Automatic, None}, {xticks, xticks}}, Frame -> True]

Mathematica graphics

$\endgroup$
2
  • 1
    $\begingroup$ Typographic note. I suggest replacing StringReplace[ToString[# σ], " " -> ""] with StringReplace[ToString[# σ], " " -> "\[VeryThinSpace]"]. The difference is subtle, but inserting a very-thin-space really makes the tick labels look better. $\endgroup$
    – m_goldberg
    Commented Sep 22, 2013 at 8:51
  • $\begingroup$ @m_goldberg agreed - I just wanted to reproduce the OP´s ticks 1:1. Without that, generating the ticks could be done more straightforward, too. $\endgroup$
    – Yves Klett
    Commented Sep 22, 2013 at 8:54