Reputation: 127
I'm trying to create a Chart image which consists of five subcharts.(see Picture)
The X Axis of the Chart should be the same for all 5 subcharts.
How can I realize that with MS Chart Controls?
Currently I'm creating all five Charts, but I have no idea how I can merge the xAxis and how to fit all 5 subcharts into an Image file or Chart.
Thanks for you help in advance!
Upvotes: 2
Views: 424
Reputation: 3177
You can do that:
ccc =[1, 2, 3, 4,5]
aaa = [11, 8, 12, 3,6]
bbb = [22,24,21,19,20]
ddd = [1,0,2,0,5]
fff = [32,32,41,35,16]
df = pd.DataFrame({'ID': ccc, 'AAA': aaa,'BBB': bbb, 'DDD': ddd, 'FFF': fff })
f, axarr =plt.subplots(5, 1, figsize=(14, 7))
df['BBB'].plot(ax=axarr[0])
df['AAA'].plot(ax=axarr[1])
df['FFF'].plot(ax=axarr[2])
df['DDD'].plot(ax=axarr[3])
df['BBB'].plot(ax=axarr[4])
Upvotes: -1
Reputation: 3141
MsChart
allows multiple ChartArea
. Each chart area can have multiple Series
.
As per your screen designs, there will be 5 Chart areas. Each ChartArea
will have 1 series added to it.
var chartArea1 = MyChart.ChartAreas.Add("ChartArea 1");
:
var chartArea5 = MyChart.ChartAreas.Add("ChartArea 5");
Add Series to charts and assign the chart area
MyChart.Series[0].ChartArea = chartArea1.Name;
MyChart.Series[5].ChartArea = chartArea5.Name;
Now, to have a common X axis, assign the
chartArea1.AlignWithChartArea = chartArea5.Name;
chartArea2.AlignWithChartArea = chartArea5.Name;
You can also refer the link for MSChart.
Update for Chart Area placement Below code is to shows how to position the chart areas within a chart control. Note:- X and Y position are in percentage rather then pixels, twips, etc.
chartArea1.Position.Y = 0;
chartArea1.Position.Height = 43;
chartArea1.Position.Width = 100;
chartArea2.Position.Y = chartArea1.Position.Bottom + 1;
chartArea2.Position.Height = chartArea1.Position.Height;
chartArea2.Position.Width = chartArea1.Position.Width;
Upvotes: 3