如何使用 core plot ios sdk 在 x 轴上显示时间

how to show time on x axis using core plot ios sdk

我需要帮助我想在 CorePlot 中使用缩放图创建 z 轴。

- (void)viewDidLoad
{
    [super viewDidLoad];

    // We need a hostview, you can create one in IB (and create an outlet) or just do this:
    CPTGraphHostingView* hostView = [[CPTGraphHostingView alloc] initWithFrame:self.view.frame];
    [self.view addSubview: hostView];

    // Create a CPTGraph object and add to hostView
    CPTGraph* graph = [[CPTXYGraph alloc] initWithFrame:hostView.bounds];
    hostView.hostedGraph = graph;

    // Get the (default) plotspace from the graph so we can set its x/y ranges
    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;

    // Note that these CPTPlotRange are defined by START and LENGTH (not START and END) !!
    [plotSpace setYRange: [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat( 0 ) length:CPTDecimalFromFloat( 16 )]];
    [plotSpace setXRange: [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat( -4 ) length:CPTDecimalFromFloat( 8 )]];

    // Create the plot (we do not define actual x/y values yet, these will be supplied by the datasource...)
    CPTScatterPlot* plot = [[CPTScatterPlot alloc] initWithFrame:CGRectZero];

    // Let's keep it simple and let this class act as datasource (therefore we implemtn <CPTPlotDataSource>)
    plot.dataSource = self;

    // Finally, add the created plot to the default plot space of the CPTGraph object we created before
    [graph addPlot:plot toPlotSpace:graph.defaultPlotSpace];
}

如何根据绘图点设置 x 轴时间,如 1:30,1:32,1:35。

几个 Core Plot 示例应用程序展示了如何创建多个 x 轴或 y 轴。例如,请参阅 Plot Gallery 应用程序中的 "Axis Demo" 和 "Labeling Policy Demo" 共享同一绘图 space 的多个轴。 "Plot Space Demo" 展示了如何在图表中创建多个图 space 并为每个图分配不同的轴。

如果您想保留默认的 x 轴和 y 轴并添加新轴,请制作 graph.axisSet.axes 数组的可变副本,将新轴添加到数组中,然后将新轴数组赋值回来到 graph.axisSet.axes 属性.

Core Plot 目前不支持 3D 图形,因此您无法添加真正的 z 轴。您也许可以用散点图伪造它,但您必须自己完成所有 3D 变换数学运算。