Question

I am currently plotting certain data using Scatter Plot of Core Plot. The size of the circles depends on the frequency of occurrence of the particular value. On plotting, I find that some of the circles are overlapping and crossing the x and y axes.

Is there any method to check if a circle (i.e, plot point) crosses the axes and automatically resize the circle so that it does not cross the axes?

Edit - The axes are fixed. So I cannot change the axes.

Edit - I would like to know which methods to use to determine if a circle crosses/touches the x or y axis. Currently the circle overlaps if the size of circle is 12 and its y coordinate is 1.1. I am unable to understand how the size is being mapped to the circle on the plot. Thanks.

Was it helpful?

Solution

No. The easiest way around this problem is to figure out how big the largest circle will be and adjust the plot ranges on the the plot space to leave at least that much space between the extreme data points (smallest and largest) and the axes or other edges of the plot space. The plot space has methods to convert back and forth between data coordinates and pixels in the coordinate space of the plot area layer.

The point conversion methods are:

(data to plot area)

-(CGPoint)plotAreaViewPointForPlotPoint:(NSDecimal *)plotPoint
                    numberOfCoordinates:(NSUInteger)count;
-(CGPoint)plotAreaViewPointForDoublePrecisionPlotPoint:(double *)plotPoint
                                   numberOfCoordinates:(NSUInteger)count;

(plot area to data)

-(void)plotPoint:(NSDecimal *)plotPoint numberOfCoordinates:(NSUInteger)count
                                       forPlotAreaViewPoint:(CGPoint)point;
-(void)doublePrecisionPlotPoint:(double *)plotPoint
            numberOfCoordinates:(NSUInteger)count
           forPlotAreaViewPoint:(CGPoint)point;

Depending on your application, you might be able to expand the plot range by a simple factor using -expandRangeByFactor:. You can find the factor for the xRange by dividing the width of the plot area plus the circle diameter by the width of the plot area. Do a similar calculation for the yRange using the height of the plot area.

OTHER TIPS

Perhaps you could check to see if half of the diameter is greater than both the x and y value of the plot. If it is greater, then reduce the diameter to equal twice the smaller of x and y.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top