# ListStepPlot with two axes of ordinates

I have the following vector:

t0={1.0023, 1.0023, 1.0023, 1.0023, 0.88191, 0.88191, 0.6682, 0.6682, \
1.25614, 1.25614, -1.20461, -1.20461, -1.20461, -1.20461, -1.05992, \
-1.05992}


and I'm trying to build a ListStepPlot with two y-axes, such that the last six negative values can be plotted in the top part of the diagram. Here is my code:

d=30;line = Line[{{11, 0}, {11, .32}}]; plot1 =
ListStepPlot[Normalize@t0,
PlotRange -> {{0.95, 16.5}, {0.15, 0.32}},
ImageSize -> Large, ImagePadding -> d,
Epilog -> {Directive[Black, Thick, Dashed], line}]; plot2 =
ListStepPlot[Normalize@t0, PlotRange -> {{0.95, 16.5}, {-0.32, 0}},
ImageSize -> Large, ImagePadding -> d, Axes -> False,
Frame -> {False, False, False, True},
FrameTicks -> {{None, All}, {None, None}}]; Overlay[{plot1, plot2}]


I would like the plot 2 should be "reflected", that is, the origin of the right y-axes should be at the same level as that of the left y-axes.

How can I do this?

You can get the desired result in a single ListStepPlot using Abs @ Normalize @ t0 as input and and using ChartingScaledTicks["Reverse"] to reverse the tick labels on the right axis:

ListStepPlot[
Abs @ Normalize @ t0,
PlotRange -> All,
ImageSize -> Large,
Epilog -> {Directive[Black, Thick, Dashed], line},
Frame -> {{True, True}, {True, False}},
FrameTicks -> {{Automatic, ChartingScaledTicks["Reverse"]}, {Automatic, None}},
FrameLabel -> {Style[#, 16] &/@ {t, t}, {Style[e, 16], None}}
]


Note: You can also use ChartingFindTicks[- {0, 1}, {0, 1}] instead of ChartingScaledTicks["Reverse"], and

GridLines -> {{{11,Directive[Opacity[1],Black, Thick, Dashed]}}, None}


instead of Epilog -> ... to get the same picture.

• how can I add the labels? Jul 16, 2019 at 16:10
• @GaeP, please see the updated version.
– kglr
Jul 16, 2019 at 16:14
• Thanks! another question: I would like to use PlotLegends -> PointLegend["t", LegendMarkers -> Automatic] but it seems doesn't work with ListStepPlot... Jul 17, 2019 at 9:21
• @GaeP, try PointLegend[ {"t"}, LegendMarkers->{Automatic}] or LineLegend[ {"t"}, LegendMarkers->{Automatic}]
– kglr
Jul 17, 2019 at 9:46

I'm not sure if I'm understanding what you want to do, exactly. Is this what you're looking for?

If so, this is the code I used:

t0 = {1.0023, 1.0023, 1.0023, 1.0023, 0.88191, 0.88191, 0.6682,
0.6682, 1.25614,
1.25614, -1.20461, -1.20461, -1.20461, -1.20461, -1.05992, \
-1.05992}
d = 30;
line = Line[{{11, 0}, {11, .32}}];
plot1 = ListStepPlot[
Normalize@t0,
PlotRange -> {{0.95, 16.5}, {0.15, 0.32}},
ImageSize -> Large,
Epilog -> {Directive[Black, Thick, Dashed], line}
];
plot2 = ListStepPlot[
Normalize@t0,
PlotRange -> {{0.95, 16.5}, {-0.32, -0.15}},
ImageSize -> Large,

The only things I changed were the PlotRange in plot2 and I added ScalingFunctions -> {None, "Reverse"} to plot2.