5

I've programmed drawing tools for graph images and am experiencing a problem with the coordinates of an Ellipse on a graph with a Log Y axis.

It's quite easy to work out the Y Axis coordinates for other primitive objects such as Line, Rectangle & etc:

y1 = ((viewHeight - stPoint.Y + topMargin) / (viewHeight) * (maxY - minY) + minY);
y2 = ((viewHeight - endPoint.Y + topMargin) / (viewHeight) * (maxY - minY) + minY);

if (isLogYAxis)
{
   y1 = Math.Exp(y1);
   y2 = Math.Exp(y2);
}

Here is an example showing the Epilog generated for a Circle and a Rectangle I've drawn:

enter image description here

Epilog -> {{RGBColor[1,0.2196,1], Circle[{AbsoluteTime@{1991,03,09} + ((AbsoluteTime@{1996,04,28} - AbsoluteTime@{1991,03,09}) / 2),Log@40},    
{(AbsoluteTime@{1996,04,28} - AbsoluteTime@{1991,03,09}) / 2,Log@60}]},

{EdgeForm[Directive[Thick, RGBColor[0.6157,0.6,0.7922]]], Transparent, Rectangle[{AbsoluteTime@{1986,03,26},Log@60},{AbsoluteTime@{1990,12,15},Log@40}]}}

When I execute this command the Ellipse's Y axis is out of proportion, see:

enter image description here

I want to be able to plug in Log@40 and Log@60 for both the Rectangle and Circle and get the same results.

I've made a basic example to demonstrate this.

LogPlot[x^x, {x, 1, 5}, 
 Epilog -> {{RGBColor[0, 0, 0], 
    Circle[{2, Log@46.20}, {1, Log@50.9972}]}}]

Seeing the radius from the ellipse's centre to its top (2000) will be a different size from its centre to its bottom (approx 50), is it even possible to draw a Ellipse on a LogY Graph as I've described?

enter image description here

Edit:

@Artes thank you for pointing me in the right direction, I've tried all sorts of things using this formula Plot[Exp[y /. Solve[x^2 + y^2 == 1, y]], {x, -1, 1}] without luck.

In the last screenshot I've put red squares around the Log@46.20 and Log@50.9972 does anybody know what formula's I would have to change these too in order to get a circle with Log Height of about 5?

If it makes any difference I have the MinY and MaxY Log scale:

MinY = 3.6888794541139363
MaxY = 4.941642422609304

WolframFan
  • 1,412
  • 14
  • 21

1 Answers1

6

If you want to draw an ellipse on top of a LogPlot by specifying the left, right, top and bottom of the ellipse:

ellipse1[l_, r_, t_, b_] :=
 Circle[{(r + l)/2, (Log[t] + Log[b])/2}, {(r - l)/2, (Log[t] - Log[b])/2}]

LogPlot[x^x, {x, 1, 5}, Epilog -> {Black, ellipse1[2, 4, 5, 500]}]

enter image description here

If you want to show a truly elliptical region distorted by the log scale on the y axis:

ellipse2[l_, r_, t_, b_] := 
 Cases[ParametricPlot[{(r + l)/2 + (r - l) Cos[a]/2, 
    Log[(t + b)/2 + (t - b) Sin[a]/2]}, {a, 0, 2 Pi}], _Line, -1]

LogPlot[x^x, {x, 1, 5}, Epilog -> {Black, ellipse2[2, 4, 5, 500]}]

enter image description here

Simon Woods
  • 84,945
  • 8
  • 175
  • 324