1
$\begingroup$

I would like to scale this plot below to arbitrary size. For the font size it is straightforward, but

p[size_] := Plot[x^2, {x, 0, 10},
            PlotStyle -> {Thickness[0.002 (size/800)]},
            AxesStyle -> {AbsoluteThickness[1.5 (size/800)], AbsoluteThickness[1 (size/800)]},
            TicksStyle -> Directive[FontSize -> 25 (size/800)],
            ImageSize -> size]

This code can be used to create plots with a custom width. Calling p[800] gives enter image description here whereas calling p[2000] gives enter image description here You can see perfectly well what is happening: the ticks disappear. I know that the package CustomTicks seemingly can solve this, but that is all I know. How do I specifiy the length (and thickness) of the ticks using this package?

$\endgroup$
5
  • 1
    $\begingroup$ Calling p[2000] certainly does not give the above result, but I see what you're getting at. You could use the TickLengthScale option in CustomTicks. $\endgroup$
    – LLlAMnYP
    Commented Feb 20, 2018 at 13:29
  • $\begingroup$ CustomTicks where? $\endgroup$ Commented Feb 20, 2018 at 14:16
  • $\begingroup$ @LLIAMnYP I think the forum software makes the images look more alike because they are both scaled to the same width. If you were to run my MWE from above, you would see that the above is the exact output. I will try to use the TickLengthScale option. $\endgroup$
    – Jens
    Commented Feb 20, 2018 at 14:53
  • $\begingroup$ I recently started to prefer to use Magnify. $\endgroup$
    – corey979
    Commented Feb 20, 2018 at 15:54
  • $\begingroup$ @corey979 I tried Magnify, but it didn't scale the ticks for some reason. I was about to suggest it too. $\endgroup$
    – LLlAMnYP
    Commented Feb 21, 2018 at 17:32

1 Answer 1

2
$\begingroup$

I found that the solution below scales fine:

<< CustomTicks`
p[size_] := Plot[x^2, {x, 0, 10},
                PlotStyle -> {Thickness[0.003]},
                AxesStyle -> {{Gray, AbsoluteThickness[2 (size/800)]},
                              {Gray, AbsoluteThickness[2 (size/800)]}},
                TicksStyle -> Directive[FontSize -> 25 (size/800)],
                Frame -> False,
                Ticks -> {LinTicks[0, 10, 1, 2, MajorTickLength -> 0.01,
                                                MinorTickLength -> 0.005],
                          LinTicks[0, 100, 10, 2, MajorTickLength -> 0.01,
                                                  MinorTickLength -> 0.005]},
                ImageSize -> size]
p[800]
p[2000]
$\endgroup$
1
  • $\begingroup$ Yeah, this is what I had in mind. +1 for the self-answer. $\endgroup$
    – LLlAMnYP
    Commented Feb 21, 2018 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.