2
$\begingroup$

There are a lot of questions already on Ticks. However I did not find a better way to handle ticks place, size etc.

I have a simple example where I want have some handle on the ticks position and size. I found the undocumented functionality Charting`ScaledTicks from some of the previous questions in this forum which I think gives a great handle to tick-size. But when it comes to choosing the Major/Minor tick position I could not so far use it. And the problem is I do not know where I will get more information on this (apart from typing ?Charting`ScaledTicks).

Let’s take the following example where I want to set my Major ticks on even-places like 600, 800, ... etc.

ListLinePlot[
  Table[{x, x}, {x, 500, 2000, 100}],
  Frame -> True,
  FrameStyle -> BlackFrame,
  FrameTicks -> {
    {Charting`ScaledTicks[{Identity, Identity}, TicksLength -> {.05, .02}], None},
    {Charting`ScaledTicks[{Identity, Identity}, TicksLength -> {.05, .02}][400, 2000, 8], None}
  }
]

After playing a bit, I am able to show the Major ticks on x-axis appearing on even-100-places, the minor ticks are gone. I am sure that I am missing something for the minor ticks in the Charting`ScaledTicks options but I dont know what should I do to make them reappear.

Here is an example where y-axis is automatically taking Major ticks, in the x-axis I try to force Major ticks appear at even-hundred places.

How do I set position and size of Major ticks?

$\endgroup$
3
  • $\begingroup$ Sorry found it. ChartingScaledTicks[{Identity,Identity},TicksLength->{.05,.02}][400,2000,{8,5}]. $\endgroup$
    – BabaYaga
    Nov 26, 2020 at 20:42
  • 1
    $\begingroup$ It would be great if you could expand your comment to a self-answer with some explanation of the usage you found. $\endgroup$
    – MarcoB
    Nov 27, 2020 at 5:22
  • 1
    $\begingroup$ Boogeyman, you can get additional information on the syntax and resulting behavior of these functions by using PrintDefinition from the GeneralUtilities package within Mathematica. Searching those two terms on this site should lend you enough information to explore the definitions you want—any definition (to my understanding!). $\endgroup$ Nov 27, 2020 at 7:01

1 Answer 1

2
$\begingroup$

The way it can be done as follows

ListLinePlot[
  Table[{x, x},{x, 500, 2000, 100}],
  Frame->True,
  FrameTicks -> {
    {Charting`ScaledTicks[{Identity, Identity}, TicksLength -> {.05, .02}], None},
    {Charting`ScaledTicks[{Identity, Identity}, TicksLength -> {.05, .02}][400, 2000, {8, 5}], None}
  }
]

First of all, through TicksLength ->{0.05,0.02} one can control the size of Major and Minor ticks. Secondly the position for Major ticks can be controlled through (NdivM below),

Charting`ScaledTicks[{Identity, Identity}, TicksLength -> {.05, .02}][min, max, {NdivM, Ndivm}]

There one has to also keep Ndivm for Minor ticks. In the above example I chose min=400, max=2000, NdivM=8, Ndivm=5.

Thanks to @CA Trevillian now I know how to see the undocumented definition of such functionalities and all the possibilities it can do. For example for this case one can do

 Needs["GeneralUtilities`"];
 PrintDefinitions[Charting`ScaledTicks]

and can see everything about this function.

$\endgroup$
1
  • $\begingroup$ Can you explain the meaning behind your naming of NdivM and Ndivm? Find any way to easily have ticks labels of the values they mark, too? $\endgroup$ Nov 28, 2020 at 4:42

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.