iOS Core Plot-散点图符号颜色外观 [英] iOS Core Plot - Scatter plot symbol color appearance

查看:176
本文介绍了iOS Core Plot-散点图符号颜色外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CorePlot进行散点图绘制,并且想知道如何获得具有这种颜色效果的散点图圆,如此处 http://i.stack.imgur.com/7ZcqY.jpg
我想像CPTXYScatterPlot-我可以设置绘图符号的Z顺序吗?。 p>

I am using CorePlot for Scatter plot and would like to know how to obtain the circles of the scatter plot with such a color effect as it is here http://i.stack.imgur.com/7ZcqY.jpg I would like to get the color as in CPTXYScatterPlot - Can I set the Z order of plot symbols?.

推荐答案

在您的 symbolForScatterPlot 实现中,创建一个带有渐变填充的circlePlotSymbol,例如因此:

In your symbolForScatterPlot implementation, create a circlePlotSymbol with a gradient fill, like so:

CPTPlotSymbol *circlePlotSymbol = [CPTPlotSymbol ellipsePlotSymbol];

// Obviously for a real bubble chart you'll want to get the color from somewhere so they're not all the same
CPTColor *endColor = [CPTColor redColor];
CPTColor *startColor = [endColor colorWithAlphaComponent:0.4f];
CPTGradient *gradient = [CPTGradient gradientWithBeginningColor:startColor endingColor:endColor];

然后将渐变类型设置为Radial,并将渐变设置为plotSymbol上的填充。如果希望它看起来像是从某个角度照亮的,则可以将startAnchor设置为偏离中心的点:

Then set the gradient type to Radial, and set your gradient as the fill on your plotSymbol. If you want it to look like it's lit from an angle, you can set the startAnchor to a point off center:

gradient.gradientType = CPTGradientTypeRadial;
graphGradient.startAnchor = CGPointMake(0.35, 0.75);
circlePlotSymbol.fill = [CPTFill fillWithGradient:gradient];

如果您不想在圆周围画边框,请将线型颜色设置为清除和/或将宽度设置为0.0f(可能不需要两者都做):

If you don't want a border around your circles, set the linestyle color to clear and/or set the width to 0.0f (probably don't need to do both):

CPTMutableLineStyle *lineStyle = [[CPTMutableLineStyle alloc] init];
lineStyle.lineColor = [CPTColor clearColor];
lineStyle.lineWidth = 0.0f;
circlePlotSymbol.lineStyle = lineStyle;
[lineStyle release];

设置气泡的大小:

// For a real bubble chart, you'll need to calculate this from your data
circlePlotSymbol.size = CGSizeMake(50.0f, 50.0f);

并返回绘图符号:

return circlePlotSymbol;

应该这样做。我前面没有代码,所以我要从内存中移出(请原谅任何拼写错误或语法错误,因为我现在也无法访问编译器),但希望这会关闭足以使您指出正确的方向。

That should do it. I don't have my code in front of me so I'm going from memory here (and please forgive any typos or bad syntax, as I don't have access to a compiler right now either), but hopefully this will be close enough to get you pointed in the right direction.

这篇关于iOS Core Plot-散点图符号颜色外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆