How to set main ticks on not-integers

I would like to draw a grid - thus set the main ticks on non-integer values, like: -1.5, -0.5, 0.5, 1.5 etc, ommiting 0, 1, 2 etc.

I’ve tried with SetNdivisions - it partially works - I need to switch optimizing off. However, my bins are not exactly starting and ending on selected ticks, so on the axis, instead of -0.5, 0.5 etc. I’ve got -0.5343, 0.5332 etc. When I have optimizing on, the main ticks always include integer values.

I also tried TAxis::Set():

	Float_t xbin[] = {-7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5};
	p->GetXaxis()->Set(15, xbin);

But for the above I got:
Error in TAxis::TAxis::Set: bins must be in increasing order
Error in TAxis::TAxis::Set: bins must be in increasing order

So, is there a way to set non-integer main ticks? I appreciate any help.

When a grid is requested (with TCanvas::SetGridx or y), the grid lines are drawn on all the main tick marks. The type of labels (integer or not) is not taken into account. If you want to draw the grid on some specific ticks only, you will have to draw the grid yourself using TLine.