Draw axis thru x=0 and y=0

2019-07-20 08:23发布

I have a set of data that I'm plotting as a scatter graph which has both positive and negative values on both axis. When I plot this in Flot, the axis are draw at the bottom and the left by default. Is there a way to make it draw the axis through the center of the graph? @X=0 and Y=0?

In other words, instead of this:

enter image description here

I want something like this:

enter image description here

标签: flot
2条回答
老娘就宠你
2楼-- · 2019-07-20 09:04

That isn't possible in the default flot. I'm sure it could be hacked in if you wanted to dig into the source, but flot by itself only supports left/right for the y-axis, and top/bottom for the x-axis.

查看更多
不美不萌又怎样
3楼-- · 2019-07-20 09:27

In case anybody else comes across the same need, I created a plugin for Flot and put it here:

https://github.com/burlandm/Flot-Origin-Axis

It does what I need, but I won't make any promises that it'll fit your particular scenario. If I have time, I might try and update it to cover more scenarios.

查看更多
登录 后发表回答