Message Boards Message Boards

1
|
14473 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

How to place frame ticks outside of the frame?

Posted 11 years ago
Hi,

I am currently altering the outlook of histograms so they are easier to read for my dissertation I would really appreciate if anyone can help me on this.
Say I am plotting a set of data fitted with a normal distribution curve (see algorithm below). By default, the ticks are place inside the frame, is there a way to flip the ticks outside of the frame instead?
 data = RandomVariate[NormalDistribution[5, 10], 10^4];
 hist = Histogram[data, Automatic, "ProbabilityDensity"]
 
 m1 = Mean[data];
 sd1 = StandardDeviation[data];
 normdist =
 Plot[PDF[NormalDistribution[m1, sd1], k], {k, -40, 40},
   PlotStyle -> Thick, AxesLabel -> {x}]
 
Show[Histogram[data, {2}, "ProbabilityDensity"], normdist,
Frame -> True, FrameLabel -> {"x", "y"}]
POSTED BY: Wai Fun Lam
6 Replies
POSTED BY: Henrick Jeanty

When I use Henrik's solution I get no Frame.

How can you say that ?!? If you want to get a frame, how about setting Frame -> True ?!

ListLinePlot[RandomReal[{-1, 1}, 25], ImageSize -> {128, 128}, 
 Frame -> True, FrameTicks -> None,
 Axes -> False, AspectRatio -> 1, PlotMarkers -> {{\[FilledCircle], 2}}]

enter image description here

POSTED BY: Henrik Schachner

For controlling ticks on a frame you should not use the option Ticks but FrameTicks, in your case:

FrameTicks -> None
POSTED BY: Henrik Schachner

I also had a question and decided to research previous questions to see if my problem had been encountered by someone else. The question by Wai was the closest to mine but not quite the same. I am able to display a plot but would like to simply frame it. I use:

ListLinePlot[coords[[n]], ImageSize -> {128, 128}, 
 Frame -> True, Axes -> False, Ticks -> False, AspectRatio -> 1, 
 PlotMarkers -> {{\[FilledCircle], 2}} ]

And I get a frame with ticks and numbers on both the X and Y axes, I would like to know if it is possible to have a simple Frame with no ticks and no axis. Essentially, I just want a Black Frame around my line plot.

POSTED BY: Henrick Jeanty
Posted 3 years ago

Hi Henrick,

One way

coords = RandomReal[10, {10, 2}];

ListLinePlot[coords,
  ImageSize -> {128, 128},
  Frame -> False,
  Axes -> False,
  AspectRatio -> 1,
  PlotMarkers -> {{\[FilledCircle], 2}}] // Framed

enter image description here

Check the docs for Framed.

POSTED BY: Rohit Namjoshi
The 3rd element of a tick specification is the pair {plen, mlen}, where plen is the length in the positive direction (i.e., inside for frame ticks), and mlen is the length in the negative direction (i.e., outside for frame ticks). So, create one’s own ticks and use FrameTicks:

xticks = Table[{i, If[Mod[i, 20] == 0, i, ""], {0, 0.01}}, {i, -40, 40, 5}]

Show[Histogram[data, {2}, "ProbabilityDensity"], normdist, Frame -> True,  FrameLabel -> {"x", "y"},  FrameTicks -> {xticks, Automatic, Automatic, Automatic}]



Lengths of major and minor ticks can be set this way also.

Better tick support is needed so that licks on different scales (e.g., log, inverse, etc.) can be easily created by the user. An option to a function that creates the ticks could easily specify whether they were in the inside or outside of the frame.
Bob
POSTED BY: Robert Nachbar
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract