Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:18:50+00:00 2026-05-31T07:18:50+00:00

I’m making a graph for an iOS app, using Core Plot 1.0 and iOS

  • 0

I’m making a graph for an iOS app, using Core Plot 1.0 and iOS 5.1.

I’ve went through all the tutorials I can find for core plot and have everything showing on my graph except the scatterplot data itself…

Can’t post a screenshot because of reputation so here is a link to one: http://francoismaillet.com/coreplot_problem.png

I’m using the numberOfRecordsForPlot and numberForPlot methods from the SimpleScatterPlot.m example. The generateData method generates numbers between 0 and 2.

I’ve been turning in circles for a while and any help would be greatly appreciated.

Here’s my class interface:

interface PriceChartViewController : UIViewController <CPTPlotDataSource, CPTScatterPlotDelegate>{
    NSArray *plotData;
}

Here’s my viewDidLoad method:

- (void)viewDidLoad {
    [super viewDidLoad];
    [self generateData];

    CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];

    CPTXYGraph *graph = [[[CPTXYGraph alloc] initWithFrame:self.view.bounds] autorelease];
    CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
    [graph applyTheme:theme];

    hostingView.hostedGraph = graph;
    //hostingView.collapsesLayers = YES;

    graph.paddingLeft   = 15.0;
    graph.paddingTop    = 40.0;
    graph.paddingRight  = 15.0;
    graph.paddingBottom = 40.0;


    // Get plotSpace from graph
    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
    plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-2)
                                                   length:CPTDecimalFromFloat(4)];
    plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-2)
                                                   length:CPTDecimalFromFloat(4)];

    [graph addPlotSpace:plotSpace];


    // Get axisset from graph
    CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;


    CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
    majorGridLineStyle.lineWidth = 1.0f;
    majorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.75f];

    CPTMutableLineStyle *minorGridLineStyle = [CPTMutableLineStyle lineStyle];
    minorGridLineStyle.lineWidth = 1.0f;
    minorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.25f];


    CPTXYAxis *x = axisSet.xAxis;
    x.title = @"X axis";
    x.titleOffset = -20.0f;
    x.titleLocation = CPTDecimalFromFloat(30.0f);

    x.majorGridLineStyle = majorGridLineStyle;
    x.minorGridLineStyle = minorGridLineStyle;

    x.majorIntervalLength = CPTDecimalFromInteger(1);
    x.minorTicksPerInterval = 0.5;
    x.plotSpace = plotSpace;       


    CPTXYAxis *y = axisSet.yAxis;
    y.majorIntervalLength = CPTDecimalFromInteger(1);
    y.minorTicksPerInterval = 0.5;
    //y.orthogonalCoordinateDecimal = CPTDecimalFromInteger(-0.5);
    //y.preferredNumberOfMajorTicks = 8;
    y.plotSpace = plotSpace;


    // Create scatterplot
    CPTScatterPlot *dataSourceLinePlot = [[CPTScatterPlot alloc] init];
    dataSourceLinePlot.identifier = @"AllTests";

    CPTMutableLineStyle *lineStyle   = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
    //lineStyle.miterLimit             = 1.0f;
    lineStyle.lineWidth              = 3.0f;
    lineStyle.lineColor              = [CPTColor blueColor];
    dataSourceLinePlot.dataLineStyle = lineStyle;
    dataSourceLinePlot.dataSource    = self;
    [graph addPlot:dataSourceLinePlot];

    // 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;
    CPTFill *areaGradientFill   = [CPTFill fillWithGradient:areaGradient1];
    dataSourceLinePlot.areaFill = areaGradientFill;
    dataSourceLinePlot.areaBaseValue = [[NSDecimalNumber zero] decimalValue];

    // Auto scale the plot space to fit the plot data
    // Extend the ranges by 30% for neatness
    [plotSpace scaleToFitPlots:[NSArray arrayWithObjects:dataSourceLinePlot, nil]];
    CPTMutablePlotRange *xRange = [[plotSpace.xRange mutableCopy] autorelease];
    CPTMutablePlotRange *yRange = [[plotSpace.yRange mutableCopy] autorelease];
    [xRange expandRangeByFactor:CPTDecimalFromDouble(1.3)];
    [yRange expandRangeByFactor:CPTDecimalFromDouble(1.3)];
    plotSpace.xRange = xRange;
    plotSpace.yRange = yRange;


    graph.legend                     = [CPTLegend legendWithGraph:graph];
    graph.legend.textStyle           = x.titleTextStyle;
    graph.legend.fill                = [CPTFill fillWithColor:[CPTColor darkGrayColor]];
    graph.legend.borderLineStyle     = x.axisLineStyle;
    graph.legend.cornerRadius        = 5.0;
    graph.legend.swatchSize          = CGSizeMake(25.0, 25.0);
    graph.legendAnchor               = CPTRectAnchorBottom;
    graph.legendDisplacement         = CGPointMake(0.0, 12.0);


    [self setView:hostingView];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:18:52+00:00Added an answer on May 31, 2026 at 7:18 am

    Turns out the code ran fine when I tried with the latest core plot source (revision 6f43faadc647), which is strange since nothing really seems to have changed since the 1.0 release.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.