You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否设置非起始于00:00:00.000的X轴网格?附gnuplot配置指令

Adjusting Gnuplot X-Axis Grid to Start at Non-00:00:00.000 Time

Absolutely you can tweak your gnuplot configuration to make the X-axis grid start at a time other than 00:00:00.000—let’s adjust your existing setup to get this working smoothly.

Background

Your current config already sets up a time-based X-axis, so we just need to align the grid with either custom starting ticks or explicit grid positions. Here are two straightforward approaches:


Approach 1: Align Grid with Custom Starting X-Tics

This is the simplest method—since the grid defaults to align with your X-axis ticks, you just need to set your xtics to start at your desired time, and the grid will follow suit automatically.

Update your config like this:

# Keep your existing core settings
set grid x layerdefault front
set xtics nomirror
set ytics nomirror
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%.3S"

# Define your desired grid start time (example: 00:05:00.000)
desired_start = "00:05:00.000"
maxtime = "01:00:00.000"  # Replace with your actual max time value

# Optional: Adjust xrange to exclude the 00:00 to start time range
set xrange [desired_start:maxtime]

# Set xtics to start at your desired time, with your preferred increment
set xtics start desired_start increment 300  # Increment = 300 seconds (5 minutes)
  • The set xtics start command tells gnuplot to begin generating ticks at your specified time.
  • Since set grid x is enabled, grid lines will automatically align with these custom ticks, starting at desired_start instead of 00:00:00.000.

Approach 2: Manually Specify Grid Positions

If you want grid lines independent of your X-axis ticks (e.g., ticks start at 00:00 but grid starts later), you can explicitly define where grid lines appear using set grid x at.

Use the strptime function to convert your desired time into gnuplot’s internal numeric time format, then define grid positions:

# Keep your existing core settings
set grid x layerdefault front
set xtics nomirror
set ytics nomirror
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%.3S"

set xrange ["00:00:00.000":maxtime]

# Convert your desired grid start time to gnuplot's numeric time value
grid_start = strptime("%H:%M:%S", "00:05:00")
# Define grid lines starting at grid_start, every 5 minutes (300 seconds)
set grid x at grid_start, grid_start+300, grid_start+600, grid_start+900  # Extend this list as needed for your time range
  • This method gives you full control over exactly where grid lines are drawn, even if they don’t match up with your axis ticks.

Quick Tips

  • Ensure your desired_start time matches the format specified in timefmt (in your case, %H:%M:%S—you can include .000 since strptime will ignore the decimal, or adjust timefmt to "%H:%M:%S.%3S" for strict millisecond parsing).
  • If you leave xrange starting at 00:00:00.000, the grid will still begin at your desired time, leaving the early time range without grid lines.

内容的提问来源于stack exchange,提问作者Mkn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 22:32:45