How to fill graph area with Color
Asked Answered
M

2

10

I am trying to plot graph in which i want to fill graph area with custom color. But the color should be below only data lines which i have used to draw line graph and the remaining part should be as such.

Monseigneur answered 19/2, 2012 at 17:28 Comment(0)
Z
13

Set the areaBaseValue and areaFill properties. The base value is the lower boundary of the filled area. This is normally set to the location value of the yRange so that the fill starts at the bottom of the plot area, but it doesn't have to be. The fill can be any CPTFill—a solid color (with optional transparency), an image, or a gradient. For example:

plot.areaFill = [CPTFill fillWithColor:[CPTColor redColor]];
plot.areaBaseValue = CPTDecimalFromInteger(0);
Zoonosis answered 19/2, 2012 at 19:2 Comment(4)
Hey Eric thanks for such kind of effort. I want to clear a point here. Think that i have points from 0 to 10 on x axis and points are (5,8),(6,9),(8,6). I want to color only that part which falls below this line and x axis. Is the plot.areaFill will work for such type of requirement.Monseigneur
Yes. For example, if the axes cross at (0, 0), set the areaBaseValue as shown in my answer. This will fill between the plot line and the x-axis.Zoonosis
Hey Eric i like to work on graph can you tell me any link which can help a lot in learning basic concepts about Core PlotMonseigneur
I'm not aware of any comprehensive resource that goes through everything. There are wiki pages at the Core Plot page on Google Code, the Documentation folder in the Core Plot package, and the API docs—available online (links on the front page of the Core Plot site) and as Xcode docsets. Core Plot includes a number of example apps that demonstrate a lot of the basic concepts, but they don't explore all of the options for every feature. They're useful for figuring out how to do something, but not so much for why it's done that way.Zoonosis
P
0

You have to draw (fill) the graph as a closed path with a fill color.

Then, if you also want to have the graph drawn with a stroke, you can redraw (stroke) only the path that defines the lines of the graph with a stroke color.

Postrider answered 19/2, 2012 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.