1
$\begingroup$

Can someone please help me find the scaling function that will help see the y-intercept of 5 and the maximum of 20000 on the same scale in the function below:

Plot[20000-(3999 (-10000+x)^2)/20000000,{x,0,20000}]

I basically want to compress the scales for values between 5 and 20000. The log scale is not appropriate for this.

$\endgroup$

3 Answers 3

1
$\begingroup$

"The log scale is not appropriate for this."

Why?

{mi = {}, ma = {}}; LogPlot[
f = 20000 - (3999 (-10000 + x)^2)/20000000, {x, 0, 20000}, 
PlotRange -> {1, 100000}, AxesOrigin -> {-1000, 1}, 
EvaluationMonitor :> {min = Min[AppendTo[mi, f]], 
max = Max[AppendTo[ma, f]]}, GridLines :> {None,   {min, max}}, 
PlotPoints -> 100, ImageSize -> 400, 
Ticks -> {Automatic, {Round[min], 10, 100, 1000, 10000, Round[max]}
}]

enter image description here

$\endgroup$
0
$\begingroup$

You can use the option ScalingFunctions to use arbitrary scaling functions (with their respective inverses) for plotting.

Block[{
  f = Sign[#]*Abs[#]^(1/5) &,
  g = Sign[#]*Abs[#]^(1/5) &,
  invf = Sign[#]*Abs[#]^5 &,
  invg = Sign[#]*Abs[#]^5 &
  },
 Plot[20000 - (3999 (-10000 + x)^2)/20000000, {x, 0, 20000}, 
  ScalingFunctions -> {{f, invf}, {g, invg}}, 
  PlotRange -> {Automatic, {0, 20000}}]
 ]

Output plot

$\endgroup$
3
  • 2
    $\begingroup$ If f and g are the same, why wouldn’t you just use f for both? That will save you from defining the same thing twice. $\endgroup$
    – MarcoB
    Jan 24, 2021 at 14:10
  • 1
    $\begingroup$ I only want to alter the y-axis compressing values between 5 and 20000 so the 5 and 20000 can be seen by the tick marks on the y-axis. No altering of the x-axis scaling. $\endgroup$
    – user13892
    Jan 24, 2021 at 17:38
  • 1
    $\begingroup$ I define 2 different functions so the x-axis and the y-axis can be scaled differently. In the example, the f and invf define the scaling for the x-axis, while g and invg define the scaling for the y-axis. $\endgroup$ Jan 25, 2021 at 2:38
0
$\begingroup$

Let's scale the y axis with Sqrt and not scale the x axis

Plot[Sqrt[20000-(3999 (-10000+x)^2)/20000000],{x,0,20000},
  Ticks->{Automatic,{{Sqrt[5],5},{Sqrt[20000],20000}}},
  AxesOrigin->{0,-5}]

That places tick labels of 5 and 20000 on the y axis and shifts the AxesOrigin down by 5 so that the 5 label isn't erased by the origin.

You can try to reproduce this using ScalingFunctions like this

Plot[20000 - (3999 (-10000 + x)^2)/20000000, {x, 0, 20000},
ScalingFunctions -> {Automatic, {Sqrt[#]&,#^2&}},
Ticks->{Automatic,{5,20000}},AxesOrigin->{0,-5}]

That displays exactly the same semicircle curve and the 20000 tick label, but it keeps fighting with the 5 tick label and I couldn't get that to reliably display, no matter how I pushed the AxesOrigin around.

I would probably suggest putting an informative label on that plot so that the viewer knows this has been scaled by the square root. And put some comments in the code so that the reader will understand what and why that was done when they come back in a week or a year.

$\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.