开发者

How to display several graphs which have common X Axis using ZedGraph library?

开发者 https://www.devze.com 2023-03-17 22:40 出处:网络
I need to display several graphs which have a common X Axis and a legend. What I want to achieve is displayed on the picture.开发者_StackOverflow中文版 The main goal is to have several Y Axis on the o

I need to display several graphs which have a common X Axis and a legend. What I want to achieve is displayed on the picture.开发者_StackOverflow中文版 The main goal is to have several Y Axis on the one line, not paralelly. So, several curves can be displayed without intersection with each other.

I know how to display several graphs, but then each of them has its own legend and Y Axis.

How to display several graphs which have common X Axis using ZedGraph library?


I worked with ZedGraph in two of my projects and it doesn't seem to support this feature. Basically, you have two options at this point:

1. Use another plotting library

If you don't have a lot of things depending on ZedGraph already, maybe it's not too late for switching to another plotting control. I worked with this library (CodeProject link), and it has a decent look and support for stacked graphs:

How to display several graphs which have common X Axis using ZedGraph library?

It's less feature-rich compared to ZedGraph, but if 2d-plotting is all you really need, you should probably give it a try.

2. Cheat by creating multiple ZedGraph panes

You can make all your graphs panes have the same width and the same zoom. By setting IsSynchronizeXAxes property to true you make sure that all the panes on ZedGraph control have their X-Axes synchronized automatically.

There are few useful articles to help you achieve the effect you want. Although in Russian, they provide code samples and illustrations and should be of use even without understanding the comments.

  • Plotting multiple graphs on single ZedGraph control
  • Multiple graphs layout
  • Synchronizing zoom and pan on multiple graphs
  • Aligning graph panes properly

You should also hide X-axis and everything else that you don't need. Single legend is tricky but can be achieved by only showing a legend for the topmost graph and adding fake dummy curves with no points to this graph to populate the legend.

0

精彩评论

暂无评论...
验证码 换一张
取 消