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.
How to fill graph area with Color
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);
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 Plot –
Monseigneur
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
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.
© 2022 - 2024 — McMap. All rights reserved.