0
$\begingroup$

This question already has an answer here:

I would like to draw a simple 2D graphics with a frame, without any FrameTicks, but still having central axes with ticks. The code is this :

Plot[
LegendreP[3, x], {x, -1, 1},
PlotPoints -> Automatic,
PlotRange -> {-1, 1},
PlotStyle -> Directive[Thick, RGBColor[0.00, 0.40, 0.80]],
Frame -> True,
FrameTicks -> None,
Axes -> True,
Ticks -> True,
AxesOrigin -> {0, 0},
AxesStyle -> Directive[Gray],
GridLines -> Automatic,
GridLinesStyle -> Directive[Gray, Dashed],
Ticks -> Automatic,
PerformanceGoal -> "Quality"
]

I believed that would be easy and pretty standard. Apparently, I was wrong (?). The documentation didn't tell anything about this combination, and the site didn't helped me much with this.

So how do you add ticks on both central axes ? The command Ticks -> True doesn't seem to make a diference.

$\endgroup$

marked as duplicate by MarcoB, user9660, m_goldberg, Michael E2 plotting Mar 15 '16 at 21:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    $\begingroup$ The short answer is that you can't have both axis ticks and a frame in the built-in system, perhaps because it can be confusing to the casual reader. This has been discussed before here: FrameTicks and Ticks on Axes in Same Plot, where some sophisticated workarounds are provided as well. A very simple alternative could be to wrap your Plot in Framed: image. $\endgroup$ – MarcoB Mar 15 '16 at 0:23
  • $\begingroup$ So we can't have both at the same time ? This is weird. In a Manipulate box, the FrameTicks are taking space outside the frame. Inside the frame, it would be ugly. The graphics with axes + ticks but without a frame is uglier. $\endgroup$ – Cham Mar 15 '16 at 0:26
  • 1
    $\begingroup$ Doh ! Using PlotRange -> {{-1, 1}, {-1, 1}}without a Frame is a good compromise. $\endgroup$ – Cham Mar 15 '16 at 0:28
  • 2
    $\begingroup$ Try Framed. $\endgroup$ – Alexey Popkov Mar 15 '16 at 2:12
  • $\begingroup$ You have used the Ticks option twice. $\endgroup$ – Sjoerd C. de Vries Mar 15 '16 at 18:56
4
$\begingroup$

Since all you want is a frame, use Framed

Framed[Plot[LegendreP[3, x], {x, -1, 1},
  PlotRange -> All,
  PlotStyle -> Directive[Thick,
    RGBColor[0.00, 0.40, 0.80]],
  Axes -> True,
  GridLines -> Automatic,
  GridLinesStyle ->
   Directive[Gray, Dashed],
  Ticks -> True,
  PerformanceGoal -> "Quality"]]

enter image description here

$\endgroup$
1
$\begingroup$

Maybe by using the Overlay command for two plots: one without frame and another one without axes

   Overlay[{Plot[LegendreP[3, x], {x, -1, 1}, PlotPoints -> Automatic, 
   PlotRange -> Full, 
   PlotStyle -> Directive[Thick, RGBColor[0.00, 0.40, 0.80]], 
   Frame -> False, Axes -> True, AxesOrigin -> {0, 0}, 
   AxesStyle -> Directive[Gray], GridLines -> Automatic, 
   GridLinesStyle -> Directive[Gray, Dashed], Ticks -> Automatic, 
   PerformanceGoal -> "Quality", ImagePadding -> All, Frame -> True], 
   Plot[None, {x, -1, 1}, PlotPoints -> Automatic, PlotRange -> Full, 
   PlotStyle -> Directive[Thick, RGBColor[0.00, 0.40, 0.80]], 
   Frame -> True, FrameTicks -> None, Axes -> False, Ticks -> True, 
   AxesOrigin -> {0, 0}, AxesStyle -> Directive[Gray], 
   Ticks -> Automatic, PerformanceGoal -> "Quality"]}]

enter image description here

$\endgroup$

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