In Flot, is it possible to eliminate or hide grid ticks without eliminating the corresponding label?

Greg Borenstein picture Greg Borenstein · Oct 4, 2008 · Viewed 14.8k times · Source

The Flot API documentation describes the library's extensive hooks for customizing the axes of a graph. You can set the number of ticks, their color, etc. separately for each axis. However, I can not figure out how to prevent Flot from drawing the vertical grid lines without also removing the x-axis labels. I've tried changing the tickColor, ticks, and tickSize options with no success.

I want to create beautiful, Tufte-compatible graphs such as these:

http://www.robgoodlatte.com/wp-content/uploads/2007/05/tufte_mint.gif http://www.argmax.com/mt_blog/archive/RealGDP_graph.jpg

I find the vertical ticks on my graphs to be chart junk. I am working with a time series that I am displaying as vertical bars so the vertical ticks often cut through the bars in a way that is visually noisy.

Answer

Darren picture Darren · Jan 14, 2011

As Laurimann noted, Flot continues to evolve. The ability to control this has been added to the API (as noted in the flot issue Nelson linked to).

If you download the latest version (which is still labeled 0.6), you can disable lines on an axis with "tickLength", like so:

xaxis: {
  tickLength: 0
}

Rather annoyingly, this addition hasn't been updated in the API documentation.