1
$\begingroup$

Here is the code,

ClearAll;
ListPlot[ParallelTable[{x, 
NIntegrate[(x - z)/(20*Sin[z]), {z, 0, 2*Pi}, MaxRecursion -> 100, 
Method -> {"LocalAdaptive", "SymbolicProcessing" -> 0}, 
AccuracyGoal -> 5]}, {x, 0, 10, 1}], Joined ->
True, AxesLabel -> {"x", "y"}, 
LabelStyle -> Directive[Black, Bold], 
BaseStyle -> {FontWeight -> Bold, FontSize -> 18},
PlotRange -> Automatic]

and that code gives me a triangle like curve plot on positive x axis and positive y axis.
I am attempting to plot the same thing reversed on negative axis and positive y axis without changing the range in integral or function in the integral (almost mirror like reflection). In other words, I am trying to plot the curve on negative axis by changing data plot range in list plot. However this attempt using DataRange does not work. Is it possible?

$\endgroup$
2
$\begingroup$

I am attempting to plot the same thing reversed on negative axis and positive y axis

You mean something like this?

Mathematica graphics

Which can be done by multiplying the x coordinates by -1

ClearAll;

data=ParallelTable[
        {x,NIntegrate[(x-z)/(20*Sin[z]),{z,0,2*Pi},
                       MaxRecursion->100,
                       Method->{"LocalAdaptive","SymbolicProcessing"->0},
                       AccuracyGoal->5]},{x,0,10,1}
];

dataReversed           =  data;
dataReversed[[All,1]]  = -1*dataReversed[[All,1]];

ListPlot[{data,dataReversed},Joined->True,
  AxesLabel->{"x","y"},
  LabelStyle->Directive[Black,Bold],
  BaseStyle->{FontWeight->Bold,FontSize->18},
  PlotRange->Automatic]

If you just want to plot the reversed data, just remove data from the above plot command.

$\endgroup$
2
$\begingroup$

You can also post-process the output of your ListPlot to reflect the lines through the vertical axis:

lp = ListPlot[data, Joined -> True, AxesLabel -> {"x", "y"}, 
  LabelStyle -> Directive[Black, Bold], 
  BaseStyle -> {FontWeight -> Bold, FontSize -> 18}, PlotRange -> Automatic];

Show[lp, lp /. L_Line :> {Red, GeometricTransformation[L, ReflectionTransform[{-1, 0}]]}, 
 PlotRange -> All]

enter image description here

Alternatively,

Show[lp, lp /. Line[x_, y___] :> {Line[x, y], Red, Line[{-1, 1} # & /@ x, y]}, 
 PlotRange -> All]

same picture

$\endgroup$

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.