In order to explain the convenience, I enclose the source code and the effect chart first.
The code is as follows:
Using System;
Using System.Drawing;
Using System.Collections;
Using Zedgraph;
Namespace Zedgraph.demo
{
<summary>
Summary description for Simpledemo.
</summary>
public class Modinitialsampledemo:demobase
{
Public Modinitialsampledemo (): Base ("Code Project Modified Initial Sample",
"Modified Initial Sample", demotype.tutorial)
{
Graphpane Mypane = base. Graphpane;
Set up the title and axis labels
Mypane.title = "My Test graphn (for CodeProject Sample)";
MyPane.XAxis.Title = "My X Axis";
MyPane.YAxis.Title = "My Y Axis";
Make up some data arrays based on the Sine function
Pointpairlist List1 = new Pointpairlist ();
Pointpairlist list2 = new Pointpairlist ();
for (int i=0; i<36; i++)
{
Double x = (double) i + 5;
Double y1 = 1.5 + Math.sin ((double) I * 0.2);
Double y2 = 3.0 * (1.5 + math.sin (double) I * 0.2));
List1. ADD (x, y1);
List2. ADD (x, y2);
}
Generate a red curve with diamond
Symbols, and "Porsche" in the legend
LineItem Mycurve = Mypane.addcurve ("Porsche",
List1, Color.Red, Symboltype.diamond);
Generate a blue curve with circle
Symbols, and "Piper" in the legend
LineItem myCurve2 = Mypane.addcurve ("Piper",
List2, Color.Blue, symboltype.circle);
Change the color of the title
MyPane.FontSpec.FontColor = Color.green;
ADD gridlines to the plot, and make them gray
MyPane.XAxis.IsShowGrid = true;
MyPane.YAxis.IsShowGrid = true;
MyPane.XAxis.GridColor = Color.lightgray;
MyPane.YAxis.GridColor = Color.lightgray;
Move the legend location
Base. Pane.Legend.Position = ZedGraph.LegendPos.Bottom;
Make both curves thicker
MyCurve.Line.Width = 2.0F;
MyCurve2.Line.Width = 2.0F;
Fill the area under the curves
MyCurve.Line.Fill = new Fill (Color.White, color.red, 45F);
MyCurve2.Line.Fill = new Fill (Color.White, Color.Blue, 45F);
Increase the symbol sizes, and fill them with solid white
MyCurve.Symbol.Size = 8.0F;
MyCurve2.Symbol.Size = 8.0F;
MyCurve.Symbol.Fill = new Fill (color.red);
MyCurve2.Symbol.Fill = new Fill (color.white);
Add a background gradient fill to the axis frame
Mypane.axisfill = new Fill (Color.White,
Color.FromArgb (255, 255, 210), -45f);
ADD a caption and an arrow
Textitem myText = new Textitem ("Interestingnpoint", 23F, 7F);
MyText.FontSpec.FontColor = color.red;
MyText.Location.AlignH = Alignh.center;
MyText.Location.AlignV = Alignv.top;
MYPANE.GRAPHITEMLIST.ADD (MyText);
Arrowitem Myarrow = new Arrowitem (color.red, 12F, 7F, 5F, 20F, 8F);
MYPANE.GRAPHITEMLIST.ADD (Myarrow);
Base. Zedgraphcontrol.axischange ();
}
}
}