# Disk is displayed distorted in plot

What is the problem with my plot? I want to get a disk shape.

Plot[Table[-x + k, {k, -2, 2, .1}], {x, -5 ,5},
RegionFunction -> Function[{x, y}, (x^2 + y^2) < 1]] • Try reducing the plotting range {x, -2, 2} and setting AspectRatio -> Automatic. – J. M.'s ennui Jun 7 '13 at 2:08
• @0x4A4D yeah, set (x^2+y^2)<2 will be another right shape, do you know why this happen in the case (x^2+y^2)<1 ? – HyperGroups Jun 7 '13 at 2:21
• I didn't tell you to change the RegionFunction. I told you to change the plotting range. You used {x, -5, 5} previously. – J. M.'s ennui Jun 7 '13 at 2:27
• Or increase your PlotPoints. – Silvia Jun 7 '13 at 3:10
• @0x4AD fine, with Silvia's suggestion, I am not so curious about knowing why this happens. --@@-- – HyperGroups Jun 7 '13 at 4:23

## 2 Answers

I think this is a bug. Here is a test with a single straight line and a RegionFunction that differs in its threshold only by .007:

Table[
Plot[-x, {x, -5, 5},
RegionFunction -> Function[{x, y}, y <= max],
AspectRatio -> Automatic,
PlotRange -> {{-1, 0}, {0, 1}},
Frame -> True,
Mesh -> True,
PlotLabel -> max
],
{max, {0.7, 0.707}}] Both lines should be visually the same. The mesh points indicate that the function was repeatedly evaluated far outside the allowed region in the second plot, but nevertheless it didn't try to refine the location of the region boundary.

The problem is very sensitive to the choice of region boundary.

To work around it, you can either change the interval of x in the Plot command to something slightly bigger or smaller than $\pm 5$, or increase the number of PlotPoints as Silvia already pointed out.

Mathematica by default cannot always guess what humans find aesthetic. In your case, it assumes the standard aspect ratio of 1/GoldenRatio. Specifying a ratio of 1 though is not enough, as the plot ranges are still automatically selected by Mathematica to include most of the data (in this case, all). So to plot a correct shape, you have to give both options explicit values, and the aspect ratio must reflect the ratios of the $x$ and $y$ ranges.

Plot[Table[-x + k, {k, -2, 2, .1}], {x, -5, 5},
PlotRange -> {{-5, 5}, {-2, 2}},
AspectRatio -> 2/5,
RegionFunction -> Function[{x, y}, (x^2 + y^2) < 1]] • Or, for the lazy: AspectRatio -> Automatic. – J. M.'s ennui Jun 7 '13 at 7:01
• @0x4A4D True, but I don't find that didactic enough :) – István Zachar Jun 7 '13 at 7:02
• @0x4A4D and Istvan Zachar - I thougth the main problem is existance of those 2 elongated lines, elliptical shape is obvious. On Your Plot strange lines are still there but it can be easily fixed with PlotPoints like Sylvia has said. – Kuba Jun 7 '13 at 7:21
• @Kuba, that's also why I told the OP to tweak the range of the independent variable. Nobody seems to take my suggestions seriously... :P – J. M.'s ennui Jun 7 '13 at 7:54
• @0x4A4D I think it is because there is no precise question. Some think ellipsis is an issue and others are focusing on those lines. – Kuba Jun 7 '13 at 8:24