5
$\begingroup$

So there is a (List)LogLogPlot I made a few months ago. Now, it turns out the axes I had back then are too small. Now, the creation of these plots costed quite some calculational time. So, instead of doing everything again, I execute

Show[*Paste old graph*,AxesStyle->Large,ImageSize->500] 

Which kind of does what I expected it to do. The problem is, due to the increased size of my Tick-numbers, they overlap on the horizontal axis. So I want to reduce these labels from the default

{10,50,100,500,1000,5000,10000} 

to

xlist={10,100,1000,10000}. 

When I specify Ticks->{{xlist},{ylist}}

All ticks seem to dissapear (actually, one on the y-axis seems to remain, it is hard to read but it looks like it is in the wrong place).

When i specify Ticks->Automatic, ticks appear at natural numbers with even spacing, as if it were a normal plot instead of a LogLogPlot. The same behaviour when only the y-axis is set to automatic.

MWE: an example of this appears as well when comparing for example

LogLogPlot[10000/T^2, {T, 10, 10000}, PlotStyle -> {Red, Dashed},Ticks->Automatic, AxesStyle -> Large, ImageSize -> 500] 

with

Show[LogLogPlot[10000/T^2, {T, 10, 10000}, PlotStyle -> {Red, Dashed}, AxesStyle -> Large, ImageSize -> 500],Ticks->Automatic] 

Partial solution: To large extent, the problem can be solved by setting the graphics option

Ticks -> {{{Log[10], 10}, {Log[100], 100}, {Log[1000], 1000}, {Log[10000], 10000}}, Charting`ScaledTicks[{Log, Exp}]}. 

The only remaining issue is that this gives only ticks markers at the specified x-values, Whereas the default (Charting`ScaledTicks) draws more unlabeled ticks markers without a label and with varying size. It would be nice to have these too on the x-axis: more ticks-markers with varying size and without label.

It would seem to me this could be obtained by, instead of giving an explicit list in Ticks right away, play with the options of

Charting`ScaledTicks 

which seems undocumented.

Options[Charting`ScaledTicks]={Method->Automatic,TicksLength->Automatic,Object->None,Ticks->Automatic}. 

Giving Charting an option like Ticks->{{Log[10],10},{Log[100],100}} or even TicksLength->Large doesn't seem to make a difference however.

$\endgroup$
9
  • $\begingroup$ We're gonna need more data and code to judge. $\endgroup$ Commented Jan 19, 2017 at 10:06
  • $\begingroup$ @Feyre added MWE $\endgroup$ Commented Jan 19, 2017 at 10:19
  • 1
    $\begingroup$ You may be interested in Information[]. $\endgroup$ Commented Jan 19, 2017 at 12:51
  • 1
    $\begingroup$ @Wouter I'd recommend using InputForm, instead, it is a bit easier on the eyes. Also, if you are looking for the options being passed to Graphics use Options, which is much easier than trying to read through the InputForm of the entire thing. $\endgroup$ Commented Jan 19, 2017 at 14:34
  • 2
    $\begingroup$ @Wouter Rule is it's FullForm, i.e. a -> b is interpreted as Rule[a, b]. It's an important hurdle in understanding how mma processes its input, so keep comparing the FullForm to the InputForm it will save you from messes like this one: #[[1]] + 2^#&@#[[2]] & which got me yesterday. Plus has a higher precedence than Function, so that this is interpreted as (#[[1]] + 2^#)& @ #[[2]]&. Definitely not what I wanted. :) $\endgroup$ Commented Jan 19, 2017 at 15:09

1 Answer 1

4
$\begingroup$

This seems to work:

plot = LogLogPlot[10000/T^2, {T, 10, 10000}, PlotStyle -> {Red, Dashed}, Ticks -> Automatic, AxesStyle -> Large, ImageSize -> 500] 

enter image description here

Show[plot, Ticks -> {Quiet[ Charting`ScaledTicks[{Log, Exp}][#1, 1.1 #2, {6, 6}]] &, Quiet[Charting`ScaledTicks[{Log, Exp}][#1, #2, {6, 6}]] &}] 

enter image description here

How did I do this? Admittedly, by try-and-error. If you do List @@ plot you can see all the options that are set of this plot. From there I saw how the ticks are specified and played with the numbers. The first item in the list given to Ticks specifies the x-axis ticks. Multiplying the second argument of the mysterios ScaledTicks function seems to change how many minor ticks are used between two major ticks. Multiplying this argument by 1.1 seems to lead to a major tick every 10 minor ticks.

$\endgroup$
6
  • 2
    $\begingroup$ The usage of ScaledTicks, while undocumented, appears in several answers, The general form is Charting`ScaledTicks[<scaling args>][min, max, divisions]. So your 1.1 #2 trick tells the ticks function that the range is a bit greater at the upper end (in fact, at T == 29427.3 == Exp[(1.1) (1 + 1/64) Log[10000]]). It does seem counterintuitive that increasing the range results in fewer major ticks. $\endgroup$ Commented Jan 19, 2017 at 18:27
  • $\begingroup$ BTW, you can use just Charting`ScaledTicks["Log"] for the vertical axis. $\endgroup$ Commented Jan 19, 2017 at 18:31
  • 1
    $\begingroup$ Thanks for clarifying the arguments. Just for completeness, let me add that [<scaling args>] = [{function, inversefunction}, options]. Also, I found that divisions = {maximum number of major ticks, number of minor ticks between major ticks}. So I would expect setting divisions = {3,11} would do the job. In fact, changing the first number in divisions produces weird output (try 5 or 21 instead of 6), whereas the second number has absolutely no effect. $\endgroup$ Commented Jan 19, 2017 at 19:28
  • 1
    $\begingroup$ Let's just say I said <scaling args> because there are several variants, not just that one. (But that one seems to be the most commonly used one.) $\endgroup$ Commented Jan 19, 2017 at 19:38
  • 1
    $\begingroup$ Good to know. Maybe we should create our own documentation for such officially undocumented functions (maybe as a question "What is the definition of ..."). As it is now, one has to extract the definition and function arguments from a bunch of comments in a variety of questions. $\endgroup$ Commented Jan 19, 2017 at 19:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.