我在我的iphone应用程序中使用核心绘图.如何在散点图中添加图例.谁能帮我?
提前致谢
根据不同的教程,我使用Core-Plot成功创建了一个散点图.现在,在X轴上设置日期我得到了完全错误的日期.我的图形源是一个包含字典的数组.在字典的每个记录中,字典的第一个键是unix时间戳,第二个键是绘制的值.它看起来像这样:
(
{
0 = 1334152500;
1 = 0;
},
{
0 = 1334152800;
1 = 0;
},
{
0 = 1334153100;
1 = 0;
},
Run Code Online (Sandbox Code Playgroud)
AFAIK Core-Plot需要一个开始日期和一个步骤.在这种情况下,开始日期是1334152500(2012年4月11日星期三,格林尼治标准时间13:55:00),步骤是300秒.每隔300秒就会出现一个新值.现在我用来绘制X轴的代码:
// this string contains the first UNIX Timestamp registered
NSString *tstamp_start = [NSString stringWithFormat:@"%@", [[[self.graphData objectForKey:@"1"] objectAtIndex:0] objectForKey:@"0"]];
NSDate *refDate = [NSDate dateWithTimeIntervalSince1970:[tstamp_start doubleValue]];
// definition of the graph skipped...
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)self.graph.axisSet;
// tInterval is previous set to 300 - float.
// here I should set the Interval between …Run Code Online (Sandbox Code Playgroud) 我现在开始使用核心情节,并遇到了一些问题.我按照本页的教程:http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application
并按照此页面上的说明完成:http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications(例如-all_load).
但我仍有一些问题,我得到以下错误:
error: incompatible type for argument 1 of 'setMajorIntervalLength:'
error: request for member 'axisLabelOffset' in something not a structure or union
error: incompatible type for argument 1 of 'setMajorIntervalLength:'
error: request for member 'axisLabelOffset' in something not a structure or union
error: request for member 'bounds' in something not a structure or union
error: request for member 'defaultPlotSymbol' in something not a structure or union
error: request for member 'bounds' in …Run Code Online (Sandbox Code Playgroud) 是否有一些示例代码或有关如何使用Core Plot框架绘制折线图的教程?我找不到任何使用谷歌的东西.
我在我的iPhone应用程序中实现了核心情节.我正在使用梯度散点图,如下所示:

如何删除上述核心图中图形的Y轴上出现的水平标记?
我目前正在尝试使用核心图库来绘制我通过JSON获得的一些数据.我试图在同一个图表上绘制两个图表,但我无法实现这一点.当我只绘制一个图表时,它可以正常工作.
下面是我使用核心图库的散点图代码.
#pragma mark -
#pragma mark Plot construction methods
- (void)constructScatterPlot
{
NSMutableArray *appleContentArray = [NSMutableArray arrayWithCapacity:270];
NSMutableArray *googleContentArray = [NSMutableArray arrayWithCapacity:270];
NSData *stocks = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://d1sz0kydzogekx.cloudfront.net/stocks.txt"]];
NSInputStream *stockStream = [[NSInputStream alloc] initWithData:stocks];
[stockStream open];
NSUInteger i;
i = 1;
if (stockStream) {
NSError *parseError = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithStream:stockStream options:NSJSONReadingAllowFragments error:&parseError];
if ([jsonObject respondsToSelector:@selector(objectForKey:)]) {
for (NSDictionary *stock in [jsonObject objectForKey:@"stocks"]) {
if ([[stock objectForKey:@"stock"] isEqualToString:@"AAPL"]){
id x = [NSNumber numberWithInt:i];
id y = [stock …Run Code Online (Sandbox Code Playgroud) 我工作核心图BarChart使用RGB应用条形颜色不起作用..!
它只是工作的主要颜色,如红色,绿色,蓝色,白色,紫色..!
我试着申请Orange不申请.任何人帮助我......!
[CPTColor colorWithComponentRed:255 green:163 blue:0 alpha:1]
Run Code Online (Sandbox Code Playgroud)
它是橙色RGB颜色值.但是,仅适用于黄色....!
我想在Y轴上只绘制10个Majors Ticks.为此,我正在使用方法preferredNumberOfMajorTicks = 10.
但正如屏幕截图所示,它并没有真正起作用......

这是我对y轴的配置:
CPTXYAxis *y = axisSet.yAxis;
y.labelingPolicy = CPTAxisLabelingPolicyFixedInterval;
//y.majorIntervalLength = CPTDecimalFromDouble(2);
y.preferredNumberOfMajorTicks = 10;
y.minorTicksPerInterval = 5;
y.tickDirection = CPTSignNone;
y.majorTickLineStyle = majorLineStyle;
y.minorTickLineStyle = minorLineStyle;
y.axisLineStyle = majorLineStyle;
y.majorTickLength = 7.0;
y.minorTickLength = 5.0;
y.labelTextStyle = whiteTextStyle;
y.minorTickLabelTextStyle = minorTickBlackTextStyle;
y.titleTextStyle = whiteTextStyle;
y.axisConstraints = [CPTConstraints constraintWithLowerOffset:40.0];
Run Code Online (Sandbox Code Playgroud)
有些东西应该超过正确的方法,preferredNumberOfMajorTicks = 10但我看不出是什么......
我刚刚完成了我的应用程序,并添加了一些伟大的东西与核心情节和他们的专职人员的帮助.我的问题涉及使用视网膜显示器的图像.我有一个注释,是一个讲话泡泡的图片.当我在模拟器中运行应用程序时,它显示正常分辨率,但当我切换到视网膜时,图像被裁剪.见下图.我有一个.png,我称之为Bubble,我又添加了另一个名为Bubble @ 2x的大小两倍,我认为这是我需要做的.那没用.所以我试着设置view.contentScale,见下面的代码.但似乎没有任何效果.任何人都有任何想法,我忘了做什么?再次感谢.
{
//first annotation
NSValue *value = [self.myData objectAtIndex:index];
CGPoint point = [value CGPointValue];
NSString *number1 = [NSString stringWithFormat:@"(%.2f, ", point.x];
NSString *number2 = [NSString stringWithFormat:@"%.2f)", point.y];
NSNumber *x = [NSNumber numberWithFloat:point.x];
NSNumber *y = [NSNumber numberWithFloat:point.y];
NSArray *anchorPoint = [NSArray arrayWithObjects: x, y, nil];
NSString *final = [number1 stringByAppendingString:number2];
//second annotation
UIImage *bubble = [UIImage imageNamed:@"Bubble.png"];
CPTImage *fillimage = [CPTImage imageWithCGImage:bubble.CGImage];
CPTBorderedLayer *imageLayer = [[CPTBorderedLayer alloc] init];
//imageLayer.contentsScale = [[UIScreen mainScreen] scale]; //tried this
imageLayer.frame = CGRectMake(0, …Run Code Online (Sandbox Code Playgroud) 我已经附加了我正在使用的整个代码,但是没有生成x轴标签.我不知道哪里出错了.我是核心情节中的菜鸟.请帮我解决.谢谢你,快乐新人年.
#import "BarPlotViewController.h"
@interface BarPlotViewController ()
@end
@implementation BarPlotViewController
#define BAR_POSITION @"POSITION"
#define BAR_HEIGHT @"HEIGHT"
#define COLOR @"COLOR"
#define CATEGORY @"CATEGORY"
#define AXIS_START 0
#define AXIS_END 50
//
@synthesize data;
@synthesize graph;
@synthesize hostingView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.data = [NSMutableArray array];
int bar_heights[] = {20,30,10,40};
UIColor *colors[] = {
[UIColor redColor],
[UIColor blueColor],
[UIColor orangeColor],
[UIColor purpleColor]};
NSString *categories[] = {@"Plain Milk", @"Milk + Caramel", @"White", @"Dark"};
for (int …Run Code Online (Sandbox Code Playgroud)