Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy won't my x-axis show with core-plot on the iPhone?
    primarykey
    data
    text
    <p><strong>EDIT: I think my question is better phrased as: How can I have a Y-axis that doesn't start at zero? It seems like the x-axis always gets placed at the y=0, but I would like the x-axis to be at some positive number on the y-axis.</strong></p> <p><strong>Here's a graph with more regular data... I just wish the x-axis was placed at the minimum y-value for the plot (about 77), instead of at 0.</strong></p> <p><img src="https://farm5.static.flickr.com/4015/4271186240_8e2f8f73c9.jpg" alt="alt text"></p> <p>Here is the function I use to create the graph.</p> <p>It's a whole bunch of code, and I'm not quite sure which piece might be off to not display the x-axis. </p> <p>Could the x-axis not showing have something to do with my data?</p> <pre><code>- (void) showGraph:(SavedDetailScreen*)dataSource { // create the graph and add it to the view CPXYGraph *graph = [[CPXYGraph alloc] initWithFrame: CGRectZero]; graph.plotArea.masksToBorder = NO; CPLayerHostingView *graphView = [[CPLayerHostingView alloc] initWithFrame:CGRectMake(0,0, 280, 240)]; [self addSubview:graphView]; graphView.hostedLayer = graph; graph.paddingLeft = 50.0; graph.paddingTop = 20.0; graph.paddingRight = 10.0; graph.paddingBottom = 40.0; // set up the ranges for the graph axis float minElevation = dataSource.track.tbStats.minAlt; float maxElevation = dataSource.track.tbStats.maxAlt-dataSource.track.tbStats.minAlt; float minDistance = 0.0f; float maxDistance = dataSource.track.tbStats.totalDistance; CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace; plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(minDistance) length:CPDecimalFromFloat(maxDistance)]; plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(minElevation) length:CPDecimalFromFloat(maxElevation)]; // style the graph with white text and lines CPTextStyle *whiteText = [CPTextStyle textStyle]; whiteText.color = [CPColor whiteColor]; CPLineStyle *whiteStyle = [CPLineStyle lineStyle]; whiteStyle.lineColor = [CPColor whiteColor]; whiteStyle.lineWidth = 2.0f; // set up the axis CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet; CPXYAxis *x = axisSet.xAxis; CPXYAxis *y = axisSet.yAxis; x.majorIntervalLength = CPDecimalFromFloat(maxDistance/10.0f); x.minorTicksPerInterval = 0; x.majorTickLineStyle = whiteStyle; x.minorTickLineStyle = whiteStyle; x.axisLineStyle = whiteStyle; x.minorTickLength = 5.0f; x.majorTickLength = 10.0f; x.labelOffset = 3.0f; x.labelTextStyle = whiteText; y.majorIntervalLength = CPDecimalFromFloat(maxElevation/5.0f); y.minorTicksPerInterval = 0; y.majorTickLineStyle = whiteStyle; y.minorTickLineStyle = whiteStyle; y.axisLineStyle = whiteStyle; y.minorTickLength = 5.0f; y.majorTickLength = 10.0f; y.labelOffset = 3.0f; y.labelTextStyle = whiteText; CPScatterPlot *plot = [[[CPScatterPlot alloc] initWithFrame:graph.bounds] autorelease]; plot.dataLineStyle.lineWidth = 2.0f; plot.dataLineStyle.lineColor = [CPColor blueColor]; plot.dataSource = dataSource; [graph addPlot:plot]; CPPlotSymbol *greenCirclePlotSymbol = [CPPlotSymbol ellipsePlotSymbol]; greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]]; greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0); plot.plotSymbol = greenCirclePlotSymbol; } </code></pre> <p><img src="https://farm5.static.flickr.com/4042/4270334347_d291f65f3a.jpg" alt="alt text"></p>
    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.
 

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