Custom tick labels

Aug 8, 2013 at 5:42 AM
Edited Aug 8, 2013 at 8:21 AM
I need to plot some numeric data as a function of audio frequency. The frequency axis (x axis) is in octave bands - which is base 2 log. Here's an example I found online of what I want to plot:
The picture is not very good quality, the frequency values are: 63, 125, 250, 500, 1k, 2k, 4k, 8k Hz.

I can't seem to be able to create such an axis. I've tried a few things without success:
  1. Using log axis for frequency - but the values are calculated with a reference of 1. That means values count up as so: 1, 2, 4, 8, 16... etc. I need a way to set a custom reference (e.g. 1000 Hz) so I can start at 63 (or 62.5) and work my way up from there.
  2. Using a category axis for frequency, so I can specify a custom string - but I need the labels to line up with the grid lines, not in between the grid lines (if that makes sense?)
  3. Using a linear axis for frequency - but I see no way of replacing the numeric labels with custom strings.
Does anyone have any ideas? It seems like I need VS2012 (I have 2010) to open and compile the source, so I really am stuck. I think option 1. should be quite easy to implement?
Aug 11, 2013 at 3:59 PM
Edited Aug 11, 2013 at 3:59 PM
You could just override the LogarithmicAxis.GetTickValues() without recompiling oxyplot as I did here.

A hacky, but nonetheless working, example (in VB I'm afraid):
Public Class MyLogAxis
    Inherits Axes.LogarithmicAxis

    Public Overrides Sub GetTickValues(ByRef majorLabelValues As IList(Of Double), ByRef majorTickValues As IList(Of Double), ByRef minorTickValues As IList(Of Double))
        majorTickValues = New List(Of Double)

        minorTickValues = majorTickValues
        majorLabelValues = majorTickValues

    End Sub
End Class
Aug 13, 2013 at 7:00 AM
Ah, that's awesome. Thank you so much!
Jan 22, 2015 at 11:25 AM
Amazing! Just what I needed!