how can I change the length/size ticks in a framed plot?

Err…Let me make clear the meaning of “the length of coordinate notation/marker”.
suppose I have frame1 by

frame1 = Plot[Sin[x], {x, 0, 10}, Frame -> True,
FrameStyle -> Directive[12]]

which looks like:

I want the longer “the length of coordinate notation/marker” similar to frame2 by

frame2 = Plot[Sin[x], {x, 0, 10}, Frame -> True,
FrameStyle -> Directive[12],
Epilog -> {Thick, Line[{{#, -1.1}, {#, -0.9}} & /@ Range[0, 10, 2]],
Line[{{0 – 0.1, #}, {0.3, #}} & /@ Range[-1, 1, 0.5]]}]

which looks like:

as you can see frame2 is ugly due to my poor skill and the code is very…Err..
I thought something like FrameStyle->the code must not be named would work better,however,it turns out and FrameStyle only change the frame color or turn the frame to dashed or change the size of Ticks rather then Frame itself. maybe there are some secret options in FrameStyle->you know what I don’t know?

or are there any automatic ways with similar effect without explicitly write out the Range[-1, 1, 0.5]s or -1.1s unless it’s necessary,I mean, I don’t want to adjust each plot one by one by hand.

all kinds of solution like frame1/.magic-replacement or powerfulfunction[frame1] or wonderfulplot[plapla…] or the methods I can’t image are all welcome.

by the way,If it’s possible,I hope the solution could work well more of Names[“*Plot”]

=================

  

 

I’m surprised that I couldn’t find a dupe for this, but it seems it hasn’t actually been asked before.
– Verbeia♦
Mar 16 ’15 at 6:06

=================

1 Answer
1

=================

Changing the length of the FrameTicks, which is really what you want to do, is addressed in the first “FrameTicks Styling” example of the Scope section in the FrameTicks documentation.

You need to specify the actual tick values shown, like this.

frame2 = Plot[Sin[x], {x, 0, 10}, Frame -> True,
FrameTicks -> {{{#, #, {0.05, 0}} & /@ Range[-2, 2, 0.5],
None}, {{#, #, {0.05, 0}} & /@ Range[0, 12, 2], None}}]

Of course, any way of getting the required specification of ticks instead of a Range would work just as well (e.g. Table[{i,i,{0.05,0},{i,0,12,2}]).

If you want minor ticks still (who does, really?), you can either construct two separate lists of ticks and Join them, or do something like this:

frame2 = Plot[Sin[x], {x, 0, 10}, Frame -> True,
FrameTicks -> {{{#, If[Chop[Mod[2 #, 1]] == 0, Chop@#, “”],
{If[Chop[Mod[2 #, 1]] == 0, 0.05, 0.01], 0}} & /@ Range[-2, 2, 0.1],
None}, {{#, If[Chop[Mod[#, 2]] == 0, Chop@#, “”],
{If[Chop[Mod[2 #, 1]] == 0, 0.05, 0.01], 0}} & /@ Range[0, 12, 0.4],
None}}]

To get rid of the trailing decimal place on the x-axis, use Floor or Round instead of Chop for the label (second part of each sublist).

frame2 = Plot[Sin[x], {x, 0, 10}, Frame -> True,
FrameTicks -> {{{#, If[Chop[Mod[2 #, 1]] == 0, Chop@#,
“”], {If[Chop[Mod[2 #, 1]] == 0, 0.05, 0.01], 0}} & /@
Range[-2, 2, 0.1], None}, {{#,
If[Chop[Mod[#, 2]] == 0, Floor@#, “”],
{If[Chop[Mod[2 #, 1]] == 0, 0.05, 0.01], 0}} & /@
Range[0, 12, 0.4], None}}]

  

 

But now, unfortunately, we have lost the minor tick marks. I would strongly suggest looking into alternate tick functions, such as the CustomTicks package, which offer the necessary flexibility.
– LLlAMnYP
Mar 16 ’15 at 8:48

  

 

@LLIAMnYP You can, of course, include them as well, but I chose a simple example that the OP could work with. I’ve added that case.
– Verbeia♦
Mar 16 ’15 at 22:15