Define major/minor ticks using bokhe in python

This is a cross-posting from SO:

Consider the following simple example:

Long range of dates, each given as a string

xLabels = [‘2014-08-01’, ‘2014-08-02’, ‘2014-08-03’, ‘2014-08-04’, ‘2014-08-05’, ‘2014-08-06’, ‘2014-08-07’, ‘2014-08-08’, ‘2014-08-09’, ‘2014-08-10’, ‘2014-08-11’, ‘2014-08-12’, ‘2014-08-13’, ‘2014-08-14’, ‘2014-08-15’, ‘2014-08-16’, ‘2014-08-17’, ‘2014-08-18’, ‘2014-08-19’, ‘2014-08-20’, ‘2014-08-21’, ‘2014-08-22’, ‘2014-08-23’, ‘2014-08-24’, ‘2014-08-25’, ‘2014-08-26’, ‘2014-08-27’, ‘2014-08-28’, ‘2014-08-29’, ‘2014-08-30’, ‘2014-08-31’, ‘2014-09-01’, ‘2014-09-02’, ‘2014-09-03’, ‘2014-09-04’, ‘2014-09-05’, ‘2014-09-06’, ‘2014-09-07’, ‘2014-09-08’, ‘2014-09-09’, ‘2014-09-10’, ‘2014-09-11’, ‘2014-09-12’, ‘2014-09-13’, ‘2014-09-14’, ‘2014-09-15’, ‘2014-09-16’, ‘2014-09-17’, ‘2014-09-18’, ‘2014-09-19’, ‘2014-09-20’, ‘2014-09-21’, ‘2014-09-22’, ‘2014-09-23’, ‘2014-09-24’, ‘2014-09-25’, ‘2014-09-26’, ‘2014-09-27’, ‘2014-09-28’, ‘2014-09-29’, ‘2014-09-30’, ‘2014-10-01’, ‘2014-10-02’, ‘2014-10-03’, ‘2014-10-04’, ‘2014-10-05’, ‘2014-10-06’, ‘2014-10-07’, ‘2014-10-08’, ‘2014-10-09’, ‘2014-10-10’, ‘2014-10-11’, ‘2014-10-12’, ‘2014-10-13’, ‘2014-10-14’, ‘2014-10-15’, ‘2014-10-16’, ‘2014-10-17’, ‘2014-10-18’, ‘2014-10-19’, ‘2014-10-20’, ‘2014-10-21’, ‘2014-10-22’, ‘2014-10-23’, ‘2014-10-24’, ‘2014-10-25’, ‘2014-10-26’, ‘2014-10-27’, ‘2014-10-28’, ‘2014-10-29’, ‘2014-10-30’, ‘2014-10-31’]
y = np.random.randn(len(xLabels))
myPlot = figure(x_range = xLabels)
myPlot.line(xLabels,y)
myPlot.xaxis.major_label_orientation = np.pi/2
show(myPlot)

``

The x-axis labels of the resulting plot are too dense (and not all are needed). I don’t understand how can I only display every n tick? How can I define which ticks are major and which are minor?

By supplying a list of *strings* you are creating a categorical range. This will result in a categorical axis. There is no notion of major or minor ticks on a categorial axis. Those notions only apply to continuous ranges, with associated linear, log, or datetime axes. Categorical axes simply display a tick and a label for every category, there is not really anything else sensible to do. You probably want a datetime axis, using real datetime data for the range. There are many examples of using datetime data (not strings, which are interpreted as categories). Here is one that may be useful:

  https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/candlestick.py

Thanks,

Bryan

···

On Feb 23, 2015, at 3:59 AM, Dror Atariah <[email protected]> wrote:

This is a cross-posting from SO:

Consider the following simple example:

# Long range of dates, each given as a string
xLabels = ['2014-08-01', '2014-08-02', '2014-08-03', '2014-08-04', '2014-08-05', '2014-08-06', '2014-08-07', '2014-08-08', '2014-08-09', '2014-08-10', '2014-08-11', '2014-08-12', '2014-08-13', '2014-08-14', '2014-08-15', '2014-08-16', '2014-08-17', '2014-08-18', '2014-08-19', '2014-08-20', '2014-08-21', '2014-08-22', '2014-08-23', '2014-08-24', '2014-08-25', '2014-08-26', '2014-08-27', '2014-08-28', '2014-08-29', '2014-08-30', '2014-08-31', '2014-09-01', '2014-09-02', '2014-09-03', '2014-09-04', '2014-09-05', '2014-09-06', '2014-09-07', '2014-09-08', '2014-09-09', '2014-09-10', '2014-09-11', '2014-09-12', '2014-09-13', '2014-09-14', '2014-09-15', '2014-09-16', '2014-09-17', '2014-09-18', '2014-09-19', '2014-09-20', '2014-09-21', '2014-09-22', '2014-09-23', '2014-09-24', '2014-09-25', '2014-09-26', '2014-09-27', '2014-09-28', '2014-09-29', '2014-09-30', '2014-10-01', '2014-10-02', '2014-10-03', '2014-10-04', '2014-10-05', '2014-10-06', '2014-10-07', '2014-10-08', '2014-10-09', '2014-10-10', '2014-10-11', '2014-10-12', '2014-10-13', '2014-10-14', '2014-10-15', '2014-10-16', '2014-10-17', '2014-10-18', '2014-10-19', '2014-10-20', '2014-10-21', '2014-10-22', '2014-10-23', '2014-10-24', '2014-10-25', '2014-10-26', '2014-10-27', '2014-10-28', '2014-10-29', '2014-10-30', '2014-10-31']
y = np.random.randn(len(xLabels))
myPlot = figure(x_range = xLabels)
myPlot.line(xLabels,y)
myPlot.xaxis.major_label_orientation = np.pi/2
show(myPlot)

The x-axis labels of the resulting plot are too dense (and not all are needed). I don't understand how can I only display every n tick? How can I define which ticks are major and which are minor?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6d630345-f6ae-4c37-a45c-2eb3aab65078%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.