Plotting: Specifying number and intervals for vertical lines on x-axis

Hey community,

I’m stuck with plotting: How do I specify number and intervals for vertical lines on my x-axis?
I tried around with the grid argument of a ControlSpec for Plot’s domainSpecs which seems to need GridLines (which again needs a ControlSpec) but I don’t succeed.

Anyone got experience in this?

Here’s a draft setting grids for every 5th value(?)

var data = Array.fill(128, { 0.rrand(60.0) });

a = data.plot();

a.domainSpecs = ControlSpec(
	minval: nil,
	maxval: nil,
	warp: 'lin',
	step: 0.0,
	default: nil,
	grid: DrawGrid(vertGrid: GridLines(, nil, \lin, 5?!))) // maybe option 1?
	grid: GridLines(, nil, \lin, 5?!)) // maybe option 2?


Thank you all xx

I’ve spent a lot of time on this and can’t seem to find a good solution…

Setting .domainSpec won’t help you. If you do set it to 5, it changes the way the data is plotted, not the grid lines. Observe:

d = Array.fill(128, { 0.rrand(60.0) }); //data

a = d.plot.domainSpecs_([0,128,\lin,5].asSpec);

I think you need to include the DrawGrid in the drawFunc method of the Plotter or its window, but I still don’t have it working. The best I can get is still grid lines at 50.

Thank you for your time…

I see…

I came across the use of GridLines for the grid arg of ControlSpecs from here:

Unfortunately, it looks like the grid lines are automagically generated based on the data bounds.

Taking a quick look, instance methods can be used to generate the list of grid lines of different densities, but the GridLines object doesn’t have a numTicks member or something similar, so doesn’t seem settable in a practical sense :confused:

In fact, DrawGridX, for example, doesn’t even call the relevant method with the numTicks argument, so it will always default to nil, meaning the number of ticks will be

numTicks = (pixRange / 64);
numTicks = numTicks.max(3).round(1);

Hm thats a pity - but thank you for your research!

There’s a PR in the works that may fix this :slight_smile:

Oh nice! Hope thats done soon ^-^