Im trying to reproduce the following graph: enter image description here

I have the parabolas graphed, but I want to indicate the intercepts with the x axis by some point or cross, also I want to eliminate the numbers and the little lines that mark them. I have this: enter image description here

Thanks in advance. Im new to mathematica so...

  • $\begingroup$ "I have the parabolas graphed" - add the settings Mesh -> {{0}}, MeshFunctions -> {#2 &}, MeshStyle -> AbsolutePointSize[4] as a starting point. $\endgroup$
    – J. M.'s torpor
    Feb 12 at 0:00
  • $\begingroup$ thankssssssssss $\endgroup$
    – alefisto
    Feb 12 at 0:25
  • 1
    $\begingroup$ Next time, please include code for any pictures you made with Mathematica instead of having people guess what you did. $\endgroup$
    – J. M.'s torpor
    Feb 12 at 0:28

Maybe something like this?

eqs = {(x + 5)^2 - 130, (x - 2)^2 - 130};
intercepts = NumericalSort[x /. Solve[Or @@ Thread[eqs == 0], x]];
 {x, -21, 16},
 AxesStyle -> White,
 Background -> Black,
 Frame -> True,
 FrameLabel -> {n, \[Epsilon]},
 FrameStyle -> White,
 FrameTicks -> None,
 Mesh -> {{0}},
 MeshFunctions -> {#2 &},
 MeshStyle -> Directive[White, AbsolutePointSize[6]],
 PlotStyle -> Red,
 Ticks -> None,
 Epilog -> {
    Text[Subscript[n, #2], {#1, 
       4}, {Sign[#2 - 2.5] 2, -1}] &, {intercepts, 

Plot of parabolas with zeroes shown.

I've sort of tried to "automate" finding the zeroes and plotting the labels, but it will probably still require a bit of manual tweaking to get the labels right. Thanks to J. M.'s ennui for the Mesh/MeshFunctions/MeshStyle solution. Since I'm already calculating the intercepts, one could also just use those, but I liked the Mesh solution better.

I'm using Epilog to add the text to the plot. The Sign[#2 - 2.5]2 is just there so that the first two zeroes use -2 as their x-offset and +2 for the second two zeroes. What looks good will depend a lot on what equations you're plotting, so the positioning may vary.

  • 1
    $\begingroup$ "Since I'm already calculating the intercepts, one could also just use those, but I liked the Mesh solution better." - if you're really determined to avoid redundancy, you could extract the positions of the intersection points from (a preliminary version of) the plot before putting in other stuff, but then you now need to do things in stages. $\endgroup$
    – J. M.'s torpor
    Feb 13 at 4:39
  • $\begingroup$ @J.M.'sennui I guess that would involve generating the plot and spelunking for the mesh points? I really wish I was better with pattern matching and Cases and that sort of thing. Some of my favourite solutions from other users seem to involve those sorts of things. I guess I will need to practice them; start simple and build from there. $\endgroup$
    – MassDefect
    Feb 13 at 4:48
  • 1
    $\begingroup$ Right, I'd be using Cases[] + Normal[] for that extraction (usually): Cases[Normal[g], Point[{x_, y_}] :> x, Infinity] (with the assumption that the only points added come from Mesh/MeshFunctions). A lot of people here have done this too, so if you want practice, you could try finding those answers to study them. ;) (I should also say that one of the upvotes came from me.) $\endgroup$
    – J. M.'s torpor
    Feb 13 at 4:53

We can use a function as the option setting for MeshStyle to add labels to mesh points without having to post-process:

Plot[{(2 x + 2) (2 x - 1), (2 x + 1) (2 x - 2)}, {x, -2, 2}, 
 Mesh -> {{0}}, MeshFunctions -> {#2 &}, 
 MeshStyle -> ({Directive[White, AbsolutePointSize[10]], #, White, 
   MapIndexed[Text[Style[Subscript[n, {1, 3, 2, 4}[[#2[[1]]]]], 
       18, White], #,{{-2, 2}[[Mod[#2[[1]], 2, 1]]], -1}] &,  #[[1]]]} &), 
 FrameLabel -> {{Style[ϵ, 16, White], None}, {Style[n, 16, White], None}}, 
 Background -> Black, FrameStyle -> White, AxesStyle -> White, Frame -> True, 
 FrameTicks -> False, ImageSize -> Large]

enter image description here

Use Mesh -> {{5}} to get

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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