iOS Scatter Core Plot with a Gap

iOS Scatter core plot with a gap

Have the datasource return nil or [NSNull null]. For example, if the plot has five data points and you return nil for the x or y field at index 2, the plot will draw the points at indices 0 and 1 connected by a line and indices 3 and 4 connected by a line with a gap in between.

draw a core-plot scatter-plot with a plot point gap

Tell the plot it has only 6 data points (-numberOfRecordsForPlot: returns 6).

Index   X     Y
-------------------
0 0 6
1 1 7
2 3 7
3 4 7
4 5 6
5 6 6

Remove blank space around scatter graph in core plot

The graph starts with 20 pixels of padding on each edge but that's easy to change:

graph.PaddingLeft = 0.0;
graph.PaddingTop = 0.0;
graph.PaddingRight = 0.0;
graph.PaddingBottom = 0.0;

How to reduce gap between CPTXYGraph and CPTGraphHostingView?

You need to set the padding on the graph, too.

graph.paddingTop = 0.0
graph.paddingRight = 0.0
graph.paddingBottom = 0.0
graph.paddingLeft = 0.0

Core Plot not showing scatter plot line

The plot's plot space (extendedPlotSpace) is nil until the plot is added to a graph. Either move your plot space setup to after the plot is part of the graph, or use graph.defaultPlotSpace instead.

ios Core plot - scatter plot circles overlap with x, y axes

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.

How to show single dot if there is only one value in scatter plot using core plot

You need two points to draw a line. When the plot only has one point, set the plot symbol to draw a symbol at that point. When there is more than one data point, set the plot symbol to nil. You can change this setting any time the plot data changes and don't have to recreate the whole plot to do it.

how to fix scatter graph size fixed in core plot

plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat([[mXaxisArray valueForKeyPath:@"@max.floatValue"]floatValue])];

Added xRange to fix this issue



Related Topics



Leave a reply



Submit