1
$\begingroup$

I have the next code:

Plot[{Sin[x], 
  Piecewise[{{Sin[x + Pi], 0 <= x <= Pi/4}, {Sin[x + Pi], 
     Pi <= x <= 5*Pi/4}, {Sin[x + Pi], 2*Pi <= x <= 9*Pi/4}}, _], 
  Piecewise[{{Sin[x], Pi/4 <= x <= Pi}, {Sin[x], 
     5*Pi/4 <= x <= 2*Pi}, {Sin[x], 9*Pi/4 <= x <= 3*Pi}}, _]}, {x, 0,
   3 Pi}, Filling -> {2 -> Axis, 3 -> Axis}, 
 FillingStyle -> {2 -> Directive[Opacity[0.5], Blue], 
   3 -> Directive[Opacity[0.5], Red]}, 
 PlotStyle -> {Dashed, Blue, Red}, 
 Ticks -> {Range[0, 3*Pi, Pi/2], Automatic}, 
 PlotLegends -> {"AC Voltage Supply", "Gate Voltage", 
   "Output Voltage"}]

The Output is the next graph:

enter image description here

Is it possible to do the same graph but instead of displaying on the X Axis: π/2, π, 3 π/2, 2π to display T/4, T/2, 3/4 T, T ? .. T is for Period

and in the Y Axis, instead of 1, to display Vmax?

$\endgroup$
2
$\begingroup$
xt = Range[0, 3 Pi, Pi/2];
xticks = Transpose[{xt, xt /. Pi -> T/2}];
yticks = {{-1, "vMin"}, {-1/2, ""}, {1/2, ""}, {1, "vMax"}};

You can use the option

Ticks -> {xticks, yticks}

in your plot = Plot[Sin[x],, ...] or as

Show[plot, Ticks -> {xticks, yticks}]

enter image description here

$\endgroup$
2
  • $\begingroup$ good, but I think it has to be: xticks = Transpose[{xt, xt /. Pi -> T/2}]; $\endgroup$
    – DieDauphin
    Dec 31 '19 at 22:59
  • $\begingroup$ @DieDauphin, right. Fixed now. $\endgroup$
    – kglr
    Dec 31 '19 at 23:11

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.