Core Plot を使用して経時的にグラフをプロットしています。現在、x 軸の labelingPolicy を に設定していCPTAxisLabelingPolicyAutomatic
ます。ただし、画像の描画には右下隅を使用したいと思います。したがって、プロットがその領域にラベルを描画しないようにする必要があります。labelExclusionRanges を使用することも考えましたが、物理サイズから時間値の範囲へのマッピングが必要です。私の目標を達成するためのより簡単な方法はありますか?
エリックの答えをコードに変換しようとすると、画像が表示されますが、現在は x 軸の横に配置されていますが、実際には x 軸ラベルの右側に配置したいのです。また、グラフのホストビューから部分的に外れています...
[更新: 実際に画像を表示するには、layer.frame を設定する必要があります。]
- (void)annotateXAxisOfGraph:(CPTGraph *)graph withImage:(CPTImage *)image
{
CPTBorderedLayer *layer = [[[CPTBorderedLayer alloc] init] autorelease];
layer.fill = [CPTFill fillWithImage:image];
layer.frame = CGRectMake(0.0f, 0.0f, 40.0f, 40.0f);
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTLayerAnnotation *layerAnnotation = [[[CPTLayerAnnotation alloc] initWithAnchorLayer:axisSet.xAxis] autorelease];
layerAnnotation.contentLayer = layer;
layerAnnotation.rectAnchor = CPTRectAnchorBottomRight;
[graph addAnnotation:layerAnnotation];
}