Note that there are some explanatory texts on larger screens.

plurals
  1. POCore-Plot formating the graph properly
    primarykey
    data
    text
    <p>I have attached a screenshot of my graph. </p> <p><img src="https://i.stack.imgur.com/d8Yxg.png" alt="core-plot"></p> <p>I need to fix the following issues.</p> <p>1) This graph starts at 60. So I no longer need that 0-60 y axis line under the x axis. How to remove that part? Y axis should start from 60 and go upwards.</p> <p>2) How to add the tick for x axis. Since my labels are inclined I need to add it properly. </p> <p>Here is my code</p> <pre><code> // Create graph from theme graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero]; CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme]; [graph applyTheme:theme]; CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view; hostingView.collapsesLayers = NO; // Setting to YES reduces GPU memory usage, but can slow drawing/scrolling hostingView.hostedGraph = graph; graph.paddingLeft = 10.0; graph.paddingTop = 10.0; graph.paddingRight = 10.0; graph.paddingBottom = 10.0; // Setup plot space CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace; plotSpace.allowsUserInteraction = YES; plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-100.0) length:CPTDecimalFromFloat(500.0)]; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-2.25) length:CPTDecimalFromFloat(15.0)]; CPTMutableLineStyle *xLineStyle = [CPTMutableLineStyle lineStyle]; xLineStyle.miterLimit = 1.0f; xLineStyle.lineWidth = 3.0f; xLineStyle.lineColor = [CPTColor whiteColor]; // Axes CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; CPTXYAxis *x = axisSet.xAxis; x.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(100)]; x.majorIntervalLength = CPTDecimalFromString(@"1"); x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(60.0); x.titleLocation = CPTDecimalFromFloat(0.5f); x.titleOffset = 5.0f; x.labelingPolicy = CPTAxisLabelingPolicyNone; NSMutableArray *customTickLocations = [[NSMutableArray alloc] init]; if (selectedIndex == 0) { self.xAxisLabels = [[[NSMutableArray alloc] init] autorelease]; for (int i = 0; i &lt; [items count]; i++) { WeightDTO *weightDTO = [items objectAtIndex:i]; [xAxisLabels addObject:weightDTO.dateAdded]; [customTickLocations addObject:[NSString stringWithFormat:@"%d", i]]; } } NSUInteger labelLocation = 0; NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]]; for ( NSNumber *tickLocation in customTickLocations ) { CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText:[xAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle]; newLabel.tickLocation = [tickLocation decimalValue]; newLabel.offset = x.labelOffset + x.majorTickLength; newLabel.rotation = M_PI / 4; [customLabels addObject:newLabel]; [newLabel release]; } x.axisLabels = [NSSet setWithArray:customLabels]; CPTXYAxis *y = axisSet.yAxis; y.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(500)]; y.majorIntervalLength = CPTDecimalFromString(@"30"); y.minorTicksPerInterval = 5; y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0.0); y.delegate = self; // Create a blue plot area CPTScatterPlot *boundLinePlot = [[[CPTScatterPlot alloc] init] autorelease]; CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; lineStyle.miterLimit = 1.0f; lineStyle.lineWidth = 3.0f; lineStyle.lineColor = [CPTColor redColor]; boundLinePlot.dataLineStyle = lineStyle; boundLinePlot.identifier = @"Blue Plot"; boundLinePlot.dataSource = self; [graph addPlot:boundLinePlot]; // Do a blue gradient CPTColor *areaColor1 = [CPTColor colorWithComponentRed:0.3 green:0.3 blue:1.0 alpha:0.8]; CPTGradient *areaGradient1 = [CPTGradient gradientWithBeginningColor:areaColor1 endingColor:[CPTColor clearColor]]; areaGradient1.angle = -90.0f; boundLinePlot.areaBaseValue = [[NSDecimalNumber zero] decimalValue]; // Add plot symbols CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle]; symbolLineStyle.lineColor = [CPTColor blackColor]; CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol]; plotSymbol.fill = [CPTFill fillWithColor:[CPTColor blueColor]]; plotSymbol.lineStyle = symbolLineStyle; plotSymbol.size = CGSizeMake(10.0, 10.0); boundLinePlot.plotSymbol = plotSymbol; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload