0
$\begingroup$

So, I have a plot similar to this one.

x = RandomReal[{0.5, 1}, 19]
y = RandomReal[{0.5, 1}, 19]

ListLinePlot[{y/Max[y], x/Max[x]}, PlotRange -> {{0, 19}, {0.4, 1}}, 
 PlotStyle -> {"97", Red}, PlotRangeClipping -> False, 
 PlotMarkers -> Automatic, Ticks -> {Automatic, Automatic}, 
 AxesLabel -> {"Bias Coefficient", "Normalized Value"}]

What I would like to do is to change the values shown in the x axis to the normalized "Normalized Value" that were used to generate the lists in the first place (the values of X and Y at the sample code are dummies), which I would like to input by hand.

Thank you for your help!

$\endgroup$
1
  • 1
    $\begingroup$ Perhaps you can replace the PlotRange option with the option DataRange -> {0, 1}? $\endgroup$
    – Carl Woll
    Commented Aug 2, 2018 at 20:34

2 Answers 2

1
$\begingroup$

It's hard to understand what you want, it's possible that such code

x = RandomReal[{0.5, 1}, 19];
y = RandomReal[{0.5, 1}, 19];
z = {Table[{i/Length[y], y[[i]]/Max[y]}, {i, 1, Length[y]}], 
   Table[{i/Length[x], x[[i]]/Max[x]}, {i, 1, Length[x]}]};
ListLinePlot[z, PlotRange -> Automatic, PlotStyle -> {"97", Red}, 
 PlotRangeClipping -> False, PlotMarkers -> Automatic, 
 Ticks -> {Automatic, Automatic}, 
 AxesLabel -> {"Bias Coefficient", "Normalized Value"}]

fig1

$\endgroup$
0
$\begingroup$

As suggested in a great comment, I would also use DataRange, as it is less extra code, than defining your own x-vector as did Alex. However, the code of Alex allows you to do also many other things.

x = RandomReal[{0.5, 1}, 19]
y = RandomReal[{0.5, 1}, 19]

ListLinePlot[{y/Max[y], x/Max[x]}, PlotRange -> {{0, 1}, {0.4, 1}}, 
 DataRange -> {0, 1}, PlotStyle -> {"97", Red}, 
 PlotRangeClipping -> False, PlotMarkers -> Automatic, 
 Ticks -> {Automatic, Automatic}, 
 AxesLabel -> {"Bias Coefficient", "Normalized Value"}]

enter image description here

Note, that I also updated the PlotRange.

But it is little bit unclear what you wanted to do. As you have labeled your two vectors x and y, perhaps this was your goal?

x = RandomReal[{0.5, 1}, 19]
y = RandomReal[{0.5, 1}, 19]

ListPlot[Transpose[{x/Max[x], y/Max[y]}], 
 PlotRange -> {{0, 1}, {0.4, 1}}, DataRange -> {0, 1}, 
 PlotStyle -> {"97", Red}, PlotRangeClipping -> False, 
 AxesLabel -> {"Normalized Value", "Bias Coefficient"}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.