0
$\begingroup$

Is there a trivial or extremely easy way to get this?

enter image description here

$\endgroup$
0

1 Answer 1

2
$\begingroup$

One quick way could be

Plot[21000 x, {x, 42, 49}, Ticks -> {Automatic, Range[900000, 10^6, 50000]}] 

Mathematica graphics

But it losses the minor ticks for some reason and I do not know now why. If I find, will update.

Update

Thanks to J.M.'s suggestion in the comment below. It is possible to create the ticks directly. Hence using his suggestion you could do

ClearAll[x]; divs = FindDivisions[21000 {42, 49}, {5, 5}]; yTicks = Flatten[Riffle[Transpose[{{divs[[1]], divs[[1]]}}, {2, 3, 1}], Map[Function[t, {t, "", {0.005, 0.}, {AbsoluteThickness[0.1]}}], divs[[2]], {2}]], 1]; Plot[21000 x, {x, 42, 49}, Ticks -> {Automatic, yTicks}] 

Mathematica graphics

J.M.'s method has the advantage that minor ticks are not lost which is better.

$\endgroup$
5
  • 1
    $\begingroup$ Here's something you can put in for the vertical ticks: Flatten[Riffle[Transpose[{{#1, #1}}, {2, 3, 1}], Map[Function[t, {t, "", {0.005, 0.}, {AbsoluteThickness[0.1]}}], #2, {2}]], 1] & @@ FindDivisions[{882000, 1029000}, {5, 5}]. $\endgroup$ Commented May 10, 2020 at 1:10
  • $\begingroup$ @J.M. that is very nice. I was trying this, but could not make it work: p1 = Plot[21000 x, {x, 42, 49}] oldTicks = AbsoluteOptions[pl, Ticks][[1, 2, 2]] This gives the original ticks. But could find how to replace the labels. I was trying to use AccountingForm, then do Show[p1, Ticks -> {Automatic, newTicks}] where newTicks is the old ones, but changed the labels. This did not work. Your method seems to make everything from scratch. Please feel free to post this as answer. $\endgroup$ Commented May 10, 2020 at 1:15
  • $\begingroup$ AbsoluteOptions[] has been broken for a while, unfortunately. Also, I'd prefer you just edit your answer (I have upvoted already) to include that minor fix. $\endgroup$ Commented May 10, 2020 at 1:17
  • $\begingroup$ Thanks for the answers, Wow, that escalated quickly! The Range[900000, 10^6, 50000] solution does not have generality. I was hoping to see something like AxisNumberForm -> Decimal. I guess that this is one point in favor of Excel, which is almost unbelievable. $\endgroup$ Commented May 11, 2020 at 1:59
  • $\begingroup$ @bowzee can you elaborate? How does this solution not “generalize”? $\endgroup$ Commented May 18, 2020 at 22:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.