3
$\begingroup$

I have the following list:

gs = {-0.4993484712, -0.4978548043, 
      -0.4940563241, -0.4836338315, 
      -0.4559910524, -0.3817524976, 
      -0.1667542598, -0.1206998794, 
      -0.1192191910, -0.1152026146, 
      -0.1046546835, -0.0769508374, 
      -0.0026840318};

I want to draw a plot using my list as The one in the picture below. How can I do so?

image of an energy level diagram

$\endgroup$
6
$\begingroup$
Plot[gs, {x, .2, 1}, 
 PlotStyle -> Black, 
 Axes -> {False, True}, 
 AspectRatio -> 2, 
 PlotRange -> {{0, 1}, Automatic}]

enter image description here

Alternatively, you can process gs to get the coordinates for 13 lines and use those coordinates with Graphics:

linecoords = {{0.05, #}, {.25, #}} & /@ gs;

Graphics[{Line /@ linecoords}, 
 Axes -> {False, True}, 
 PlotRange -> {{0, .25}, All}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ great! Thanks a lot $\endgroup$ – Wisdom Jun 11 at 9:20
  • $\begingroup$ @Wisdom, you are welcome. $\endgroup$ – kglr Jun 11 at 9:21
  • $\begingroup$ Dear @kglr can you tell me what part of your code produces the horizontal lines? $\endgroup$ – Wisdom Jun 11 at 9:24
  • $\begingroup$ @Wisdom, as you can see from the simpler example Plot[{2, 5, x^2}, {x, 0, 2}] we are using gs as 13 different constant functions. $\endgroup$ – kglr Jun 11 at 9:31
  • $\begingroup$ OK got it. Thanks again $\endgroup$ – Wisdom Jun 11 at 9:44

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.