Is there a way to have gnuplot use xaxis time data, but skip certain intervals (e.g. non-trading hours)

前提是你 提交于 2020-01-05 08:39:15

问题


I'm collecting pricing data on stocks and options during trading hours and appending them to a data file that I plot with gnuplot. The file looks like:

2013-01-30--15:58:14 38.68 0.64
2013-01-30--15:58:44 38.70 0.64
2013-01-30--15:59:15 38.70 0.64
2013-01-30--15:59:45 38.69 0.64

I end up with large periods of time that I don't collect any data for since the markets are closed.

When I plot this data with gnuplot, using xdata as timefmt, it displays large gaps from the end of one day to the start of another.

I'd prefer to have it skip those times during the days where there is no actual data... Is there a way to do this?

I've been able to come close by not plotting the data against the time value in the first column, but I'd like to show the time data AS WELL AS skip those times when the data was not collected.

I hope this makes sense and appreciate your help.


回答1:


If I understood correctly, you can make good use of a broken axis on x.

There are two ways to obtain broken axis. The first one relies on ternary operators to plot the data only in the region of your interest, which in your case should not even be necessary, and shifting the xtics left in order to reduce the dimension of the empty region. This is a nice tutorial:

http://gnuplot-tricks.blogspot.com/2009/06/broken-axis-revisited.html

The second one makes uses of multiplots instead. This is probably better suit to your needs.

http://gnuplot-tricks.blogspot.com/2010/06/broken-axis-once-more.html

Hope it helps.



来源:https://stackoverflow.com/questions/14618708/is-there-a-way-to-have-gnuplot-use-xaxis-time-data-but-skip-certain-intervals

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!