# Perform simple reformatting of the ticks in a plot?

**URL:** <https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [February 15, 2017, 4:59pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024 "2017-02-15T16:59:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ms](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ms/32/13335_2.png) [@ms](https://community.wolfram.com/u/ms)\
**Post date:** [February 15, 2017, 4:59pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/1 "2017-02-15T16:59:49Z")

</div>

I often deal with graphs involving large dollar amounts over time. Mathematica will generally format Y-axis ticks as scientific numbers `{1.0x10^6, 1.2x10^6 . . . etc.}`.

So for example,

```
mydata = EventSeries@
  Table[{DatePlus[DateObject[{2010, 1, 1}], {x, "Month"}], 
    10^6 RandomReal[{1, 2}]}, {x, 0, 20}];

myplot = DateListPlot[mydata] (* produces a Y-axis in scientific notation, which is not what I want *)

```

I’m happy to let Mathematica pick where the ticks go, but I want to change the formatting to `{$1.0MM, $1.2MM . . . etc.}`.

Is there an elegant way to do this?

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [February 15, 2017, 5:58pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/2 "2017-02-15T17:58:01Z")

</div>

Manually specify the ticks:

```
mydata=EventSeries@Table[{DatePlus[DateObject[{2010,1,1}],{x,"Month"}],10^6 RandomReal[{1,2}]},{x,0,20}];
rightticks=leftticks = {# 10^6,"$ "<>ToString[NumberForm[#,{\[Infinity],1}]]<>"MM"}&/@Range[1,2,0.1];
rightticks[[All,2]]="";
myplot=DateListPlot[mydata,FrameTicks->{{leftticks,rightticks},{Automatic,Automatic}}]

```

 ![ScreenShot2017-02-15at18.57.12.png](https://global.discourse-cdn.com/wolfram/original/3X/b/7/b72efc1f242d9752ad502029d1ab238e95d28120.png)

Using **FindDivisions** you could automate the position of the ticks. Which is also what internally is used by the various plot functionalities…

---

<div class="post-metadata">

**Author:** ![ms](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ms/32/13335_2.png) [@ms](https://community.wolfram.com/u/ms)\
**Post date:** [February 15, 2017, 9:14pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/3 "2017-02-15T21:14:22Z")

</div>

I generate a lot of these graphs with varying Y-axes so I would greatly prefer not to have to set the upper and lower bounds by hand. Is there some mechanism that lets Mathematica pick the placement but lets me pick the formatting?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [February 16, 2017, 7:17am UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/4 "2017-02-16T07:17:52Z")

</div>

You can intercept the automatically generated ticks and then tweak them, for example with a replacement rule. Something like this:

```
myPlot = Plot[Sin[x], {x, 0, Pi}]
tks = Ticks /. AbsoluteOptions[myPlot, Ticks];
Show[myPlot, 
 Ticks -> {tks[[1]] /. {x_Real, tk_Real, rest___} :> {x, 
      Rationalize[tk/Pi, Pi/10000] Pi, rest}, tks[[2]]}]

```

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [February 16, 2017, 9:37am UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/5 "2017-02-16T09:37:07Z")

</div>

Currently only semi-manually, like Gianluca proposed…

---

<div class="post-metadata">

**Author:** ![ms](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ms/32/13335_2.png) [@ms](https://community.wolfram.com/u/ms)\
**Post date:** [February 16, 2017, 12:06pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/6 "2017-02-16T12:06:06Z")

</div>

This doesn’t work with DateListPlots.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [February 16, 2017, 3:34pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/7 "2017-02-16T15:34:39Z")

</div>

Hmm, `AbsoluteOptions` gives useless result with `DateListPlot`. A workaround is to get the ticks from a `ListPlot` and to feed them to `DateListPlot`:

```
data = {{{2017, 1, 1}, 1}, {{2017, 2, 1}, 2}};
nonDatePlot = ListPlot[data[[All, -1]]];
tks = Ticks /. AbsoluteOptions[nonDatePlot];
modifiedTks = 
  tks[[2]] /. {x_Real, tk_Real, rest___} :> {x, 
     Rationalize[tk/Pi, Pi/10000] Pi, rest};
DateListPlot[data, 
 FrameTicks -> {{modifiedTks, Automatic}, Automatic}]

```

---

<div class="post-metadata">

**Author:** ![tmreg](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tmreg](https://community.wolfram.com/u/tmreg)\
**Post date:** [September 22, 2020, 4:34pm UTC](https://community.wolfram.com/t/perform-simple-reformatting-of-the-ticks-in-a-plot/10024/8 "2020-09-22T16:34:41Z")

</div>

Hi, I am interested in this solution too. I would like to use human readable numeric values on my charts, not in scientific notation. I could not find how to do that. I am using Mathematica 12.1.1  
Thanks!
