Message Boards Message Boards

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

How to shift functions in a multiple-function plot?

In the plot shown below (which, as you might guess, is my lame attempt at an energy level diagram) all of the horizontal lines lie along the same column. Is there any way to shift some of these to the right so as to arrange them into a sort of staircase?

Plot of several horizontal lines Plot[{0, 1.0812, 2.1096, 2.8883, 3.2302, 4.8815, 5.3394, 5.4031, 5.2447}, {x, 1, 1.1}, PlotRange -> {{1, 1.5}, {0, 6}}]

Attachments:
POSTED BY: Ricardo Garcia
6 Replies

One way is to apply a ShearingTransform to your plot

Graphics[GeometricTransformation[
  First@Plot[{0, 1.0812, 2.1096, 2.8883, 3.2302, 4.8815, 5.3394, 
     5.4031, 5.2447}, {x, 1, 1.1}], 
  ShearingTransform[Pi/3, {1, 0}, {0, 1}]]]
POSTED BY: Gianluca Gorni

Thank you very much. Is there a way to do it so that the y-axis values are also shown?

POSTED BY: Ricardo Garcia

One way is like this:

startingPlot = 
  Plot[{0, 1.0812, 2.1096, 2.8883, 3.2302, 4.8815, 5.3394, 5.4031, 
    5.2447}, {x, 1, 2}];
Graphics[GeometricTransformation[First@startingPlot, 
  ShearingTransform[.1Pi, {1, 0}, {0, 1}]], Frame -> True]

A different approach, with different domains for the plots:

values = {0, 1.0812, 2.1096, 2.8883, 3.2302, 4.8815, 5.3394, 5.4031, 
   5.2447};
Show[Table[Plot[values[[n]], {x, n - 1, n}], {n, Length[values]}], 
 PlotRange -> All]

Yet another, using ListPlot:

values = {0, 1.0812, 2.1096, 2.8883, 3.2302, 4.8815, 5.3394, 5.4031, 
   5.2447};
ListPlot[values, PlotMarkers -> "\[LongDash]"]

Do you need the lines to be of some particular colors?

POSTED BY: Gianluca Gorni

Thank you! No, the colors don't need to be any color in particular.

POSTED BY: Ricardo Garcia

Ok, I was asked to make them black now haha, sorry about that. Also, if you could tell me how to make the lines a bit thicker, I would appreciate it very much (I used the second method).

POSTED BY: Ricardo Garcia

Here is a way:

values = {0, 1.0812, 2.1096, 2.8883, 3.2302, 4.8815, 5.3394, 5.4031, 
   5.2447};
Show[Table[
  Plot[values[[n]], {x, n - 1, n}, 
   PlotStyle -> Directive[Black, Thickness[.01]]], {n, 
   Length[values]}], PlotRange -> All]

You can adjust the thickness to your needs.

POSTED BY: Gianluca Gorni
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